From d1327df1f1c9bae26571e6699800c8d1c4712afb Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 12 Oct 2018 11:06:33 +0200 Subject: [PATCH] mountlist: Add support for Minix. Reported by Assaf Gordon in . * m4/ls-mntd-fs.m4 (gl_LIST_MOUNTED_FILE_SYSTEMS): Don't use AC_CHECK_FUNCS to check for 'getmntinfo'. * lib/mountlist.c: Update comments. --- ChangeLog | 9 +++++++++ lib/mountlist.c | 4 ++-- m4/ls-mntd-fs.m4 | 31 ++++++++++++++++++++++++------- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 27beb804fd..7d4d487d68 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2018-10-12 Bruno Haible + + mountlist: Add support for Minix. + Reported by Assaf Gordon in + . + * m4/ls-mntd-fs.m4 (gl_LIST_MOUNTED_FILE_SYSTEMS): Don't use + AC_CHECK_FUNCS to check for 'getmntinfo'. + * lib/mountlist.c: Update comments. + 2018-10-12 Bruno Haible Make better use of Autoconf. diff --git a/lib/mountlist.c b/lib/mountlist.c index 79a584e9ef..970c611510 100644 --- a/lib/mountlist.c +++ b/lib/mountlist.c @@ -83,7 +83,7 @@ # include #endif -#ifdef MOUNTED_GETMNTINFO2 /* NetBSD */ +#ifdef MOUNTED_GETMNTINFO2 /* NetBSD, Minix */ # include #endif @@ -629,7 +629,7 @@ read_file_system_list (bool need_fs_type) } #endif /* MOUNTED_GETMNTINFO */ -#ifdef MOUNTED_GETMNTINFO2 /* NetBSD */ +#ifdef MOUNTED_GETMNTINFO2 /* NetBSD, Minix */ { struct statvfs *fsp; int entries; diff --git a/m4/ls-mntd-fs.m4 b/m4/ls-mntd-fs.m4 index 6a03fe3a4a..ff688f5ce3 100644 --- a/m4/ls-mntd-fs.m4 +++ b/m4/ls-mntd-fs.m4 @@ -28,7 +28,7 @@ AC_DEFUN([AC_FUNC_GETMNTENT], AC_DEFUN([gl_LIST_MOUNTED_FILE_SYSTEMS], [ AC_REQUIRE([AC_CANONICAL_HOST]) - AC_CHECK_FUNCS([listmntent getmntinfo]) + AC_CHECK_FUNCS([listmntent]) AC_CHECK_HEADERS_ONCE([sys/param.h sys/statvfs.h]) # We must include grp.h before ucred.h on OSF V4.0, since ucred.h uses @@ -229,14 +229,31 @@ $getfsstat_includes fi if test -z "$ac_list_mounted_fs"; then - # Mac OS X, FreeBSD, NetBSD, OpenBSD, also (obsolete) 4.4BSD. + # Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix, also (obsolete) 4.4BSD. # OSF/1 also has getmntinfo but is already handled above. + # We cannot use AC_CHECK_FUNCS([getmntinfo]) here, because at the linker + # level the function is sometimes called getmntinfo64 or getmntinfo$INODE64 + # on Mac OS X, __getmntinfo13 on NetBSD and Minix, _F64_getmntinfo on OSF/1. AC_CACHE_CHECK([for getmntinfo function], [fu_cv_sys_mounted_getmntinfo], - [ - test "$ac_cv_func_getmntinfo" = yes \ - && fu_cv_sys_mounted_getmntinfo=yes \ - || fu_cv_sys_mounted_getmntinfo=no + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[ +#if HAVE_SYS_PARAM_H +# include +#endif +#include +#if HAVE_SYS_MOUNT_H +# include +#endif +#if HAVE_SYS_STATVFS_H +# include +#endif +#include + ]], + [[int count = getmntinfo (NULL, MNT_WAIT); + ]])], + [fu_cv_sys_mounted_getmntinfo=yes], + [fu_cv_sys_mounted_getmntinfo=no]) ]) if test $fu_cv_sys_mounted_getmntinfo = yes; then AC_CACHE_CHECK([whether getmntinfo returns statvfs structures], @@ -270,7 +287,7 @@ int getmntinfo (struct statfs **, int); list of mounted file systems and it returns an array of 'struct statfs'. (4.4BSD, Darwin)]) else - # NetBSD. + # NetBSD, Minix. ac_list_mounted_fs=found AC_DEFINE([MOUNTED_GETMNTINFO2], [1], [Define if there is a function named getmntinfo for reading the -- 2.39.5