Add some minor fixes concerning spelling issues
[midnight-commander.git] / m4 / fsusage.m4
bloba8df1d500b47e3ae81f106499860eddfa2cdce05
1 #serial 23
2 # Obtaining file system usage information.
4 # Copyright (C) 1997, 1998, 2000, 2001, 2003-2007 Free Software Foundation, Inc.
6 # This file is free software; the Free Software Foundation
7 # gives unlimited permission to copy and/or distribute it,
8 # with or without modifications, as long as this notice is preserved.
10 # Written by Jim Meyering.
12 AC_DEFUN([gl_FSUSAGE],
14   AC_LIBSOURCES([fsusage.c, fsusage.h])
16   AC_CHECK_HEADERS_ONCE(sys/param.h)
17   AC_CHECK_HEADERS_ONCE(sys/vfs.h sys/fs_types.h)
18   AC_CHECK_HEADERS(sys/mount.h, [], [],
19     [AC_INCLUDES_DEFAULT
20      [#if HAVE_SYS_PARAM_H
21        #include <sys/param.h>
22       #endif]])
23   gl_FILE_SYSTEM_USAGE([gl_cv_fs_space=yes], [gl_cv_fs_space=no])
24   if test $gl_cv_fs_space = yes; then
25     AC_LIBOBJ(fsusage)
26     gl_PREREQ_FSUSAGE_EXTRA
27   fi
30 # Try to determine how a program can obtain file system usage information.
31 # If successful, define the appropriate symbol (see fsusage.c) and
32 # execute ACTION-IF-FOUND.  Otherwise, execute ACTION-IF-NOT-FOUND.
34 # gl_FILE_SYSTEM_USAGE([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
36 AC_DEFUN([gl_FILE_SYSTEM_USAGE],
39 AC_MSG_NOTICE([checking how to get file system space usage])
40 ac_fsusage_space=no
42 # Perform only the link test since it seems there are no variants of the
43 # statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
44 # because that got a false positive on SCO OSR5.  Adding the declaration
45 # of a `struct statvfs' causes this test to fail (as it should) on such
46 # systems.  That system is reported to work fine with STAT_STATFS4 which
47 # is what it gets when this test fails.
48 if test $ac_fsusage_space = no; then
49   # SVR4
50   AC_CACHE_CHECK([for statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
51                  [AC_TRY_LINK([#include <sys/types.h>
52 #if defined __GLIBC__ && !defined __BEOS__
53 Do not use statvfs on systems with GNU libc, because that function stats
54 all preceding entries in /proc/mounts, and that makes df hang if even
55 one of the corresponding file systems is hard-mounted, but not available.
56 statvfs in GNU libc on BeOS operates differently: it only makes a system
57 call.
58 #endif
60 #ifdef __osf__
61 "Do not use Tru64's statvfs implementation"
62 #endif
64 #include <sys/statvfs.h>],
65                               [struct statvfs fsd; statvfs (0, &fsd);],
66                               fu_cv_sys_stat_statvfs=yes,
67                               fu_cv_sys_stat_statvfs=no)])
68   if test $fu_cv_sys_stat_statvfs = yes; then
69     ac_fsusage_space=yes
70     AC_DEFINE(STAT_STATVFS, 1,
71               [  Define if there is a function named statvfs.  (SVR4)])
72   fi
75 if test $ac_fsusage_space = no; then
76   # DEC Alpha running OSF/1
77   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
78   AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
79   [AC_TRY_RUN([
80 #include <sys/param.h>
81 #include <sys/types.h>
82 #include <sys/mount.h>
83   int
84   main ()
85   {
86     struct statfs fsd;
87     fsd.f_fsize = 0;
88     return statfs (".", &fsd, sizeof (struct statfs)) != 0;
89   }],
90   fu_cv_sys_stat_statfs3_osf1=yes,
91   fu_cv_sys_stat_statfs3_osf1=no,
92   fu_cv_sys_stat_statfs3_osf1=no)])
93   AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
94   if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
95     ac_fsusage_space=yes
96     AC_DEFINE(STAT_STATFS3_OSF1, 1,
97               [   Define if  statfs takes 3 args.  (DEC Alpha running OSF/1)])
98   fi
101 if test $ac_fsusage_space = no; then
102 # AIX
103   AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
104 member (AIX, 4.3BSD)])
105   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
106   [AC_TRY_RUN([
107 #ifdef HAVE_SYS_PARAM_H
108 #include <sys/param.h>
109 #endif
110 #ifdef HAVE_SYS_MOUNT_H
111 #include <sys/mount.h>
112 #endif
113 #ifdef HAVE_SYS_VFS_H
114 #include <sys/vfs.h>
115 #endif
116   int
117   main ()
118   {
119   struct statfs fsd;
120   fsd.f_bsize = 0;
121   return statfs (".", &fsd) != 0;
122   }],
123   fu_cv_sys_stat_statfs2_bsize=yes,
124   fu_cv_sys_stat_statfs2_bsize=no,
125   fu_cv_sys_stat_statfs2_bsize=no)])
126   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
127   if test $fu_cv_sys_stat_statfs2_bsize = yes; then
128     ac_fsusage_space=yes
129     AC_DEFINE(STAT_STATFS2_BSIZE, 1,
130 [  Define if statfs takes 2 args and struct statfs has a field named f_bsize.
131    (4.3BSD, SunOS 4, HP-UX, AIX PS/2)])
132   fi
135 if test $ac_fsusage_space = no; then
136 # SVR3
137   AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
138   AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
139   [AC_TRY_RUN([#include <sys/types.h>
140 #include <sys/statfs.h>
141   int
142   main ()
143   {
144   struct statfs fsd;
145   return statfs (".", &fsd, sizeof fsd, 0) != 0;
146   }],
147     fu_cv_sys_stat_statfs4=yes,
148     fu_cv_sys_stat_statfs4=no,
149     fu_cv_sys_stat_statfs4=no)])
150   AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
151   if test $fu_cv_sys_stat_statfs4 = yes; then
152     ac_fsusage_space=yes
153     AC_DEFINE(STAT_STATFS4, 1,
154               [  Define if statfs takes 4 args.  (SVR3, Dynix, Irix, Dolphin)])
155   fi
158 if test $ac_fsusage_space = no; then
159 # 4.4BSD and NetBSD
160   AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
161 member (4.4BSD and NetBSD)])
162   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
163   [AC_TRY_RUN([#include <sys/types.h>
164 #ifdef HAVE_SYS_PARAM_H
165 #include <sys/param.h>
166 #endif
167 #ifdef HAVE_SYS_MOUNT_H
168 #include <sys/mount.h>
169 #endif
170   int
171   main ()
172   {
173   struct statfs fsd;
174   fsd.f_fsize = 0;
175   return statfs (".", &fsd) != 0;
176   }],
177   fu_cv_sys_stat_statfs2_fsize=yes,
178   fu_cv_sys_stat_statfs2_fsize=no,
179   fu_cv_sys_stat_statfs2_fsize=no)])
180   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
181   if test $fu_cv_sys_stat_statfs2_fsize = yes; then
182     ac_fsusage_space=yes
183     AC_DEFINE(STAT_STATFS2_FSIZE, 1,
184 [  Define if statfs takes 2 args and struct statfs has a field named f_fsize.
185    (4.4BSD, NetBSD)])
186   fi
189 if test $ac_fsusage_space = no; then
190   # Ultrix
191   AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
192   AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
193   [AC_TRY_RUN([#include <sys/types.h>
194 #ifdef HAVE_SYS_PARAM_H
195 #include <sys/param.h>
196 #endif
197 #ifdef HAVE_SYS_MOUNT_H
198 #include <sys/mount.h>
199 #endif
200 #ifdef HAVE_SYS_FS_TYPES_H
201 #include <sys/fs_types.h>
202 #endif
203   int
204   main ()
205   {
206   struct fs_data fsd;
207   /* Ultrix's statfs returns 1 for success,
208      0 for not mounted, -1 for failure.  */
209   return statfs (".", &fsd) != 1;
210   }],
211   fu_cv_sys_stat_fs_data=yes,
212   fu_cv_sys_stat_fs_data=no,
213   fu_cv_sys_stat_fs_data=no)])
214   AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
215   if test $fu_cv_sys_stat_fs_data = yes; then
216     ac_fsusage_space=yes
217     AC_DEFINE(STAT_STATFS2_FS_DATA, 1,
218 [  Define if statfs takes 2 args and the second argument has
219    type struct fs_data.  (Ultrix)])
220   fi
223 if test $ac_fsusage_space = no; then
224   # SVR2
225   AC_TRY_CPP([#include <sys/filsys.h>
226     ],
227     AC_DEFINE(STAT_READ_FILSYS, 1,
228       [Define if there is no specific function for reading file systems usage
229        information and you have the <sys/filsys.h> header file.  (SVR2)])
230     ac_fsusage_space=yes)
233 AS_IF([test $ac_fsusage_space = yes], [$1], [$2])
238 # Check for SunOS statfs brokenness wrt partitions 2GB and larger.
239 # If <sys/vfs.h> exists and struct statfs has a member named f_spare,
240 # enable the work-around code in fsusage.c.
241 AC_DEFUN([gl_STATFS_TRUNCATES],
243   AC_MSG_CHECKING([for statfs that truncates block counts])
244   AC_CACHE_VAL(fu_cv_sys_truncating_statfs,
245   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
246 #if !defined(sun) && !defined(__sun)
247 choke -- this is a workaround for a Sun-specific problem
248 #endif
249 #include <sys/types.h>
250 #include <sys/vfs.h>]],
251     [[struct statfs t; long c = *(t.f_spare);
252       if (c) return 0;]])],
253     [fu_cv_sys_truncating_statfs=yes],
254     [fu_cv_sys_truncating_statfs=no])])
255   if test $fu_cv_sys_truncating_statfs = yes; then
256     AC_DEFINE(STATFS_TRUNCATES_BLOCK_COUNTS, 1,
257       [Define if the block counts reported by statfs may be truncated to 2GB
258        and the correct values may be stored in the f_spare array.
259        (SunOS 4.1.2, 4.1.3, and 4.1.3_U1 are reported to have this problem.
260        SunOS 4.1.1 seems not to be affected.)])
261   fi
262   AC_MSG_RESULT($fu_cv_sys_truncating_statfs)
266 # Prerequisites of lib/fsusage.c not done by gl_FILE_SYSTEM_USAGE.
267 AC_DEFUN([gl_PREREQ_FSUSAGE_EXTRA],
269   AC_REQUIRE([gl_AC_TYPE_UINTMAX_T])
270   AC_CHECK_HEADERS(dustat.h sys/fs/s5param.h sys/filsys.h sys/statfs.h)
271   gl_STATFS_TRUNCATES