diff lib/mountlist.c @ 14191:00edc8eebaa5

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.
author Markus Duft <mduft@gentoo.org>
date Thu, 20 Jan 2011 09:19:24 +0100
parents 97fc9a21a8fb
children 68883c50dbf9
line wrap: on
line diff
--- a/lib/mountlist.c	Thu Jan 20 11:50:53 2011 +0100
+++ b/lib/mountlist.c	Thu Jan 20 09:19:24 2011 +0100
@@ -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
@@ -879,6 +884,45 @@
   }
 #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;