mountlist: add support for Interix
authorMarkus Duft <mduft@gentoo.org>
Thu, 20 Jan 2011 08:19:24 +0000 (09:19 +0100)
committerJim Meyering <meyering@redhat.com>
Thu, 20 Jan 2011 14:56:23 +0000 (15:56 +0100)
* lib/mountlist.c (read_file_system_list) [MOUNTED_INTERIX_STATVFS]:
Apply statvfs to all entries of /dev/fs.
* m4/ls-mntd-fs.m4 (gl_LIST_MOUNTED_FILE_SYSTEMS): Check for statvfs,
and if found, AC_DEFINE MOUNTED_INTERIX_STATVFS.

ChangeLog
lib/mountlist.c
m4/ls-mntd-fs.m4

index 9c125c9..b122696 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-01-14  Markus Duft <mduft@gentoo.org>
+
+       mountlist: add support for Interix
+       * lib/mountlist.c (read_file_system_list) [MOUNTED_INTERIX_STATVFS]:
+       Apply statvfs to all entries of /dev/fs.
+       * m4/ls-mntd-fs.m4 (gl_LIST_MOUNTED_FILE_SYSTEMS): Check for statvfs,
+       and if found, AC_DEFINE MOUNTED_INTERIX_STATVFS.
+
 2011-01-20  Jim Meyering  <meyering@redhat.com>
 
        maint.mk: improve the public-submodule-commit rule
index afe813c..397de57 100644 (file)
 # 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
@@ -879,6 +884,45 @@ read_file_system_list (bool need_fs_type)
   }
 #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;
 
index 0500699..72beaed 100644 (file)
@@ -326,6 +326,23 @@ if test -z "$ac_list_mounted_fs"; then
 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 mounted 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