GNU file utilities
[gnulib.git] / lib / mountlist.c
index 88fda7a..4528c9e 100644 (file)
@@ -36,6 +36,11 @@ char *xrealloc ();
 char *xstrdup ();
 void error ();
 
+#if defined (MOUNTED_GETFSSTAT)        /* __alpha running OSF_1 */
+#  include <sys/mount.h>
+#  include <sys/fs_types.h>
+#endif /* MOUNTED_GETFSSTAT */
+
 #ifdef MOUNTED_GETMNTENT1      /* 4.3BSD, SunOS, HP-UX, Dynix, Irix.  */
 #include <mntent.h>
 #if !defined(MOUNTED)
@@ -77,6 +82,12 @@ void error ();
 #include <sys/vfs.h>
 #endif
 
+#ifdef DOLPHIN
+/* So special that it's not worth putting this in autoconf.  */
+#undef MOUNTED_FREAD_FSTYP
+#define MOUNTED_GETMNTTBL
+#endif
+
 #ifdef MOUNTED_GETMNTENT1      /* 4.3BSD, SunOS, HP-UX, Dynix, Irix.  */
 /* Return the value of the hexadecimal number represented by CP.
    No prefix (like '0x') or suffix (like 'h') is expected to be
@@ -116,8 +127,10 @@ fstype_to_string (t)
       return "ufs";
     case MOUNT_NFS:
       return "nfs";
+#ifdef MOUNT_PC
     case MOUNT_PC:
       return "pc";
+#endif
 #ifdef MOUNT_MFS
     case MOUNT_MFS:
       return "mfs";
@@ -268,6 +281,43 @@ read_filesystem_list (need_fs_type, all_fs)
   }
 #endif /* MOUNTED_GETMNT. */
 
+#if defined (MOUNTED_GETFSSTAT)        /* __alpha running OSF_1 */
+  {
+    int numsys, counter, bufsize;
+    struct statfs *stats;
+
+    numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT);
+    if (numsys < 0)
+      return (NULL);
+
+    bufsize = (1 + numsys) * sizeof (struct statfs);
+    stats = (struct statfs *)xmalloc (bufsize);
+    numsys = getfsstat (stats, bufsize, MNT_WAIT);
+
+    if (numsys < 0)
+      {
+       free (stats);
+       return (NULL);
+      }
+
+    for (counter = 0; counter < numsys; counter++)
+      {
+       me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
+       me->me_devname = xstrdup (stats[counter].f_mntfromname);
+       me->me_mountdir = xstrdup (stats[counter].f_mntonname);
+       me->me_type = mnt_names[stats[counter].f_type];
+       me->me_dev = -1;        /* Magic; means not known yet. */
+       me->me_next = NULL;
+
+       /* Add to the linked list. */
+       mtail->me_next = me;
+       mtail = me;
+      }
+
+    free (stats);
+  }
+#endif /* MOUNTED_GETFSSTAT */
+
 #if defined (MOUNTED_FREAD) || defined (MOUNTED_FREAD_FSTYP) /* SVR[23].  */
   {
     struct mnttab mnt;
@@ -314,6 +364,26 @@ read_filesystem_list (need_fs_type, all_fs)
   }
 #endif /* MOUNTED_FREAD || MOUNTED_FREAD_FSTYP.  */
 
+#ifdef MOUNTED_GETMNTTBL       /* DolphinOS goes it's own way */
+  {
+    struct mntent **mnttbl=getmnttbl(),**ent;
+    for (ent=mnttbl;*ent;ent++)
+      {
+       me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
+       me->me_devname = xstrdup ( (*ent)->mt_resource);
+       me->me_mountdir = xstrdup( (*ent)->mt_directory);
+       me->me_type =  xstrdup ((*ent)->mt_fstype);
+       me->me_dev = -1;        /* Magic; means not known yet. */
+       me->me_next = NULL;
+       
+       /* Add to the linked list. */
+       mtail->me_next = me;
+       mtail = me;
+      }
+    endmnttbl();
+  }
+#endif
+
 #ifdef MOUNTED_GETMNTENT2      /* SVR4.  */
   {
     struct mnttab mnt;