3 # From fileutils/configure.in
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
12 gl_PREREQ_FSUSAGE_EXTRA
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.
20 # jm_FILE_SYSTEM_USAGE([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
22 AC_DEFUN([jm_FILE_SYSTEM_USAGE],
25 echo "checking how to get filesystem space usage..."
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.
34 if test $ac_fsusage_space = no; then
36 AC_CACHE_CHECK([for statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
37 [AC_TRY_LINK([#include <sys/types.h>
39 Do not use statvfs on systems with GNU libc, because that function stats
40 all preceding entries in /proc/mounts, and that makes df hang if even
41 one of the corresponding file systems is hard-mounted, but not available.
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
49 AC_DEFINE(STAT_STATVFS, 1,
50 [ Define if there is a function named statvfs. (SVR4)])
54 if 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,
59 #include <sys/param.h>
60 #include <sys/types.h>
61 #include <sys/mount.h>
66 exit (statfs (".", &fsd, sizeof (struct statfs)));
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
74 AC_DEFINE(STAT_STATFS3_OSF1, 1,
75 [ Define if statfs takes 3 args. (DEC Alpha running OSF/1)])
79 if test $ac_fsusage_space = no; then
81 AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
82 member (AIX, 4.3BSD)])
83 AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
85 #ifdef HAVE_SYS_PARAM_H
86 #include <sys/param.h>
88 #ifdef HAVE_SYS_MOUNT_H
89 #include <sys/mount.h>
98 exit (statfs (".", &fsd));
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
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)])
112 if test $ac_fsusage_space = no; then
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>
121 exit (statfs (".", &fsd, sizeof fsd, 0));
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
129 AC_DEFINE(STAT_STATFS4, 1,
130 [ Define if statfs takes 4 args. (SVR3, Dynix, Irix, Dolphin)])
134 if test $ac_fsusage_space = no; then
136 AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
137 member (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>
143 #ifdef HAVE_SYS_MOUNT_H
144 #include <sys/mount.h>
150 exit (statfs (".", &fsd));
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
158 AC_DEFINE(STAT_STATFS2_FSIZE, 1,
159 [ Define if statfs takes 2 args and struct statfs has a field named f_fsize.
164 if test $ac_fsusage_space = no; then
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>
172 #ifdef HAVE_SYS_MOUNT_H
173 #include <sys/mount.h>
175 #ifdef HAVE_SYS_FS_TYPES_H
176 #include <sys/fs_types.h>
181 /* Ultrix's statfs returns 1 for success,
182 0 for not mounted, -1 for failure. */
183 exit (statfs (".", &fsd) != 1);
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
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)])
197 if test $ac_fsusage_space = no; then
199 AC_TRY_CPP([#include <sys/filsys.h>
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)
207 AS_IF([test $ac_fsusage_space = yes], [$1], [$2])
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.
215 AC_DEFUN([jm_STATFS_TRUNCATES],
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)
221 choke -- this is a workaround for a Sun-specific problem
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.)])
235 AC_MSG_RESULT($fu_cv_sys_truncating_statfs)
239 # Prerequisites of lib/fsusage.c not done by jm_FILE_SYSTEM_USAGE.
240 AC_DEFUN([gl_PREREQ_FSUSAGE_EXTRA],
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)