diff options
author | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-08-19 21:27:12 (GMT) |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-08-19 21:27:12 (GMT) |
commit | 26fbe7f1e68bb0c96da32491efcf3696fe6c299b (patch) | |
tree | c4d95289187a64e9c7517bf73d8208026c3d2fb3 /gl/m4/fsusage.m4 | |
parent | 5f79e3e9f62ca5487d9881973149136ba1d19d3e (diff) | |
download | monitoring-plugins-26fbe7f1e68bb0c96da32491efcf3696fe6c299b.tar.gz |
Sync with the latest Gnulib code (6f2d632)
Diffstat (limited to 'gl/m4/fsusage.m4')
-rw-r--r-- | gl/m4/fsusage.m4 | 107 |
1 files changed, 85 insertions, 22 deletions
diff --git a/gl/m4/fsusage.m4 b/gl/m4/fsusage.m4 index 68684c2..6277bfa 100644 --- a/gl/m4/fsusage.m4 +++ b/gl/m4/fsusage.m4 | |||
@@ -1,7 +1,7 @@ | |||
1 | # serial 26 | 1 | # serial 30 |
2 | # Obtaining file system usage information. | 2 | # Obtaining file system usage information. |
3 | 3 | ||
4 | # Copyright (C) 1997-1998, 2000-2001, 2003-2010 Free Software Foundation, Inc. | 4 | # Copyright (C) 1997-1998, 2000-2001, 2003-2013 Free Software Foundation, Inc. |
5 | # | 5 | # |
6 | # This file is free software; the Free Software Foundation | 6 | # This file is free software; the Free Software Foundation |
7 | # gives unlimited permission to copy and/or distribute it, | 7 | # gives unlimited permission to copy and/or distribute it, |
@@ -19,10 +19,6 @@ AC_DEFUN([gl_FSUSAGE], | |||
19 | #include <sys/param.h> | 19 | #include <sys/param.h> |
20 | #endif]]) | 20 | #endif]]) |
21 | gl_FILE_SYSTEM_USAGE([gl_cv_fs_space=yes], [gl_cv_fs_space=no]) | 21 | gl_FILE_SYSTEM_USAGE([gl_cv_fs_space=yes], [gl_cv_fs_space=no]) |
22 | if test $gl_cv_fs_space = yes; then | ||
23 | AC_LIBOBJ([fsusage]) | ||
24 | gl_PREREQ_FSUSAGE_EXTRA | ||
25 | fi | ||
26 | ]) | 22 | ]) |
27 | 23 | ||
28 | # Try to determine how a program can obtain file system usage information. | 24 | # Try to determine how a program can obtain file system usage information. |
@@ -33,6 +29,12 @@ AC_DEFUN([gl_FSUSAGE], | |||
33 | 29 | ||
34 | AC_DEFUN([gl_FILE_SYSTEM_USAGE], | 30 | AC_DEFUN([gl_FILE_SYSTEM_USAGE], |
35 | [ | 31 | [ |
32 | dnl Enable large-file support. This has the effect of changing the size | ||
33 | dnl of field f_blocks in 'struct statvfs' from 32 bit to 64 bit on | ||
34 | dnl glibc/Hurd, HP-UX 11, Solaris (32-bit mode). It also changes the size | ||
35 | dnl of field f_blocks in 'struct statfs' from 32 bit to 64 bit on | ||
36 | dnl Mac OS X >= 10.5 (32-bit mode). | ||
37 | AC_REQUIRE([AC_SYS_LARGEFILE]) | ||
36 | 38 | ||
37 | AC_MSG_NOTICE([checking how to get file system space usage]) | 39 | AC_MSG_NOTICE([checking how to get file system space usage]) |
38 | ac_fsusage_space=no | 40 | ac_fsusage_space=no |
@@ -40,37 +42,98 @@ ac_fsusage_space=no | |||
40 | # Perform only the link test since it seems there are no variants of the | 42 | # Perform only the link test since it seems there are no variants of the |
41 | # statvfs function. This check is more than just AC_CHECK_FUNCS([statvfs]) | 43 | # statvfs function. This check is more than just AC_CHECK_FUNCS([statvfs]) |
42 | # because that got a false positive on SCO OSR5. Adding the declaration | 44 | # because that got a false positive on SCO OSR5. Adding the declaration |
43 | # of a `struct statvfs' causes this test to fail (as it should) on such | 45 | # of a 'struct statvfs' causes this test to fail (as it should) on such |
44 | # systems. That system is reported to work fine with STAT_STATFS4 which | 46 | # systems. That system is reported to work fine with STAT_STATFS4 which |
45 | # is what it gets when this test fails. | 47 | # is what it gets when this test fails. |
46 | if test $ac_fsusage_space = no; then | 48 | if test $ac_fsusage_space = no; then |
47 | # glibc/{Hurd,kFreeBSD}, MacOS X >= 10.4, FreeBSD >= 5.0, NetBSD >= 3.0, | 49 | # glibc/{Hurd,kFreeBSD}, FreeBSD >= 5.0, NetBSD >= 3.0, |
48 | # OpenBSD >= 4.4, AIX, HP-UX, IRIX, Solaris, Cygwin, Interix, BeOS. | 50 | # OpenBSD >= 4.4, AIX, HP-UX, IRIX, Solaris, Cygwin, Interix, BeOS. |
49 | AC_CACHE_CHECK([for statvfs function (SVR4)], [fu_cv_sys_stat_statvfs], | 51 | AC_CACHE_CHECK([for statvfs function (SVR4)], [fu_cv_sys_stat_statvfs], |
50 | [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> | 52 | [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> |
51 | #if defined __GLIBC__ && defined __linux__ | ||
52 | Do not use statvfs on systems with GNU libc on Linux, because that function | ||
53 | stats all preceding entries in /proc/mounts, and that makes df hang if even | ||
54 | one of the corresponding file systems is hard-mounted, but not available. | ||
55 | statvfs in GNU libc on Hurd, BeOS, Haiku operates differently: it only makes | ||
56 | a system call. | ||
57 | #endif | ||
58 | |||
59 | #ifdef __osf__ | 53 | #ifdef __osf__ |
60 | "Do not use Tru64's statvfs implementation" | 54 | "Do not use Tru64's statvfs implementation" |
61 | #endif | 55 | #endif |
62 | 56 | ||
63 | #include <sys/statvfs.h>]], | 57 | #include <sys/statvfs.h> |
64 | [[struct statvfs fsd; statvfs (0, &fsd);]])], | 58 | |
59 | struct statvfs fsd; | ||
60 | |||
61 | #if defined __APPLE__ && defined __MACH__ | ||
62 | #include <limits.h> | ||
63 | /* On Mac OS X >= 10.5, f_blocks in 'struct statvfs' is a 32-bit quantity; | ||
64 | that commonly limits file systems to 4 TiB. Whereas f_blocks in | ||
65 | 'struct statfs' is a 64-bit type, thanks to the large-file support | ||
66 | that was enabled above. In this case, don't use statvfs(); use statfs() | ||
67 | instead. */ | ||
68 | int check_f_blocks_size[sizeof fsd.f_blocks * CHAR_BIT <= 32 ? -1 : 1]; | ||
69 | #endif | ||
70 | ]], | ||
71 | [[statvfs (0, &fsd);]])], | ||
65 | [fu_cv_sys_stat_statvfs=yes], | 72 | [fu_cv_sys_stat_statvfs=yes], |
66 | [fu_cv_sys_stat_statvfs=no])]) | 73 | [fu_cv_sys_stat_statvfs=no])]) |
67 | if test $fu_cv_sys_stat_statvfs = yes; then | 74 | if test $fu_cv_sys_stat_statvfs = yes; then |
68 | ac_fsusage_space=yes | 75 | ac_fsusage_space=yes |
69 | AC_DEFINE([STAT_STATVFS], [1], | 76 | # AIX >= 5.2 has statvfs64 that has a wider f_blocks field than statvfs. |
70 | [ Define if there is a function named statvfs. (SVR4)]) | 77 | # glibc, HP-UX, IRIX, Solaris have statvfs64 as well, but on these systems |
78 | # statvfs with large-file support is already equivalent to statvfs64. | ||
79 | AC_CACHE_CHECK([whether to use statvfs64], | ||
80 | [fu_cv_sys_stat_statvfs64], | ||
81 | [AC_LINK_IFELSE( | ||
82 | [AC_LANG_PROGRAM( | ||
83 | [[#include <sys/types.h> | ||
84 | #include <sys/statvfs.h> | ||
85 | struct statvfs64 fsd; | ||
86 | int check_f_blocks_larger_in_statvfs64 | ||
87 | [sizeof (((struct statvfs64 *) 0)->f_blocks) | ||
88 | > sizeof (((struct statvfs *) 0)->f_blocks) | ||
89 | ? 1 : -1]; | ||
90 | ]], | ||
91 | [[statvfs64 (0, &fsd);]])], | ||
92 | [fu_cv_sys_stat_statvfs64=yes], | ||
93 | [fu_cv_sys_stat_statvfs64=no]) | ||
94 | ]) | ||
95 | if test $fu_cv_sys_stat_statvfs64 = yes; then | ||
96 | AC_DEFINE([STAT_STATVFS64], [1], | ||
97 | [ Define if statvfs64 should be preferred over statvfs.]) | ||
98 | else | ||
99 | AC_DEFINE([STAT_STATVFS], [1], | ||
100 | [ Define if there is a function named statvfs. (SVR4)]) | ||
101 | fi | ||
71 | fi | 102 | fi |
72 | fi | 103 | fi |
73 | 104 | ||
105 | # Check for this unconditionally so we have a | ||
106 | # good fallback on glibc/Linux > 2.6 < 2.6.36 | ||
107 | AC_MSG_CHECKING([for two-argument statfs with statfs.f_frsize member]) | ||
108 | AC_CACHE_VAL([fu_cv_sys_stat_statfs2_frsize], | ||
109 | [AC_RUN_IFELSE([AC_LANG_SOURCE([[ | ||
110 | #ifdef HAVE_SYS_PARAM_H | ||
111 | #include <sys/param.h> | ||
112 | #endif | ||
113 | #ifdef HAVE_SYS_MOUNT_H | ||
114 | #include <sys/mount.h> | ||
115 | #endif | ||
116 | #ifdef HAVE_SYS_VFS_H | ||
117 | #include <sys/vfs.h> | ||
118 | #endif | ||
119 | int | ||
120 | main () | ||
121 | { | ||
122 | struct statfs fsd; | ||
123 | fsd.f_frsize = 0; | ||
124 | return statfs (".", &fsd) != 0; | ||
125 | }]])], | ||
126 | [fu_cv_sys_stat_statfs2_frsize=yes], | ||
127 | [fu_cv_sys_stat_statfs2_frsize=no], | ||
128 | [fu_cv_sys_stat_statfs2_frsize=no])]) | ||
129 | AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_frsize]) | ||
130 | if test $fu_cv_sys_stat_statfs2_frsize = yes; then | ||
131 | ac_fsusage_space=yes | ||
132 | AC_DEFINE([STAT_STATFS2_FRSIZE], [1], | ||
133 | [ Define if statfs takes 2 args and struct statfs has a field named f_frsize. | ||
134 | (glibc/Linux > 2.6)]) | ||
135 | fi | ||
136 | |||
74 | if test $ac_fsusage_space = no; then | 137 | if test $ac_fsusage_space = no; then |
75 | # DEC Alpha running OSF/1 | 138 | # DEC Alpha running OSF/1 |
76 | AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)]) | 139 | AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)]) |
@@ -98,8 +161,8 @@ if test $ac_fsusage_space = no; then | |||
98 | fi | 161 | fi |
99 | 162 | ||
100 | if test $ac_fsusage_space = no; then | 163 | if test $ac_fsusage_space = no; then |
101 | # glibc/Linux, MacOS X < 10.4, FreeBSD < 5.0, NetBSD < 3.0, OpenBSD < 4.4. | 164 | # glibc/Linux, Mac OS X, FreeBSD < 5.0, NetBSD < 3.0, OpenBSD < 4.4. |
102 | # (glibc/{Hurd,kFreeBSD}, MacOS X >= 10.4, FreeBSD >= 5.0, NetBSD >= 3.0, | 165 | # (glibc/{Hurd,kFreeBSD}, FreeBSD >= 5.0, NetBSD >= 3.0, |
103 | # OpenBSD >= 4.4, AIX, HP-UX, OSF/1, Cygwin already handled above.) | 166 | # OpenBSD >= 4.4, AIX, HP-UX, OSF/1, Cygwin already handled above.) |
104 | # (On IRIX you need to include <sys/statfs.h>, not only <sys/mount.h> and | 167 | # (On IRIX you need to include <sys/statfs.h>, not only <sys/mount.h> and |
105 | # <sys/vfs.h>.) | 168 | # <sys/vfs.h>.) |