GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
#include <stdio.h>
#include <sys/types.h>
#include "mountlist.h"
#ifdef STDC_HEADERS
-#include <stdlib.h>
+# include <stdlib.h>
#else
void free ();
#endif
-#if defined(USG) || defined(STDC_HEADERS)
-#include <string.h>
+#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
+# include <string.h>
#else
-#include <strings.h>
+# include <strings.h>
#endif
char *strstr ();
char *xstrdup ();
void error ();
+#ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+
+#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)
+# include <mntent.h>
+# if !defined(MOUNTED)
# if defined(MNT_MNTTAB) /* HP-UX. */
-# define MOUNTED MNT_MNTTAB
+# define MOUNTED MNT_MNTTAB
# endif
# if defined(MNTTABNAME) /* Dynix. */
-# define MOUNTED MNTTABNAME
+# define MOUNTED MNTTABNAME
# endif
-#endif
+# endif
#endif
#ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */
-#include <sys/mount.h>
+# include <sys/mount.h>
#endif
#ifdef MOUNTED_GETMNT /* Ultrix. */
-#include <sys/param.h>
-#include <sys/mount.h>
-#include <sys/fs_types.h>
+# include <sys/mount.h>
+# include <sys/fs_types.h>
#endif
#ifdef MOUNTED_FREAD /* SVR2. */
-#include <mnttab.h>
+# include <mnttab.h>
#endif
#ifdef MOUNTED_FREAD_FSTYP /* SVR3. */
-#include <mnttab.h>
-#include <sys/fstyp.h>
-#include <sys/statfs.h>
+# include <mnttab.h>
+# include <sys/fstyp.h>
+# include <sys/statfs.h>
+#endif
+
+#ifdef MOUNTED_LISTMNTENT
+# include <mntent.h>
#endif
#ifdef MOUNTED_GETMNTENT2 /* SVR4. */
-#include <sys/mnttab.h>
+# include <sys/mnttab.h>
#endif
#ifdef MOUNTED_VMOUNT /* AIX. */
-#include <fshelp.h>
-#include <sys/vfs.h>
+# include <fshelp.h>
+# 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. */
char *cp;
{
int val;
-
+
val = 0;
while (*cp)
{
}
#endif /* MOUNTED_GETMNTENT1. */
-#ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */
+#if defined (MOUNTED_GETMNTINFO) && !defined (__NetBSD__)
static char *
fstype_to_string (t)
short t;
{
switch (t)
{
- case MOUNT_UFS:
- return "ufs";
- case MOUNT_NFS:
- return "nfs";
+# ifdef MOUNT_PC
case MOUNT_PC:
return "pc";
-#ifdef MOUNT_MFS
+# endif
+# ifdef MOUNT_MFS
case MOUNT_MFS:
return "mfs";
-#endif
-#ifdef MOUNT_LO
+# endif
+# ifdef MOUNT_LO
case MOUNT_LO:
return "lo";
-#endif
-#ifdef MOUNT_TFS
+# endif
+# ifdef MOUNT_TFS
case MOUNT_TFS:
return "tfs";
-#endif
-#ifdef MOUNT_TMP
+# endif
+# ifdef MOUNT_TMP
case MOUNT_TMP:
return "tmp";
-#endif
+# endif
+# ifdef MOUNT_UFS
+ case MOUNT_UFS:
+ return "ufs" ;
+# endif
+# ifdef MOUNT_NFS
+ case MOUNT_NFS:
+ return "nfs" ;
+# endif
+# ifdef MOUNT_MSDOS
+ case MOUNT_MSDOS:
+ return "msdos" ;
+# endif
+# ifdef MOUNT_LFS
+ case MOUNT_LFS:
+ return "lfs" ;
+# endif
+# ifdef MOUNT_LOFS
+ case MOUNT_LOFS:
+ return "lofs" ;
+# endif
+# ifdef MOUNT_FDESC
+ case MOUNT_FDESC:
+ return "fdesc" ;
+# endif
+# ifdef MOUNT_PORTAL
+ case MOUNT_PORTAL:
+ return "portal" ;
+# endif
+# ifdef MOUNT_NULL
+ case MOUNT_NULL:
+ return "null" ;
+# endif
+# ifdef MOUNT_UMAP
+ case MOUNT_UMAP:
+ return "umap" ;
+# endif
+# ifdef MOUNT_KERNFS
+ case MOUNT_KERNFS:
+ return "kernfs" ;
+# endif
+# ifdef MOUNT_PROCFS
+ case MOUNT_PROCFS:
+ return "procfs" ;
+# endif
+# ifdef MOUNT_AFS
+ case MOUNT_AFS:
+ return "afs" ;
+# endif
+# ifdef MOUNT_CD9660
+ case MOUNT_CD9660:
+ return "cd9660" ;
+# endif
+# ifdef MOUNT_UNION
+ case MOUNT_UNION:
+ return "union" ;
+# endif
+# ifdef MOUNT_DEVFS
+ case MOUNT_DEVFS:
+ return "devfs" ;
+# endif
+# ifdef MOUNT_EXT2FS
+ case MOUNT_EXT2FS:
+ return "ext2fs" ;
+# endif
default:
return "?";
}
me->me_next = NULL;
mount_list = mtail = me;
+#ifdef MOUNTED_LISTMNTENT
+ {
+ struct tabmntent *mntlist, *p;
+ struct mntent *mnt;
+ struct mount_entry *me;
+
+ /* the third and fourth arguments could be used to filter mounts,
+ but Crays doesn't seem to have any mounts that we want to
+ remove. Specifically, automount create normal NFS mounts.
+ */
+
+ if(listmntent(&mntlist, KMTAB, NULL, NULL) < 0)
+ return NULL;
+ p = mntlist;
+ while(p){
+ mnt = p->ment;
+ me = (struct mount_entry*) xmalloc(sizeof (struct mount_entry));
+ me->me_devname = xstrdup(mnt->mnt_fsname);
+ me->me_mountdir = xstrdup(mnt->mnt_dir);
+ me->me_type = xstrdup(mnt->mnt_type);
+ me->me_dev = -1;
+ me->me_next = NULL;
+ mtail->me_next = me;
+ mtail = me;
+ p = p->next;
+ }
+ freemntlist(mntlist);
+ }
+#endif
+
#ifdef MOUNTED_GETMNTENT1 /* 4.3BSD, SunOS, HP-UX, Dynix, Irix. */
{
struct mntent *mnt;
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. */
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. */
}
#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;
while (fread (&mnt, sizeof mnt, 1, fp) > 0)
{
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
-#ifdef GETFSTYP /* SVR3. */
+# ifdef GETFSTYP /* SVR3. */
me->me_devname = xstrdup (mnt.mt_dev);
-#else
+# else
me->me_devname = xmalloc (strlen (mnt.mt_dev) + 6);
strcpy (me->me_devname, "/dev/");
strcpy (me->me_devname + 5, mnt.mt_dev);
-#endif
+# 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. */
+# ifdef GETFSTYP /* SVR3. */
if (need_fs_type)
{
struct statfs fsd;
&& sysfs (GETFSTYP, fsd.f_fstyp, typebuf) != -1)
me->me_type = xstrdup (typebuf);
}
-#endif
+# endif
me->me_next = NULL;
/* Add to the linked list. */
}
#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;
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. */
}
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. */