1 #serial 11
3 # From fileutils/configure.in
5 AC_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 ])
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]])
22 AC_DEFUN([jm_FILE_SYSTEM_USAGE],
23 [
25 echo "checking how to get filesystem space usage..."
26 ac_fsusage_space=no
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
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__
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.
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
52 fi
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,
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
77 fi
79 if test $ac_fsusage_space = no; then
80 # AIX
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,
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
110 fi
112 if 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
132 fi
134 if test $ac_fsusage_space = no; then
135 # 4.4BSD and NetBSD
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>
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
162 fi
164 if 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
195 fi
197 if 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)
205 fi
207 AS_IF([test $ac_fsusage_space = yes], [$1], [$2])
209 ])
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],
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)
221 choke -- 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 ])
239 # Prerequisites of lib/fsusage.c not done by jm_FILE_SYSTEM_USAGE.
240 AC_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 ])