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.
9 # jm_FILE_SYSTEM_USAGE([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
11 AC_DEFUN([jm_FILE_SYSTEM_USAGE],
14 echo "checking how to get filesystem space usage..."
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
25 AC_CACHE_CHECK([for statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
26 [AC_TRY_LINK([#include <sys/types.h>
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.
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
38 AC_DEFINE(STAT_STATVFS, 1,
39 [ Define if there is a function named statvfs. (SVR4)])
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,
48 #include <sys/param.h>
49 #include <sys/types.h>
50 #include <sys/mount.h>
55 exit (statfs (".", &fsd, sizeof (struct statfs)));
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
63 AC_DEFINE(STAT_STATFS3_OSF1, 1,
64 [ Define if statfs takes 3 args. (DEC Alpha running OSF/1)])
68 if test $ac_fsusage_space = no; then
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,
74 #ifdef HAVE_SYS_PARAM_H
75 #include <sys/param.h>
77 #ifdef HAVE_SYS_MOUNT_H
78 #include <sys/mount.h>
87 exit (statfs (".", &fsd));
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
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)])
101 if test $ac_fsusage_space = no; then
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>
110 exit (statfs (".", &fsd, sizeof fsd, 0));
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
118 AC_DEFINE(STAT_STATFS4, 1,
119 [ Define if statfs takes 4 args. (SVR3, Dynix, Irix, Dolphin)])
123 if test $ac_fsusage_space = no; then
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>
132 #ifdef HAVE_SYS_MOUNT_H
133 #include <sys/mount.h>
139 exit (statfs (".", &fsd));
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
147 AC_DEFINE(STAT_STATFS2_FSIZE, 1,
148 [ Define if statfs takes 2 args and struct statfs has a field named f_fsize.
153 if test $ac_fsusage_space = no; then
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>
161 #ifdef HAVE_SYS_MOUNT_H
162 #include <sys/mount.h>
164 #ifdef HAVE_SYS_FS_TYPES_H
165 #include <sys/fs_types.h>
170 /* Ultrix's statfs returns 1 for success,
171 0 for not mounted, -1 for failure. */
172 exit (statfs (".", &fsd) != 1);
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
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)])
186 if test $ac_fsusage_space = no; then
188 AC_TRY_CPP([#include <sys/filsys.h>
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)
196 AS_IF([test $ac_fsusage_space = yes], [$1], [$2])