Download raw body.
new (wip-ish): sysutils/plocate
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 <iosfwd>
#include <math.h>
#include <memory>
+#ifdef __OpenBSD__
+#include <sys/types.h>
+#include <sys/mount.h>
+#else
#include <mntent.h>
+#endif
#include <random>
#include <stdint.h>
#include <stdio.h>
@@ -58,6 +63,8 @@ any later version.
#include <utility>
#include <vector>
+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<rlim_t>(wanted, rlim.rlim_max);
setrlimit(RLIMIT_NOFILE, &rlim); // Ignore errors.
}
+ program_invocation_name = argv[0];
conf_prepare(argc, argv);
if (conf_prune_bind_mounts) {
new (wip-ish): sysutils/plocate