From: Marc Espie Subject: Re: new (wip-ish): sysutils/plocate To: ports Date: Sat, 3 Aug 2024 10:21:56 +0200 On Fri, Aug 02, 2024 at 06:14:47PM +0100, Stuart Henderson wrote: > Biggest yucky bit with the port if used as a "standard" locate tool is > that the code to check filesystem types is Linux-only and I haven't > added an OpenBSD implementation, so you can't easily disable (e.g.) > "all NFS partitions", you've got to specify paths to skip. I've looked at the FreeBSD port, puked in my mouth a bit (I assume they already got that horrible compat code from somewhere else) and wrote a quickie using statfs Should work. New port attached. I also took the liberty of silencing some crazy warning from modern clang. (no idea if it's possible to do that directly on the meson command line) Index: updatedb.cpp --- updatedb.cpp.orig +++ updatedb.cpp @@ -43,7 +43,12 @@ any later version. #include #include #include +#ifdef __OpenBSD__ +#include +#include +#else #include +#endif #include #include #include @@ -58,6 +63,8 @@ any later version. #include #include +char *program_invocation_name; + using namespace std; using namespace std::chrono; @@ -164,6 +171,20 @@ bool filesystem_is_excluded(const string &path) if (conf_debug_pruning) { fprintf(stderr, "Checking whether filesystem `%s' is excluded:\n", path.c_str()); } +#ifdef __OpenBSD__ + struct statfs buf; + if (statfs(path.c_str(), &buf) == -1) + perror("statfs failed"); + string type(buf.f_fstypename); + for (char &p : type) { + p = toupper(p); + } + bool exclude = (find(conf_prunefs.begin(), conf_prunefs.end(), type) != conf_prunefs.end()); + if (exclude && conf_debug_pruning) { + fprintf(stderr, " => excluded due to filesystem type\n"); + } + return exclude; +#else FILE *f = setmntent("/proc/mounts", "r"); if (f == nullptr) { return false; @@ -192,6 +213,7 @@ bool filesystem_is_excluded(const string &path) fprintf(stderr, "...not found in mount list\n"); } endmntent(f); +#endif return false; } @@ -780,6 +802,7 @@ int main(int argc, char **argv) rlim.rlim_cur = std::min(wanted, rlim.rlim_max); setrlimit(RLIMIT_NOFILE, &rlim); // Ignore errors. } + program_invocation_name = argv[0]; conf_prepare(argc, argv); if (conf_prune_bind_mounts) {