df throws the following error on FreeBSD:

root@140amd64_noopts-usrports:/usr/local/toybox/bin # ./df /
df: getmntinfo: Invalid argument

A little bit of poking around shows that getmntinfo expects the second
argument (the mode) to be one of these, and not 0:

#define MNT_WAIT    1   /* synchronously wait for I/O to complete */
#define MNT_NOWAIT  2   /* start all I/O, but do not wait for it */
#define MNT_LAZY    3   /* push data not written by filesystem syncer */
#define MNT_SUSPEND 4   /* Suspend file system after sync */

Changing 0 to MNT_NOWAIT in portability.c makes df happy again.
diff --git a/lib/portability.c b/lib/portability.c
index 83382d1d..a677173e 100644
--- a/lib/portability.c
+++ b/lib/portability.c
@@ -65,7 +65,11 @@ struct mtab_list *xgetmountlist(char *path)
   int i, count;
   if (path) error_exit("xgetmountlist");
+#if defined(__FreeBSD__)
+  if ((count = getmntinfo(&entries, MNT_NOWAIT)) == 0) perror_exit("getmntinfo");
   if ((count = getmntinfo(&entries, 0)) == 0) perror_exit("getmntinfo");
   // The "test" part of the loop is done before the first time through and
   // again after each "increment", so putting the actual load there avoids
Toybox mailing list

Reply via email to