Mercurial > gnulib
changeset 39908:f2b5499e6ee2
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.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Fri, 12 Oct 2018 11:12:53 +0200 |
parents | b14bcf3a1610 |
children | 24499928832b |
files | ChangeLog lib/mountlist.c m4/ls-mntd-fs.m4 |
diffstat | 3 files changed, 79 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Fri Oct 12 11:06:33 2018 +0200 +++ b/ChangeLog Fri Oct 12 11:12:53 2018 +0200 @@ -1,3 +1,12 @@ +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.
--- a/lib/mountlist.c Fri Oct 12 11:06:33 2018 +0200 +++ b/lib/mountlist.c Fri Oct 12 11:12:53 2018 +0200 @@ -111,7 +111,11 @@ # 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 @@ -918,10 +922,55 @@ } #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; @@ -979,6 +1028,7 @@ } ret = fclose (fp) == EOF ? errno : 0 < ret ? 0 : -1; + /* Here ret = -1 means success, ret >= 0 means failure. */ } if (0 <= lockfd && close (lockfd) != 0)
--- a/m4/ls-mntd-fs.m4 Fri Oct 12 11:06:33 2018 +0200 +++ b/m4/ls-mntd-fs.m4 Fri Oct 12 11:12:53 2018 +0200 @@ -158,7 +158,23 @@ 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],