Code

underquoted defines cause warning on FC2
[nagiosplug.git] / lib / fsusage.m4
1 #serial 9
3 # From fileutils/configure.in
5 # Try to determine how a program can obtain filesystem usage information.
6 # If successful, define the appropriate symbol (see fsusage.c) and
7 # execute ACTION-IF-FOUND.  Otherwise, execute ACTION-IF-NOT-FOUND.
8 #
9 # jm_FILE_SYSTEM_USAGE([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
11 AC_DEFUN([jm_FILE_SYSTEM_USAGE],
12 [
14 echo "checking how to get filesystem space usage..."
15 ac_fsusage_space=no
17 # Perform only the link test since it seems there are no variants of the
18 # statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
19 # because that got a false positive on SCO OSR5.  Adding the declaration
20 # of a `struct statvfs' causes this test to fail (as it should) on such
21 # systems.  That system is reported to work fine with STAT_STATFS4 which
22 # is what it gets when this test fails.
23 if test $ac_fsusage_space = no; then
24   # SVR4
25   AC_CACHE_CHECK([for statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
26                  [AC_TRY_LINK([#include <sys/types.h>
27 #ifdef __GLIBC__
28 Do not use statvfs on systems with GNU libc, because that function stats
29 all preceding entries in /proc/mounts, and that makes df hang if even
30 one of the corresponding file systems is hard-mounted, but not available.
31 #endif
32 #include <sys/statvfs.h>],
33                               [struct statvfs fsd; statvfs (0, &fsd);],
34                               fu_cv_sys_stat_statvfs=yes,
35                               fu_cv_sys_stat_statvfs=no)])
36   if test $fu_cv_sys_stat_statvfs = yes; then
37     ac_fsusage_space=yes
38     AC_DEFINE(STAT_STATVFS, 1,
39               [  Define if there is a function named statvfs.  (SVR4)])
40   fi
41 fi
43 if test $ac_fsusage_space = no; then
44   # DEC Alpha running OSF/1
45   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
46   AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
47   [AC_TRY_RUN([
48 #include <sys/param.h>
49 #include <sys/types.h>
50 #include <sys/mount.h>
51   main ()
52   {
53     struct statfs fsd;
54     fsd.f_fsize = 0;
55     exit (statfs (".", &fsd, sizeof (struct statfs)));
56   }],
57   fu_cv_sys_stat_statfs3_osf1=yes,
58   fu_cv_sys_stat_statfs3_osf1=no,
59   fu_cv_sys_stat_statfs3_osf1=no)])
60   AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
61   if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
62     ac_fsusage_space=yes
63     AC_DEFINE(STAT_STATFS3_OSF1, 1,
64               [   Define if  statfs takes 3 args.  (DEC Alpha running OSF/1)])
65   fi
66 fi
68 if test $ac_fsusage_space = no; then
69 # AIX
70   AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
71 member (AIX, 4.3BSD)])
72   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
73   [AC_TRY_RUN([
74 #ifdef HAVE_SYS_PARAM_H
75 #include <sys/param.h>
76 #endif
77 #ifdef HAVE_SYS_MOUNT_H
78 #include <sys/mount.h>
79 #endif
80 #ifdef HAVE_SYS_VFS_H
81 #include <sys/vfs.h>
82 #endif
83   main ()
84   {
85   struct statfs fsd;
86   fsd.f_bsize = 0;
87   exit (statfs (".", &fsd));
88   }],
89   fu_cv_sys_stat_statfs2_bsize=yes,
90   fu_cv_sys_stat_statfs2_bsize=no,
91   fu_cv_sys_stat_statfs2_bsize=no)])
92   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
93   if test $fu_cv_sys_stat_statfs2_bsize = yes; then
94     ac_fsusage_space=yes
95     AC_DEFINE(STAT_STATFS2_BSIZE, 1,
96 [  Define if statfs takes 2 args and struct statfs has a field named f_bsize.
97    (4.3BSD, SunOS 4, HP-UX, AIX PS/2)])
98   fi
99 fi
101 if test $ac_fsusage_space = no; then
102 # SVR3
103   AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
104   AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
105   [AC_TRY_RUN([#include <sys/types.h>
106 #include <sys/statfs.h>
107   main ()
108   {
109   struct statfs fsd;
110   exit (statfs (".", &fsd, sizeof fsd, 0));
111   }],
112     fu_cv_sys_stat_statfs4=yes,
113     fu_cv_sys_stat_statfs4=no,
114     fu_cv_sys_stat_statfs4=no)])
115   AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
116   if test $fu_cv_sys_stat_statfs4 = yes; then
117     ac_fsusage_space=yes
118     AC_DEFINE(STAT_STATFS4, 1,
119               [  Define if statfs takes 4 args.  (SVR3, Dynix, Irix, Dolphin)])
120   fi
121 fi
123 if test $ac_fsusage_space = no; then
124 # 4.4BSD and NetBSD
125   AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
126 member (4.4BSD and NetBSD)])
127   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
128   [AC_TRY_RUN([#include <sys/types.h>
129 #ifdef HAVE_SYS_PARAM_H
130 #include <sys/param.h>
131 #endif
132 #ifdef HAVE_SYS_MOUNT_H
133 #include <sys/mount.h>
134 #endif
135   main ()
136   {
137   struct statfs fsd;
138   fsd.f_fsize = 0;
139   exit (statfs (".", &fsd));
140   }],
141   fu_cv_sys_stat_statfs2_fsize=yes,
142   fu_cv_sys_stat_statfs2_fsize=no,
143   fu_cv_sys_stat_statfs2_fsize=no)])
144   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
145   if test $fu_cv_sys_stat_statfs2_fsize = yes; then
146     ac_fsusage_space=yes
147     AC_DEFINE(STAT_STATFS2_FSIZE, 1,
148 [  Define if statfs takes 2 args and struct statfs has a field named f_fsize.
149    (4.4BSD, NetBSD)])
150   fi
151 fi
153 if test $ac_fsusage_space = no; then
154   # Ultrix
155   AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
156   AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
157   [AC_TRY_RUN([#include <sys/types.h>
158 #ifdef HAVE_SYS_PARAM_H
159 #include <sys/param.h>
160 #endif
161 #ifdef HAVE_SYS_MOUNT_H
162 #include <sys/mount.h>
163 #endif
164 #ifdef HAVE_SYS_FS_TYPES_H
165 #include <sys/fs_types.h>
166 #endif
167   main ()
168   {
169   struct fs_data fsd;
170   /* Ultrix's statfs returns 1 for success,
171      0 for not mounted, -1 for failure.  */
172   exit (statfs (".", &fsd) != 1);
173   }],
174   fu_cv_sys_stat_fs_data=yes,
175   fu_cv_sys_stat_fs_data=no,
176   fu_cv_sys_stat_fs_data=no)])
177   AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
178   if test $fu_cv_sys_stat_fs_data = yes; then
179     ac_fsusage_space=yes
180     AC_DEFINE(STAT_STATFS2_FS_DATA, 1,
181 [  Define if statfs takes 2 args and the second argument has
182    type struct fs_data.  (Ultrix)])
183   fi
184 fi
186 if test $ac_fsusage_space = no; then
187   # SVR2
188   AC_TRY_CPP([#include <sys/filsys.h>
189     ],
190     AC_DEFINE(STAT_READ_FILSYS, 1,
191       [Define if there is no specific function for reading filesystems usage
192        information and you have the <sys/filsys.h> header file.  (SVR2)])
193     ac_fsusage_space=yes)
194 fi
196 dnl AS_IF([test $ac_fsusage_space = yes], [$1], [$2])
197 if test $ac_fsusage_space = yes ; then [$1] ; else [$2] ; fi
199 ])