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>
38 #include <sys/statvfs.h>],
39 [struct statvfs fsd; statvfs (0, &fsd);],
40 fu_cv_sys_stat_statvfs=yes,
41 fu_cv_sys_stat_statvfs=no)])
42 if test $fu_cv_sys_stat_statvfs = yes; then
44 AC_DEFINE(STAT_STATVFS, 1,
45 [ Define if there is a function named statvfs. (SVR4)])
49 if test $ac_fsusage_space = no; then
50 # DEC Alpha running OSF/1
51 AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
52 AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
54 #include <sys/param.h>
55 #include <sys/types.h>
56 #include <sys/mount.h>
61 exit (statfs (".", &fsd, sizeof (struct statfs)));
63 fu_cv_sys_stat_statfs3_osf1=yes,
64 fu_cv_sys_stat_statfs3_osf1=no,
65 fu_cv_sys_stat_statfs3_osf1=no)])
66 AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
67 if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
69 AC_DEFINE(STAT_STATFS3_OSF1, 1,
70 [ Define if statfs takes 3 args. (DEC Alpha running OSF/1)])
74 if test $ac_fsusage_space = no; then
76 AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
77 member (AIX, 4.3BSD)])
78 AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
80 #ifdef HAVE_SYS_PARAM_H
81 #include <sys/param.h>
83 #ifdef HAVE_SYS_MOUNT_H
84 #include <sys/mount.h>
93 exit (statfs (".", &fsd));
95 fu_cv_sys_stat_statfs2_bsize=yes,
96 fu_cv_sys_stat_statfs2_bsize=no,
97 fu_cv_sys_stat_statfs2_bsize=no)])
98 AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
99 if test $fu_cv_sys_stat_statfs2_bsize = yes; then
101 AC_DEFINE(STAT_STATFS2_BSIZE, 1,
102 [ Define if statfs takes 2 args and struct statfs has a field named f_bsize.
103 (4.3BSD, SunOS 4, HP-UX, AIX PS/2)])
107 if test $ac_fsusage_space = no; then
109 AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
110 AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
111 [AC_TRY_RUN([#include <sys/types.h>
112 #include <sys/statfs.h>
116 exit (statfs (".", &fsd, sizeof fsd, 0));
118 fu_cv_sys_stat_statfs4=yes,
119 fu_cv_sys_stat_statfs4=no,
120 fu_cv_sys_stat_statfs4=no)])
121 AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
122 if test $fu_cv_sys_stat_statfs4 = yes; then
124 AC_DEFINE(STAT_STATFS4, 1,
125 [ Define if statfs takes 4 args. (SVR3, Dynix, Irix, Dolphin)])
129 if test $ac_fsusage_space = no; then
131 AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
132 member (4.4BSD and NetBSD)])
133 AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
134 [AC_TRY_RUN([#include <sys/types.h>
135 #ifdef HAVE_SYS_PARAM_H
136 #include <sys/param.h>
138 #ifdef HAVE_SYS_MOUNT_H
139 #include <sys/mount.h>
145 exit (statfs (".", &fsd));
147 fu_cv_sys_stat_statfs2_fsize=yes,
148 fu_cv_sys_stat_statfs2_fsize=no,
149 fu_cv_sys_stat_statfs2_fsize=no)])
150 AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
151 if test $fu_cv_sys_stat_statfs2_fsize = yes; then
153 AC_DEFINE(STAT_STATFS2_FSIZE, 1,
154 [ Define if statfs takes 2 args and struct statfs has a field named f_fsize.
159 if test $ac_fsusage_space = no; then
161 AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
162 AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
163 [AC_TRY_RUN([#include <sys/types.h>
164 #ifdef HAVE_SYS_PARAM_H
165 #include <sys/param.h>
167 #ifdef HAVE_SYS_MOUNT_H
168 #include <sys/mount.h>
170 #ifdef HAVE_SYS_FS_TYPES_H
171 #include <sys/fs_types.h>
176 /* Ultrix's statfs returns 1 for success,
177 0 for not mounted, -1 for failure. */
178 exit (statfs (".", &fsd) != 1);
180 fu_cv_sys_stat_fs_data=yes,
181 fu_cv_sys_stat_fs_data=no,
182 fu_cv_sys_stat_fs_data=no)])
183 AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
184 if test $fu_cv_sys_stat_fs_data = yes; then
186 AC_DEFINE(STAT_STATFS2_FS_DATA, 1,
187 [ Define if statfs takes 2 args and the second argument has
188 type struct fs_data. (Ultrix)])
192 if test $ac_fsusage_space = no; then
194 AC_TRY_CPP([#include <sys/filsys.h>
196 AC_DEFINE(STAT_READ_FILSYS, 1,
197 [Define if there is no specific function for reading filesystems usage
198 information and you have the <sys/filsys.h> header file. (SVR2)])
199 ac_fsusage_space=yes)
202 AS_IF([test $ac_fsusage_space = yes], [$1], [$2])
207 # Check for SunOS statfs brokenness wrt partitions 2GB and larger.
208 # If <sys/vfs.h> exists and struct statfs has a member named f_spare,
209 # enable the work-around code in fsusage.c.
210 AC_DEFUN([jm_STATFS_TRUNCATES],
212 AC_MSG_CHECKING([for statfs that truncates block counts])
213 AC_CACHE_VAL(fu_cv_sys_truncating_statfs,
214 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
215 #if !defined(sun) && !defined(__sun)
216 choke -- this is a workaround for a Sun-specific problem
218 #include <sys/types.h>
219 #include <sys/vfs.h>]],
220 [[struct statfs t; long c = *(t.f_spare);]])],
221 [fu_cv_sys_truncating_statfs=yes],
222 [fu_cv_sys_truncating_statfs=no])])
223 if test $fu_cv_sys_truncating_statfs = yes; then
224 AC_DEFINE(STATFS_TRUNCATES_BLOCK_COUNTS, 1,
225 [Define if the block counts reported by statfs may be truncated to 2GB
226 and the correct values may be stored in the f_spare array.
227 (SunOS 4.1.2, 4.1.3, and 4.1.3_U1 are reported to have this problem.
228 SunOS 4.1.1 seems not to be affected.)])
230 AC_MSG_RESULT($fu_cv_sys_truncating_statfs)
234 # Prerequisites of lib/fsusage.c not done by jm_FILE_SYSTEM_USAGE.
235 AC_DEFUN([gl_PREREQ_FSUSAGE_EXTRA],
237 AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
238 AC_CHECK_HEADERS_ONCE(fcntl.h)
239 AC_CHECK_HEADERS(dustat.h sys/fs/s5param.h sys/filsys.h sys/statfs.h sys/statvfs.h)