Sync with gnulib f7a6286e04209da1bc7b1820002b6a5c32638369.

mountlist: Improve support for Solaris in 64-bit mode.

* m4.include/gnulib/ls-mntd-fs.m4 (gl_LIST_MOUNTED_FILE_SYSTEMS): On
  Solaris 8 or newer, define MOUNTED_GETEXTMNTENT instead of
  MOUNTED_GETMNTENT2.
* src/filemanager/mountlist.c: Add code for MOUNTED_GETEXTMNTENT case.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2018-10-14 12:33:05 +03:00
parent 6d593567d1
commit 25a9aa1d45
2 changed files with 68 additions and 5 deletions

View File

@ -158,7 +158,23 @@ yes
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],

View File

@ -127,7 +127,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
@ -1095,12 +1099,54 @@ read_file_system_list (void)
}
endmnttbl ();
}
#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 = g_malloc (sizeof *me);
me->me_devname = g_strdup (mnt.mnt_special);
me->me_mountdir = g_strdup (mnt.mnt_mountp);
me->me_mntroot = NULL;
me->me_type = g_strdup (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);
mount_list = g_slist_prepend (mount_list, me);
}
ret = fclose (fp) == EOF ? errno : 0 < ret ? 0 : -1;
/* Here ret = -1 means success, ret >= 0 means failure. */
}
if (ret >= 0)
{
errno = ret;
goto free_then_fail;
}
}
#endif /* MOUNTED_GETEXTMNTENT */
#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;
@ -1157,6 +1203,7 @@ read_file_system_list (void)
}
ret = fclose (fp) == EOF ? errno : 0 < ret ? 0 : -1;
/* Here ret = -1 means success, ret >= 0 means failure. */
}
if (lockfd >= 0 && close (lockfd) != 0)