[lib/ChangeLog]
[gnulib.git] / m4 / ls-mntd-fs.m4
index ed24386..21ac4e7 100644 (file)
@@ -1,7 +1,7 @@
-#serial 20
+#serial 26
 # How to list mounted file systems.
 
-# Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
+# Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006 Free Software
 # Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
@@ -20,14 +20,15 @@ dnl
 AC_DEFUN([AC_FUNC_GETMNTENT],
 [# getmntent is in the standard C library on UNICOS, in -lsun on Irix 4,
 # -lseq on Dynix/PTX, -lgen on Unixware.
-AC_SEARCH_LIBS(getmntent, [sun seq gen], [AC_CHECK_FUNCS(getmntent)])
+AC_SEARCH_LIBS(getmntent, [sun seq gen])
+AC_CHECK_FUNCS(getmntent)
 ])
 
 # gl_LIST_MOUNTED_FILE_SYSTEMS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
 AC_DEFUN([gl_LIST_MOUNTED_FILE_SYSTEMS],
   [
 AC_CHECK_FUNCS(listmntent getmntinfo)
-AC_CHECK_HEADERS_ONCE(sys/param.h)
+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
 # NGROUPS (as the array dimension for a struct member) without a definition.
@@ -140,7 +141,8 @@ if test $ac_cv_func_getmntent = yes; then
 # endif
 #endif
 ],
-                    [ struct mntent *mnt = 0; char *table = MOUNTED; ],
+                    [ struct mntent *mnt = 0; char *table = MOUNTED;
+                     if (sizeof mnt && sizeof table) return 0;],
                    fu_cv_sys_mounted_getmntent1=yes,
                    fu_cv_sys_mounted_getmntent1=no)])
     AC_MSG_RESULT($fu_cv_sys_mounted_getmntent1)
@@ -166,6 +168,7 @@ if test $ac_cv_func_getmntent = yes; then
       AC_DEFINE(MOUNTED_GETMNTENT2, 1,
         [Define if there is a function named getmntent for reading the list of
          mounted file systems, and that function takes two arguments.  (SVR4)])
+      AC_CHECK_FUNCS(hasmntopt)
     fi
   fi
 
@@ -231,10 +234,39 @@ if test -z "$ac_list_mounted_fs"; then
     ])
   AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo)
   if test $fu_cv_sys_mounted_getmntinfo = yes; then
-    ac_list_mounted_fs=found
-    AC_DEFINE(MOUNTED_GETMNTINFO, 1,
-             [Define if there is a function named getmntinfo for reading the
-               list of mounted file systems.  (4.4BSD, Darwin)])
+    AC_MSG_CHECKING([whether getmntinfo returns statvfs structures])
+    AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo2,
+      [
+        AC_TRY_COMPILE([
+#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
+extern int getmntinfo (struct statfs **, int);
+          ], [],
+          [fu_cv_sys_mounted_getmntinfo2=no],
+          [fu_cv_sys_mounted_getmntinfo2=yes])
+      ])
+    AC_MSG_RESULT([$fu_cv_sys_mounted_getmntinfo2])
+    if test $fu_cv_sys_mounted_getmntinfo2 = no; then
+      ac_list_mounted_fs=found
+      AC_DEFINE(MOUNTED_GETMNTINFO, 1,
+               [Define if there is a function named getmntinfo for reading the
+                 list of mounted file systems and it returns an array of
+                 'struct statfs'.  (4.4BSD, Darwin)])
+    else
+      ac_list_mounted_fs=found
+      AC_DEFINE(MOUNTED_GETMNTINFO2, 1,
+               [Define if there is a function named getmntinfo for reading the
+                 list of mounted file systems and it returns an array of
+                 'struct statvfs'.  (NetBSD 3.0)])
+    fi
   fi
 fi