diff options
Diffstat (limited to 'lib/fsusage.m4')
-rw-r--r-- | lib/fsusage.m4 | 194 |
1 files changed, 194 insertions, 0 deletions
diff --git a/lib/fsusage.m4 b/lib/fsusage.m4 new file mode 100644 index 0000000..d5c646f --- /dev/null +++ b/lib/fsusage.m4 | |||
@@ -0,0 +1,194 @@ | |||
1 | #serial 7 | ||
2 | |||
3 | # From fileutils/configure.in | ||
4 | |||
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. | ||
8 | # | ||
9 | # jm_FILE_SYSTEM_USAGE([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) | ||
10 | |||
11 | AC_DEFUN(jm_FILE_SYSTEM_USAGE, | ||
12 | [ | ||
13 | |||
14 | echo "checking how to get filesystem space usage..." | ||
15 | ac_fsusage_space=no | ||
16 | |||
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 | ||
24 | # SVR4 | ||
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 | ||
32 | ac_fsusage_space=yes | ||
33 | AC_DEFINE_UNQUOTED(STAT_STATVFS, 1, | ||
34 | [ Define if there is a function named statvfs. (SVR4)]) | ||
35 | fi | ||
36 | fi | ||
37 | |||
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, | ||
42 | [AC_TRY_RUN([ | ||
43 | #include <sys/param.h> | ||
44 | #include <sys/types.h> | ||
45 | #include <sys/mount.h> | ||
46 | main () | ||
47 | { | ||
48 | struct statfs fsd; | ||
49 | fsd.f_fsize = 0; | ||
50 | exit (statfs (".", &fsd, sizeof (struct statfs))); | ||
51 | }], | ||
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 | ||
57 | ac_fsusage_space=yes | ||
58 | AC_DEFINE_UNQUOTED(STAT_STATFS3_OSF1, 1, | ||
59 | [ Define if statfs takes 3 args. (DEC Alpha running OSF/1)]) | ||
60 | fi | ||
61 | fi | ||
62 | |||
63 | if test $ac_fsusage_space = no; then | ||
64 | # AIX | ||
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, | ||
68 | [AC_TRY_RUN([ | ||
69 | #ifdef HAVE_SYS_PARAM_H | ||
70 | #include <sys/param.h> | ||
71 | #endif | ||
72 | #ifdef HAVE_SYS_MOUNT_H | ||
73 | #include <sys/mount.h> | ||
74 | #endif | ||
75 | #ifdef HAVE_SYS_VFS_H | ||
76 | #include <sys/vfs.h> | ||
77 | #endif | ||
78 | main () | ||
79 | { | ||
80 | struct statfs fsd; | ||
81 | fsd.f_bsize = 0; | ||
82 | exit (statfs (".", &fsd)); | ||
83 | }], | ||
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 | ||
89 | ac_fsusage_space=yes | ||
90 | AC_DEFINE_UNQUOTED(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)]) | ||
93 | fi | ||
94 | fi | ||
95 | |||
96 | if test $ac_fsusage_space = no; then | ||
97 | # SVR3 | ||
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> | ||
102 | main () | ||
103 | { | ||
104 | struct statfs fsd; | ||
105 | exit (statfs (".", &fsd, sizeof fsd, 0)); | ||
106 | }], | ||
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 | ||
112 | ac_fsusage_space=yes | ||
113 | AC_DEFINE_UNQUOTED(STAT_STATFS4, 1, | ||
114 | [ Define if statfs takes 4 args. (SVR3, Dynix, Irix, Dolphin)]) | ||
115 | fi | ||
116 | fi | ||
117 | |||
118 | if test $ac_fsusage_space = no; then | ||
119 | # 4.4BSD and NetBSD | ||
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> | ||
126 | #endif | ||
127 | #ifdef HAVE_SYS_MOUNT_H | ||
128 | #include <sys/mount.h> | ||
129 | #endif | ||
130 | main () | ||
131 | { | ||
132 | struct statfs fsd; | ||
133 | fsd.f_fsize = 0; | ||
134 | exit (statfs (".", &fsd)); | ||
135 | }], | ||
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 | ||
141 | ac_fsusage_space=yes | ||
142 | AC_DEFINE_UNQUOTED(STAT_STATFS2_FSIZE, 1, | ||
143 | [ Define if statfs takes 2 args and struct statfs has a field named f_fsize. | ||
144 | (4.4BSD, NetBSD)]) | ||
145 | fi | ||
146 | fi | ||
147 | |||
148 | if test $ac_fsusage_space = no; then | ||
149 | # Ultrix | ||
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> | ||
155 | #endif | ||
156 | #ifdef HAVE_SYS_MOUNT_H | ||
157 | #include <sys/mount.h> | ||
158 | #endif | ||
159 | #ifdef HAVE_SYS_FS_TYPES_H | ||
160 | #include <sys/fs_types.h> | ||
161 | #endif | ||
162 | main () | ||
163 | { | ||
164 | struct fs_data fsd; | ||
165 | /* Ultrix's statfs returns 1 for success, | ||
166 | 0 for not mounted, -1 for failure. */ | ||
167 | exit (statfs (".", &fsd) != 1); | ||
168 | }], | ||
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 | ||
174 | ac_fsusage_space=yes | ||
175 | AC_DEFINE_UNQUOTED(STAT_STATFS2_FS_DATA, 1, | ||
176 | [ Define if statfs takes 2 args and the second argument has | ||
177 | type struct fs_data. (Ultrix)]) | ||
178 | fi | ||
179 | fi | ||
180 | |||
181 | if test $ac_fsusage_space = no; then | ||
182 | # SVR2 | ||
183 | AC_TRY_CPP([#include <sys/filsys.h> | ||
184 | ], | ||
185 | AC_DEFINE_UNQUOTED(STAT_READ_FILSYS, 1, | ||
186 | [Define if there is no specific function for reading filesystems usage | ||
187 | information and you have the <sys/filsys.h> header file. (SVR2)]) | ||
188 | ac_fsusage_space=yes) | ||
189 | fi | ||
190 | |||
191 | dnl AS_IF([test $ac_fsusage_space = yes], [$1], [$2]) | ||
192 | if test $ac_fsusage_space = yes ; then [$1] ; else [$2] ; fi | ||
193 | |||
194 | ]) | ||