summaryrefslogtreecommitdiffstats
path: root/m4/fsusage.m4
diff options
context:
space:
mode:
authorTon Voon <tonvoon@users.sourceforge.net>2004-12-15 20:51:47 (GMT)
committerTon Voon <tonvoon@users.sourceforge.net>2004-12-15 20:51:47 (GMT)
commit6fff4bcdcf97412a6d1422991ea9fe5e8a203e75 (patch)
tree6494851815282f4b27829a7f10b8ca522aa7668e /m4/fsusage.m4
parent82d1989d3245791c9fac22ca848f5497f261c10b (diff)
downloadmonitoring-plugins-6fff4bcdcf97412a6d1422991ea9fe5e8a203e75.tar.gz
Moving m4 files from lib/
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1028 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'm4/fsusage.m4')
-rw-r--r--m4/fsusage.m4246
1 files changed, 246 insertions, 0 deletions
diff --git a/m4/fsusage.m4 b/m4/fsusage.m4
new file mode 100644
index 0000000..a0ab1e1
--- /dev/null
+++ b/m4/fsusage.m4
@@ -0,0 +1,246 @@
1#serial 11
2
3# From fileutils/configure.in
4
5AC_DEFUN([gl_FSUSAGE],
6[
7 AC_CHECK_HEADERS_ONCE(sys/param.h)
8 AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs_types.h)
9 jm_FILE_SYSTEM_USAGE([gl_cv_fs_space=yes], [gl_cv_fs_space=no])
10 if test $gl_cv_fs_space = yes; then
11 AC_LIBOBJ(fsusage)
12 gl_PREREQ_FSUSAGE_EXTRA
13 fi
14])
15
16# Try to determine how a program can obtain filesystem usage information.
17# If successful, define the appropriate symbol (see fsusage.c) and
18# execute ACTION-IF-FOUND. Otherwise, execute ACTION-IF-NOT-FOUND.
19#
20# jm_FILE_SYSTEM_USAGE([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
21
22AC_DEFUN([jm_FILE_SYSTEM_USAGE],
23[
24
25echo "checking how to get filesystem space usage..."
26ac_fsusage_space=no
27
28# Perform only the link test since it seems there are no variants of the
29# statvfs function. This check is more than just AC_CHECK_FUNCS(statvfs)
30# because that got a false positive on SCO OSR5. Adding the declaration
31# of a `struct statvfs' causes this test to fail (as it should) on such
32# systems. That system is reported to work fine with STAT_STATFS4 which
33# is what it gets when this test fails.
34if test $ac_fsusage_space = no; then
35 # SVR4
36 AC_CACHE_CHECK([for statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
37 [AC_TRY_LINK([#include <sys/types.h>
38#ifdef __GLIBC__
39Do not use statvfs on systems with GNU libc, because that function stats
40all preceding entries in /proc/mounts, and that makes df hang if even
41one of the corresponding file systems is hard-mounted, but not available.
42#endif
43#include <sys/statvfs.h>],
44 [struct statvfs fsd; statvfs (0, &fsd);],
45 fu_cv_sys_stat_statvfs=yes,
46 fu_cv_sys_stat_statvfs=no)])
47 if test $fu_cv_sys_stat_statvfs = yes; then
48 ac_fsusage_space=yes
49 AC_DEFINE(STAT_STATVFS, 1,
50 [ Define if there is a function named statvfs. (SVR4)])
51 fi
52fi
53
54if test $ac_fsusage_space = no; then
55 # DEC Alpha running OSF/1
56 AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
57 AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
58 [AC_TRY_RUN([
59#include <sys/param.h>
60#include <sys/types.h>
61#include <sys/mount.h>
62 main ()
63 {
64 struct statfs fsd;
65 fsd.f_fsize = 0;
66 exit (statfs (".", &fsd, sizeof (struct statfs)));
67 }],
68 fu_cv_sys_stat_statfs3_osf1=yes,
69 fu_cv_sys_stat_statfs3_osf1=no,
70 fu_cv_sys_stat_statfs3_osf1=no)])
71 AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
72 if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
73 ac_fsusage_space=yes
74 AC_DEFINE(STAT_STATFS3_OSF1, 1,
75 [ Define if statfs takes 3 args. (DEC Alpha running OSF/1)])
76 fi
77fi
78
79if test $ac_fsusage_space = no; then
80# AIX
81 AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
82member (AIX, 4.3BSD)])
83 AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
84 [AC_TRY_RUN([
85#ifdef HAVE_SYS_PARAM_H
86#include <sys/param.h>
87#endif
88#ifdef HAVE_SYS_MOUNT_H
89#include <sys/mount.h>
90#endif
91#ifdef HAVE_SYS_VFS_H
92#include <sys/vfs.h>
93#endif
94 main ()
95 {
96 struct statfs fsd;
97 fsd.f_bsize = 0;
98 exit (statfs (".", &fsd));
99 }],
100 fu_cv_sys_stat_statfs2_bsize=yes,
101 fu_cv_sys_stat_statfs2_bsize=no,
102 fu_cv_sys_stat_statfs2_bsize=no)])
103 AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
104 if test $fu_cv_sys_stat_statfs2_bsize = yes; then
105 ac_fsusage_space=yes
106 AC_DEFINE(STAT_STATFS2_BSIZE, 1,
107[ Define if statfs takes 2 args and struct statfs has a field named f_bsize.
108 (4.3BSD, SunOS 4, HP-UX, AIX PS/2)])
109 fi
110fi
111
112if test $ac_fsusage_space = no; then
113# SVR3
114 AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
115 AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
116 [AC_TRY_RUN([#include <sys/types.h>
117#include <sys/statfs.h>
118 main ()
119 {
120 struct statfs fsd;
121 exit (statfs (".", &fsd, sizeof fsd, 0));
122 }],
123 fu_cv_sys_stat_statfs4=yes,
124 fu_cv_sys_stat_statfs4=no,
125 fu_cv_sys_stat_statfs4=no)])
126 AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
127 if test $fu_cv_sys_stat_statfs4 = yes; then
128 ac_fsusage_space=yes
129 AC_DEFINE(STAT_STATFS4, 1,
130 [ Define if statfs takes 4 args. (SVR3, Dynix, Irix, Dolphin)])
131 fi
132fi
133
134if test $ac_fsusage_space = no; then
135# 4.4BSD and NetBSD
136 AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
137member (4.4BSD and NetBSD)])
138 AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
139 [AC_TRY_RUN([#include <sys/types.h>
140#ifdef HAVE_SYS_PARAM_H
141#include <sys/param.h>
142#endif
143#ifdef HAVE_SYS_MOUNT_H
144#include <sys/mount.h>
145#endif
146 main ()
147 {
148 struct statfs fsd;
149 fsd.f_fsize = 0;
150 exit (statfs (".", &fsd));
151 }],
152 fu_cv_sys_stat_statfs2_fsize=yes,
153 fu_cv_sys_stat_statfs2_fsize=no,
154 fu_cv_sys_stat_statfs2_fsize=no)])
155 AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
156 if test $fu_cv_sys_stat_statfs2_fsize = yes; then
157 ac_fsusage_space=yes
158 AC_DEFINE(STAT_STATFS2_FSIZE, 1,
159[ Define if statfs takes 2 args and struct statfs has a field named f_fsize.
160 (4.4BSD, NetBSD)])
161 fi
162fi
163
164if test $ac_fsusage_space = no; then
165 # Ultrix
166 AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
167 AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
168 [AC_TRY_RUN([#include <sys/types.h>
169#ifdef HAVE_SYS_PARAM_H
170#include <sys/param.h>
171#endif
172#ifdef HAVE_SYS_MOUNT_H
173#include <sys/mount.h>
174#endif
175#ifdef HAVE_SYS_FS_TYPES_H
176#include <sys/fs_types.h>
177#endif
178 main ()
179 {
180 struct fs_data fsd;
181 /* Ultrix's statfs returns 1 for success,
182 0 for not mounted, -1 for failure. */
183 exit (statfs (".", &fsd) != 1);
184 }],
185 fu_cv_sys_stat_fs_data=yes,
186 fu_cv_sys_stat_fs_data=no,
187 fu_cv_sys_stat_fs_data=no)])
188 AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
189 if test $fu_cv_sys_stat_fs_data = yes; then
190 ac_fsusage_space=yes
191 AC_DEFINE(STAT_STATFS2_FS_DATA, 1,
192[ Define if statfs takes 2 args and the second argument has
193 type struct fs_data. (Ultrix)])
194 fi
195fi
196
197if test $ac_fsusage_space = no; then
198 # SVR2
199 AC_TRY_CPP([#include <sys/filsys.h>
200 ],
201 AC_DEFINE(STAT_READ_FILSYS, 1,
202 [Define if there is no specific function for reading filesystems usage
203 information and you have the <sys/filsys.h> header file. (SVR2)])
204 ac_fsusage_space=yes)
205fi
206
207AS_IF([test $ac_fsusage_space = yes], [$1], [$2])
208
209])
210
211
212# Check for SunOS statfs brokenness wrt partitions 2GB and larger.
213# If <sys/vfs.h> exists and struct statfs has a member named f_spare,
214# enable the work-around code in fsusage.c.
215AC_DEFUN([jm_STATFS_TRUNCATES],
216[
217 AC_MSG_CHECKING([for statfs that truncates block counts])
218 AC_CACHE_VAL(fu_cv_sys_truncating_statfs,
219 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
220#if !defined(sun) && !defined(__sun)
221choke -- this is a workaround for a Sun-specific problem
222#endif
223#include <sys/types.h>
224#include <sys/vfs.h>]],
225 [[struct statfs t; long c = *(t.f_spare);]])],
226 [fu_cv_sys_truncating_statfs=yes],
227 [fu_cv_sys_truncating_statfs=no])])
228 if test $fu_cv_sys_truncating_statfs = yes; then
229 AC_DEFINE(STATFS_TRUNCATES_BLOCK_COUNTS, 1,
230 [Define if the block counts reported by statfs may be truncated to 2GB
231 and the correct values may be stored in the f_spare array.
232 (SunOS 4.1.2, 4.1.3, and 4.1.3_U1 are reported to have this problem.
233 SunOS 4.1.1 seems not to be affected.)])
234 fi
235 AC_MSG_RESULT($fu_cv_sys_truncating_statfs)
236])
237
238
239# Prerequisites of lib/fsusage.c not done by jm_FILE_SYSTEM_USAGE.
240AC_DEFUN([gl_PREREQ_FSUSAGE_EXTRA],
241[
242 AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
243 AC_CHECK_HEADERS_ONCE(fcntl.h)
244 AC_CHECK_HEADERS(dustat.h sys/fs/s5param.h sys/filsys.h sys/statfs.h sys/statvfs.h)
245 jm_STATFS_TRUNCATES
246])