changeset 39907:b14bcf3a1610

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.
author Bruno Haible <bruno@clisp.org>
date Fri, 12 Oct 2018 11:06:33 +0200
parents 39f09bed8945
children f2b5499e6ee2
files ChangeLog lib/mountlist.c m4/ls-mntd-fs.m4
diffstat 3 files changed, 35 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Oct 12 02:42:44 2018 +0200
+++ b/ChangeLog	Fri Oct 12 11:06:33 2018 +0200
@@ -1,3 +1,12 @@
+2018-10-12  Bruno Haible  <bruno@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.
+
 2018-10-12  Bruno Haible  <bruno@clisp.org>
 
 	Make better use of Autoconf.
--- a/lib/mountlist.c	Fri Oct 12 02:42:44 2018 +0200
+++ b/lib/mountlist.c	Fri Oct 12 11:06:33 2018 +0200
@@ -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 @@
   }
 #endif /* MOUNTED_GETMNTINFO */
 
-#ifdef MOUNTED_GETMNTINFO2      /* NetBSD */
+#ifdef MOUNTED_GETMNTINFO2      /* NetBSD, Minix */
   {
     struct statvfs *fsp;
     int entries;
--- a/m4/ls-mntd-fs.m4	Fri Oct 12 02:42:44 2018 +0200
+++ b/m4/ls-mntd-fs.m4	Fri Oct 12 11:06:33 2018 +0200
@@ -28,7 +28,7 @@
 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 @@
   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 @@
            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