/* mountlist.c -- return a list of mounted filesystems
- Copyright (C) 1991, 1992 Free Software Foundation, Inc.
+ Copyright (C) 1991, 1992, 1997, 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
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
+#if HAVE_CONFIG_H
# include <config.h>
#endif
# include <strings.h>
#endif
+#ifndef strstr
char *strstr ();
+#endif
char *xmalloc ();
char *xrealloc ();
char *xstrdup ();
void error ();
-#ifdef HAVE_SYS_PARAM_H
+#if HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif
# define MOUNTED_GETMNTTBL
#endif
+#if HAVE_SYS_MNTENT_H
+/* This is to get MNTOPT_IGNORE on e.g. SVR4. */
+# include <sys/mntent.h>
+#endif
+
+#if defined (MNTOPT_IGNORE) && defined (HAVE_HASMNTOPT)
+# define MNT_IGNORE(M) hasmntopt ((M), MNTOPT_IGNORE)
+#else
+# define MNT_IGNORE(M) 0
+#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
}
#endif /* MOUNTED_GETMNTENT1. */
-#if defined (MOUNTED_GETMNTINFO) && !defined (__NetBSD__)
+#if defined (MOUNTED_GETMNTINFO) && !defined (__NetBSD__) && !defined (__OpenBSD__)
static char *
fstype_to_string (t)
short t;
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__
+# if defined (__NetBSD__) || defined (__OpenBSD__)
me->me_type = xstrdup (fsp->f_fstypename);
# else
me->me_type = fstype_to_string (fsp->f_type);
while ((ret = getmntent (fp, &mnt)) == 0)
{
+ /* Don't show automounted filesystems twice on e.g., Solaris. */
+ if (!all_fs && MNT_IGNORE (&mnt))
+ continue;
+
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
me->me_devname = xstrdup (mnt.mnt_special);
me->me_mountdir = xstrdup (mnt.mnt_mountp);