Hi!

I just created the attached patch for findutils to build. Any chance to
get this in your git repo? :) The code is as good as it can get with
interix, i think - improvement suggestions welcome!

Thanks!
Markus
diff -ru findutils-4.5.9.orig/gnulib/lib/mountlist.c findutils-4.5.9/gnulib/lib/mountlist.c
--- findutils-4.5.9.orig/gnulib/lib/mountlist.c	2010-10-21 09:55:31 +0200
+++ findutils-4.5.9/gnulib/lib/mountlist.c	2010-10-21 10:36:22 +0200
@@ -112,6 +112,11 @@
 # include <sys/vfs.h>
 #endif
 
+#ifdef MOUNTED_INTERIX_STATVFS  /* Interix. */
+# include <sys/statvfs.h>
+# include <dirent.h>
+#endif
+
 #ifdef DOLPHIN
 /* So special that it's not worth putting this in autoconf.  */
 # undef MOUNTED_FREAD_FSTYP
@@ -854,6 +859,47 @@
   }
 #endif /* MOUNTED_VMOUNT. */
 
+#ifdef MOUNTED_INTERIX_STATVFS
+  {
+    DIR* dirp = opendir("/dev/fs");
+    char node[9 + NAME_MAX];
+
+    if(!dirp) 
+      {
+        goto free_then_fail;
+      }
+
+    while(1)
+      {
+        struct statvfs dev;
+        struct dirent entry;
+        struct dirent* result;
+
+        if(readdir_r(dirp, &entry, &result) || result == NULL)
+            break;
+
+        strcpy(node, "/dev/fs/");
+        strcat(node, entry.d_name);
+
+        if(statvfs(node, &dev) == 0)
+          {
+            me = xmalloc (sizeof *me);
+            me->me_devname = xstrdup(dev.f_mntfromname);
+            me->me_mountdir = xstrdup(dev.f_mntonname);
+            me->me_type = xstrdup(dev.f_fstypename);
+            me->me_type_malloced = 1;
+            me->me_dummy = ME_DUMMY(me->me_devname, me->me_type);
+            me->me_remote = ME_REMOTE(me->me_devname, me->me_type);
+            me->me_dev = (dev_t) -1;        /* Magic; means not known yet. */
+
+            /* Add to the linked list. */
+            *mtail = me;
+            mtail = &me->me_next;
+          }
+      }
+  }
+#endif /* MOUNTED_INTERIX_STATVFS */
+
   *mtail = NULL;
   return mount_list;
 
diff -ru findutils-4.5.9.orig/gnulib/m4/ls-mntd-fs.m4 findutils-4.5.9/gnulib/m4/ls-mntd-fs.m4
--- findutils-4.5.9.orig/gnulib/m4/ls-mntd-fs.m4	2010-10-21 09:55:32 +0200
+++ findutils-4.5.9/gnulib/m4/ls-mntd-fs.m4	2010-10-21 10:14:07 +0200
@@ -326,6 +326,23 @@
 fi
 
 if test -z "$ac_list_mounted_fs"; then
+  # Interix / BSD alike statvfs
+  # the code is really interix specific, so make sure, we're on it.
+  case "$host" in
+  *-interix*)
+      AC_CHECK_FUNCS([statvfs])
+      if test $ac_cv_func_statvfs = yes; then
+          ac_list_mounted_fs=found
+          AC_DEFINE([MOUNTED_INTERIX_STATVFS], [1],
+                    [Define if we are on interix, and ought to use statvfs plus
+                     some special knowledge on where mounte filesystems can be
+                     found. (Interix)])
+      fi  
+      ;;
+  esac
+fi
+
+if test -z "$ac_list_mounted_fs"; then
   AC_MSG_ERROR([could not determine how to read list of mounted file systems])
   # FIXME -- no need to abort building the whole package
   # Can't build mountlist.c or anything that needs its functions

Reply via email to