X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fmountlist.c;h=5933f76881e2c7a2b1eddbb33e23f23781426c06;hb=84fdd39f05ad45f6126fa58023fd73a876c85733;hp=78955f709d3dfff4a2d5cc3f2bf0a564e1b1b122;hpb=d87c39464604e74f580c7fae835be31a4c125c36;p=gnulib.git diff --git a/lib/mountlist.c b/lib/mountlist.c index 78955f709..5933f7688 100644 --- a/lib/mountlist.c +++ b/lib/mountlist.c @@ -15,6 +15,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include #include "mountlist.h" @@ -24,7 +28,7 @@ #else void free (); #endif -#if defined(USG) || defined(STDC_HEADERS) +#if defined(STDC_HEADERS) || defined(HAVE_STRING_H) #include #else #include @@ -36,6 +40,15 @@ char *xrealloc (); char *xstrdup (); void error (); +#ifdef HAVE_SYS_PARAM_H +#include +#endif + +#if defined (MOUNTED_GETFSSTAT) /* __alpha running OSF_1 */ +# include +# include +#endif /* MOUNTED_GETFSSTAT */ + #ifdef MOUNTED_GETMNTENT1 /* 4.3BSD, SunOS, HP-UX, Dynix, Irix. */ #include #if !defined(MOUNTED) @@ -53,7 +66,6 @@ void error (); #endif #ifdef MOUNTED_GETMNT /* Ultrix. */ -#include #include #include #endif @@ -77,6 +89,12 @@ void error (); #include #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 @@ -87,7 +105,7 @@ xatoi (cp) char *cp; { int val; - + val = 0; while (*cp) { @@ -105,7 +123,7 @@ xatoi (cp) } #endif /* MOUNTED_GETMNTENT1. */ -#ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */ +#if defined (MOUNTED_GETMNTINFO) && !defined (__NetBSD__) static char * fstype_to_string (t) short t; @@ -116,8 +134,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"; @@ -205,7 +225,7 @@ read_filesystem_list (need_fs_type, all_fs) me->me_dev = xatoi (devopt + 4); } else - me->me_dev = -1; /* Magic; means not known yet. */ + me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ me->me_next = NULL; /* Add to the linked list. */ @@ -231,8 +251,12 @@ read_filesystem_list (need_fs_type, all_fs) me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry)); me->me_devname = xstrdup (fsp->f_mntfromname); me->me_mountdir = xstrdup (fsp->f_mntonname); +#ifdef __NetBSD__ + me->me_type = xstrdup (fsp->f_fstypename); +#else me->me_type = fstype_to_string (fsp->f_type); - me->me_dev = -1; /* Magic; means not known yet. */ +#endif + me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ me->me_next = NULL; /* Add to the linked list. */ @@ -268,6 +292,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 = (dev_t) -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; @@ -289,7 +350,7 @@ read_filesystem_list (need_fs_type, all_fs) strcpy (me->me_devname + 5, mnt.mt_dev); #endif me->me_mountdir = xstrdup (mnt.mt_filsys); - me->me_dev = -1; /* Magic; means not known yet. */ + me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ me->me_type = ""; #ifdef GETFSTYP /* SVR3. */ if (need_fs_type) @@ -314,6 +375,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 = (dev_t) -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; @@ -331,7 +412,7 @@ read_filesystem_list (need_fs_type, all_fs) me->me_devname = xstrdup (mnt.mnt_special); me->me_mountdir = xstrdup (mnt.mnt_mountp); me->me_type = xstrdup (mnt.mnt_fstype); - me->me_dev = -1; /* Magic; means not known yet. */ + me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ me->me_next = NULL; /* Add to the linked list. */ @@ -378,12 +459,12 @@ read_filesystem_list (need_fs_type, all_fs) } else { - me->me_devname = xstrdup (thisent + + me->me_devname = xstrdup (thisent + vmp->vmt_data[VMT_OBJECT].vmt_off); } me->me_mountdir = xstrdup (thisent + vmp->vmt_data[VMT_STUB].vmt_off); me->me_type = xstrdup (fstype_to_string (vmp->vmt_gfstype)); - me->me_dev = -1; /* vmt_fsid might be the info we want. */ + me->me_dev = (dev_t) -1; /* vmt_fsid might be the info we want. */ me->me_next = NULL; /* Add to the linked list. */