Assaf Gordon wrote in <https://lists.gnu.org/archive/html/bug-gnulib/2014-09/msg00074.html>:
> './configure' fails to detect "getmntinfo()" function call: > $ ./configure > checking whether it is possible to resort to fread on /etc/mnttab... no > configure: error: could not determine how to read list of mounted file > systems > > MINIX3 defines it as: > $ grep getmntinfo /usr/include/sys/statvfs.h > int getmntinfo(struct statvfs **, int) __RENAME(__getmntinfo13); > > Which I guess prevents a simple linking test to 'getmntinfo' to fail. > > A work-around is to use: > ./configure fu_cv_sys_mounted_getmntinfo=yes > > The relevant gnulib file is: > gnulib/m4/ls-mntd-fs.m4 > > I didn't find a way to test this directly with gnulib, as I couldn't find a > test C file with actually calls "read_file_system_list()" from > "lib/mountlist.h". > > Using the work-around (and the fixes mentioned below), "df" compiles and > works fine. Fixed as follows. Tested by injecting this change into coreutils-8.30 and running './df'. 2018-10-12 Bruno Haible <br...@clisp.org> mountlist: Add support for Minix. Reported by Assaf Gordon in <https://lists.gnu.org/archive/html/bug-gnulib/2014-09/msg00074.html>. * 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. diff --git a/lib/mountlist.c b/lib/mountlist.c index 79a584e..970c611 100644 --- a/lib/mountlist.c +++ b/lib/mountlist.c @@ -83,7 +83,7 @@ # include <sys/mount.h> #endif -#ifdef MOUNTED_GETMNTINFO2 /* NetBSD */ +#ifdef MOUNTED_GETMNTINFO2 /* NetBSD, Minix */ # include <sys/statvfs.h> #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 6a03fe3..ff688f5 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 <sys/param.h> +#endif +#include <sys/types.h> +#if HAVE_SYS_MOUNT_H +# include <sys/mount.h> +#endif +#if HAVE_SYS_STATVFS_H +# include <sys/statvfs.h> +#endif +#include <stdlib.h> + ]], + [[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