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>
27 #include <sys/statvfs.h>],
28 [struct statvfs fsd; statvfs (0, &fsd);],
29 fu_cv_sys_stat_statvfs=yes,
30 fu_cv_sys_stat_statvfs=no)])
31 if test $fu_cv_sys_stat_statvfs = yes; then
33 AC_DEFINE(STAT_STATVFS, 1,
34 [ Define if there is a function named statvfs. (SVR4)])
38 if test $ac_fsusage_space = no; then
39 # DEC Alpha running OSF/1
40 AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
41 AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
43 #include <sys/param.h>
44 #include <sys/types.h>
45 #include <sys/mount.h>
50 exit (statfs (".", &fsd, sizeof (struct statfs)));
52 fu_cv_sys_stat_statfs3_osf1=yes,
53 fu_cv_sys_stat_statfs3_osf1=no,
54 fu_cv_sys_stat_statfs3_osf1=no)])
55 AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
56 if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
58 AC_DEFINE(STAT_STATFS3_OSF1, 1,
59 [ Define if statfs takes 3 args. (DEC Alpha running OSF/1)])
63 if test $ac_fsusage_space = no; then
65 AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
66 member (AIX, 4.3BSD)])
67 AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
69 #ifdef HAVE_SYS_PARAM_H
70 #include <sys/param.h>
72 #ifdef HAVE_SYS_MOUNT_H
73 #include <sys/mount.h>
82 exit (statfs (".", &fsd));
84 fu_cv_sys_stat_statfs2_bsize=yes,
85 fu_cv_sys_stat_statfs2_bsize=no,
86 fu_cv_sys_stat_statfs2_bsize=no)])
87 AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
88 if test $fu_cv_sys_stat_statfs2_bsize = yes; then
90 AC_DEFINE(STAT_STATFS2_BSIZE, 1,
91 [ Define if statfs takes 2 args and struct statfs has a field named f_bsize.
92 (4.3BSD, SunOS 4, HP-UX, AIX PS/2)])
96 if test $ac_fsusage_space = no; then
98 AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
99 AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
100 [AC_TRY_RUN([#include <sys/types.h>
101 #include <sys/statfs.h>
105 exit (statfs (".", &fsd, sizeof fsd, 0));
107 fu_cv_sys_stat_statfs4=yes,
108 fu_cv_sys_stat_statfs4=no,
109 fu_cv_sys_stat_statfs4=no)])
110 AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
111 if test $fu_cv_sys_stat_statfs4 = yes; then
113 AC_DEFINE(STAT_STATFS4, 1,
114 [ Define if statfs takes 4 args. (SVR3, Dynix, Irix, Dolphin)])
118 if test $ac_fsusage_space = no; then
120 AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
121 member (4.4BSD and NetBSD)])
122 AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
123 [AC_TRY_RUN([#include <sys/types.h>
124 #ifdef HAVE_SYS_PARAM_H
125 #include <sys/param.h>
127 #ifdef HAVE_SYS_MOUNT_H
128 #include <sys/mount.h>
134 exit (statfs (".", &fsd));
136 fu_cv_sys_stat_statfs2_fsize=yes,
137 fu_cv_sys_stat_statfs2_fsize=no,
138 fu_cv_sys_stat_statfs2_fsize=no)])
139 AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
140 if test $fu_cv_sys_stat_statfs2_fsize = yes; then
142 AC_DEFINE(STAT_STATFS2_FSIZE, 1,
143 [ Define if statfs takes 2 args and struct statfs has a field named f_fsize.
148 if test $ac_fsusage_space = no; then
150 AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
151 AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
152 [AC_TRY_RUN([#include <sys/types.h>
153 #ifdef HAVE_SYS_PARAM_H
154 #include <sys/param.h>
156 #ifdef HAVE_SYS_MOUNT_H
157 #include <sys/mount.h>
159 #ifdef HAVE_SYS_FS_TYPES_H
160 #include <sys/fs_types.h>
165 /* Ultrix's statfs returns 1 for success,
166 0 for not mounted, -1 for failure. */
167 exit (statfs (".", &fsd) != 1);
169 fu_cv_sys_stat_fs_data=yes,
170 fu_cv_sys_stat_fs_data=no,
171 fu_cv_sys_stat_fs_data=no)])
172 AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
173 if test $fu_cv_sys_stat_fs_data = yes; then
175 AC_DEFINE(STAT_STATFS2_FS_DATA, 1,
176 [ Define if statfs takes 2 args and the second argument has
177 type struct fs_data. (Ultrix)])
181 if test $ac_fsusage_space = no; then
183 AC_TRY_CPP([#include <sys/filsys.h>],
184 AC_DEFINE(STAT_READ_FILSYS, 1,
185 [ Define if there is no specific function for reading filesystems usage
186 information and you have the <sys/filsys.h> header file. (SVR2)])
187 ac_fsusage_space=yes)
190 AS_IF([test $ac_fsusage_space = yes], [$1], [$2])dnl