+2018-10-12 Bruno Haible <bruno@clisp.org>
+
+ mountlist: Improve support for Solaris in 64-bit mode.
+ Reported by David Wood <David.Wood@deshaw.com> in
+ <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=6816>.
+ * m4/ls-mntd-fs.m4 (gl_LIST_MOUNTED_FILE_SYSTEMS): On Solaris 8 or
+ newer, define MOUNTED_GETEXTMNTENT instead of MOUNTED_GETMNTENT2.
+ * lib/mountlist.c: Add code for MOUNTED_GETEXTMNTENT case.
+
2018-10-12 Bruno Haible <bruno@clisp.org>
mountlist: Add support for Minix.
# include <mntent.h>
#endif
-#ifdef MOUNTED_GETMNTENT2 /* Solaris, also (obsolete) SVR4 */
+#ifdef MOUNTED_GETEXTMNTENT /* Solaris >= 8 */
+# include <sys/mnttab.h>
+#endif
+
+#ifdef MOUNTED_GETMNTENT2 /* Solaris < 8, also (obsolete) SVR4 */
# include <sys/mnttab.h>
#endif
}
#endif /* MOUNTED_GETMNTTBL */
-#ifdef MOUNTED_GETMNTENT2 /* Solaris, also (obsolete) SVR4 */
+#ifdef MOUNTED_GETEXTMNTENT /* Solaris >= 8 */
+ {
+ struct extmnttab mnt;
+ const char *table = MNTTAB;
+ FILE *fp;
+ int ret;
+
+ /* No locking is needed, because the contents of /etc/mnttab is generated
+ by the kernel. */
+
+ errno = 0;
+ fp = fopen (table, "r");
+ if (fp == NULL)
+ ret = errno;
+ else
+ {
+ while ((ret = getextmntent (fp, &mnt, 1)) == 0)
+ {
+ me = xmalloc (sizeof *me);
+ me->me_devname = xstrdup (mnt.mnt_special);
+ me->me_mountdir = xstrdup (mnt.mnt_mountp);
+ me->me_mntroot = NULL;
+ me->me_type = xstrdup (mnt.mnt_fstype);
+ me->me_type_malloced = 1;
+ me->me_dummy = MNT_IGNORE (&mnt) != 0;
+ me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
+ me->me_dev = makedev (mnt.mnt_major, mnt.mnt_minor);
+
+ /* Add to the linked list. */
+ *mtail = me;
+ mtail = &me->me_next;
+ }
+
+ ret = fclose (fp) == EOF ? errno : 0 < ret ? 0 : -1;
+ /* Here ret = -1 means success, ret >= 0 means failure. */
+ }
+
+ if (0 <= ret)
+ {
+ errno = ret;
+ goto free_then_fail;
+ }
+ }
+#endif /* MOUNTED_GETMNTTBL */
+
+#ifdef MOUNTED_GETMNTENT2 /* Solaris < 8, also (obsolete) SVR4 */
{
struct mnttab mnt;
- char *table = MNTTAB;
+ const char *table = MNTTAB;
FILE *fp;
int ret;
int lockfd = -1;
}
ret = fclose (fp) == EOF ? errno : 0 < ret ? 0 : -1;
+ /* Here ret = -1 means success, ret >= 0 means failure. */
}
if (0 <= lockfd && close (lockfd) != 0)
fi
if test -z "$ac_list_mounted_fs"; then
- # Solaris, also (obsolete) SVR4.
+ # Solaris >= 8.
+ AC_CACHE_CHECK([for getextmntent function],
+ [fu_cv_sys_mounted_getextmntent],
+ [AC_EGREP_HEADER([getextmntent], [sys/mnttab.h],
+ [fu_cv_sys_mounted_getextmntent=yes],
+ [fu_cv_sys_mounted_getextmntent=no])])
+ if test $fu_cv_sys_mounted_getextmntent = yes; then
+ ac_list_mounted_fs=found
+ AC_DEFINE([MOUNTED_GETEXTMNTENT], [1],
+ [Define if there is a function named getextmntent for reading the list
+ of mounted file systems. (Solaris)])
+ fi
+ fi
+
+ if test -z "$ac_list_mounted_fs"; then
+ # Solaris < 8, also (obsolete) SVR4.
+ # Solaris >= 8 has the two-argument getmntent but is already handled above.
AC_CACHE_CHECK([for two-argument getmntent function],
[fu_cv_sys_mounted_getmntent2],
[AC_EGREP_HEADER([getmntent], [sys/mnttab.h],