* tests/test-xstrtoimax.sh (t-xstrtoimax.xo): Likewise.
[gnulib.git] / m4 / ls-mntd-fs.m4
index 2eca073..21ac4e7 100644 (file)
@@ -1,22 +1,12 @@
-#serial 19
+#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 program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
 dnl From Jim Meyering.
 dnl
@@ -30,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.
@@ -150,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)
@@ -176,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
 
@@ -241,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