summaryrefslogtreecommitdiffstats
path: root/m4/ls-mntd-fs.m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4/ls-mntd-fs.m4')
-rw-r--r--m4/ls-mntd-fs.m4282
1 files changed, 282 insertions, 0 deletions
diff --git a/m4/ls-mntd-fs.m4 b/m4/ls-mntd-fs.m4
new file mode 100644
index 0000000..c28466b
--- /dev/null
+++ b/m4/ls-mntd-fs.m4
@@ -0,0 +1,282 @@
1#serial 14
2
3dnl From Jim Meyering.
4dnl
5dnl This is not pretty. I've just taken the autoconf code and wrapped
6dnl it in an AC_DEFUN.
7dnl
8
9# jm_LIST_MOUNTED_FILESYSTEMS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
10AC_DEFUN([jm_LIST_MOUNTED_FILESYSTEMS],
11 [
12AC_CHECK_FUNCS(listmntent getmntinfo)
13AC_CHECK_HEADERS_ONCE(sys/param.h)
14
15# We must include grp.h before ucred.h on OSF V4.0, since ucred.h uses
16# NGROUPS (as the array dimension for a struct member) without a definition.
17AC_CHECK_HEADERS(sys/ucred.h, [], [], [#include <grp.h>])
18
19AC_CHECK_HEADERS(mntent.h sys/mount.h sys/fs_types.h)
20 getfsstat_includes="\
21$ac_includes_default
22#if HAVE_SYS_PARAM_H
23# include <sys/param.h> /* needed by powerpc-apple-darwin1.3.7 */
24#endif
25#if HAVE_SYS_UCRED_H
26# include <grp.h> /* needed for definition of NGROUPS */
27# include <sys/ucred.h> /* needed by powerpc-apple-darwin1.3.7 */
28#endif
29#if HAVE_SYS_MOUNT_H
30# include <sys/mount.h>
31#endif
32#if HAVE_SYS_FS_TYPES_H
33# include <sys/fs_types.h> /* needed by powerpc-apple-darwin1.3.7 */
34#endif
35"
36AC_CHECK_MEMBERS([struct fsstat.f_fstypename],,,[$getfsstat_includes])
37
38# Determine how to get the list of mounted filesystems.
39ac_list_mounted_fs=
40
41# If the getmntent function is available but not in the standard library,
42# make sure LIBS contains -lsun (on Irix4) or -lseq (on PTX).
43AC_FUNC_GETMNTENT
44
45# This test must precede the ones for getmntent because Unicos-9 is
46# reported to have the getmntent function, but its support is incompatible
47# with other getmntent implementations.
48
49# NOTE: Normally, I wouldn't use a check for system type as I've done for
50# `CRAY' below since that goes against the whole autoconf philosophy. But
51# I think there is too great a chance that some non-Cray system has a
52# function named listmntent to risk the false positive.
53
54if test -z "$ac_list_mounted_fs"; then
55 # Cray UNICOS 9
56 AC_MSG_CHECKING([for listmntent of Cray/Unicos-9])
57 AC_CACHE_VAL(fu_cv_sys_mounted_cray_listmntent,
58 [fu_cv_sys_mounted_cray_listmntent=no
59 AC_EGREP_CPP(yes,
60 [#ifdef _CRAY
61yes
62#endif
63 ], [test $ac_cv_func_listmntent = yes \
64 && fu_cv_sys_mounted_cray_listmntent=yes]
65 )
66 ]
67 )
68 AC_MSG_RESULT($fu_cv_sys_mounted_cray_listmntent)
69 if test $fu_cv_sys_mounted_cray_listmntent = yes; then
70 ac_list_mounted_fs=found
71 AC_DEFINE(MOUNTED_LISTMNTENT, 1,
72 [Define if there is a function named listmntent that can be used to
73 list all mounted filesystems. (UNICOS)])
74 fi
75fi
76
77if test -z "$ac_list_mounted_fs"; then
78 # AIX.
79 AC_MSG_CHECKING([for mntctl function and struct vmount])
80 AC_CACHE_VAL(fu_cv_sys_mounted_vmount,
81 [AC_TRY_CPP([#include <fshelp.h>],
82 fu_cv_sys_mounted_vmount=yes,
83 fu_cv_sys_mounted_vmount=no)])
84 AC_MSG_RESULT($fu_cv_sys_mounted_vmount)
85 if test $fu_cv_sys_mounted_vmount = yes; then
86 ac_list_mounted_fs=found
87 AC_DEFINE(MOUNTED_VMOUNT, 1,
88 [Define if there is a function named mntctl that can be used to read
89 the list of mounted filesystems, and there is a system header file
90 that declares `struct vmount.' (AIX)])
91 fi
92fi
93
94if test $ac_cv_func_getmntent = yes; then
95
96 # This system has the getmntent function.
97 # Determine whether it's the one-argument variant or the two-argument one.
98
99 if test -z "$ac_list_mounted_fs"; then
100 # 4.3BSD, SunOS, HP-UX, Dynix, Irix
101 AC_MSG_CHECKING([for one-argument getmntent function])
102 AC_CACHE_VAL(fu_cv_sys_mounted_getmntent1,
103 [AC_TRY_COMPILE([
104/* SunOS 4.1.x /usr/include/mntent.h needs this for FILE */
105#include <stdio.h>
106
107#include <mntent.h>
108#if !defined MOUNTED
109# if defined _PATH_MOUNTED /* GNU libc */
110# define MOUNTED _PATH_MOUNTED
111# endif
112# if defined MNT_MNTTAB /* HP-UX. */
113# define MOUNTED MNT_MNTTAB
114# endif
115# if defined MNTTABNAME /* Dynix. */
116# define MOUNTED MNTTABNAME
117# endif
118#endif
119],
120 [ struct mntent *mnt = 0; char *table = MOUNTED; ],
121 fu_cv_sys_mounted_getmntent1=yes,
122 fu_cv_sys_mounted_getmntent1=no)])
123 AC_MSG_RESULT($fu_cv_sys_mounted_getmntent1)
124 if test $fu_cv_sys_mounted_getmntent1 = yes; then
125 ac_list_mounted_fs=found
126 AC_DEFINE(MOUNTED_GETMNTENT1, 1,
127 [Define if there is a function named getmntent for reading the list
128 of mounted filesystems, and that function takes a single argument.
129 (4.3BSD, SunOS, HP-UX, Dynix, Irix)])
130 fi
131 fi
132
133 if test -z "$ac_list_mounted_fs"; then
134 # SVR4
135 AC_MSG_CHECKING([for two-argument getmntent function])
136 AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2,
137 [AC_EGREP_HEADER(getmntent, sys/mnttab.h,
138 fu_cv_sys_mounted_getmntent2=yes,
139 fu_cv_sys_mounted_getmntent2=no)])
140 AC_MSG_RESULT($fu_cv_sys_mounted_getmntent2)
141 if test $fu_cv_sys_mounted_getmntent2 = yes; then
142 ac_list_mounted_fs=found
143 AC_DEFINE(MOUNTED_GETMNTENT2, 1,
144 [Define if there is a function named getmntent for reading the list of
145 mounted filesystems, and that function takes two arguments. (SVR4)])
146 fi
147 fi
148
149fi
150
151if test -z "$ac_list_mounted_fs"; then
152 # DEC Alpha running OSF/1, and Apple Darwin 1.3.
153 # powerpc-apple-darwin1.3.7 needs sys/param.h sys/ucred.h sys/fs_types.h
154
155 AC_MSG_CHECKING([for getfsstat function])
156 AC_CACHE_VAL(fu_cv_sys_mounted_getfsstat,
157 [AC_TRY_LINK([
158#include <sys/types.h>
159#if HAVE_STRUCT_FSSTAT_F_FSTYPENAME
160# define FS_TYPE(Ent) ((Ent).f_fstypename)
161#else
162# define FS_TYPE(Ent) mnt_names[(Ent).f_type]
163#endif
164]$getfsstat_includes
165,
166 [struct statfs *stats;
167 int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT);
168 char *t = FS_TYPE (*stats); ],
169 fu_cv_sys_mounted_getfsstat=yes,
170 fu_cv_sys_mounted_getfsstat=no)])
171 AC_MSG_RESULT($fu_cv_sys_mounted_getfsstat)
172 if test $fu_cv_sys_mounted_getfsstat = yes; then
173 ac_list_mounted_fs=found
174 AC_DEFINE(MOUNTED_GETFSSTAT, 1,
175 [Define if there is a function named getfsstat for reading the
176 list of mounted filesystems. (DEC Alpha running OSF/1)])
177 fi
178fi
179
180if test -z "$ac_list_mounted_fs"; then
181 # SVR3
182 AC_MSG_CHECKING([for FIXME existence of three headers])
183 AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp,
184 [AC_TRY_CPP([
185#include <sys/statfs.h>
186#include <sys/fstyp.h>
187#include <mnttab.h>],
188 fu_cv_sys_mounted_fread_fstyp=yes,
189 fu_cv_sys_mounted_fread_fstyp=no)])
190 AC_MSG_RESULT($fu_cv_sys_mounted_fread_fstyp)
191 if test $fu_cv_sys_mounted_fread_fstyp = yes; then
192 ac_list_mounted_fs=found
193 AC_DEFINE(MOUNTED_FREAD_FSTYP, 1,
194 [Define if (like SVR2) there is no specific function for reading the
195 list of mounted filesystems, and your system has these header files:
196 <sys/fstyp.h> and <sys/statfs.h>. (SVR3)])
197 fi
198fi
199
200if test -z "$ac_list_mounted_fs"; then
201 # 4.4BSD and DEC OSF/1.
202 AC_MSG_CHECKING([for getmntinfo function])
203 AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo,
204 [
205 test "$ac_cv_func_getmntinfo" = yes \
206 && fu_cv_sys_mounted_getmntinfo=yes \
207 || fu_cv_sys_mounted_getmntinfo=no
208 ])
209 AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo)
210 if test $fu_cv_sys_mounted_getmntinfo = yes; then
211 ac_list_mounted_fs=found
212 AC_DEFINE(MOUNTED_GETMNTINFO, 1,
213 [Define if there is a function named getmntinfo for reading the
214 list of mounted filesystems. (4.4BSD, Darwin)])
215 fi
216fi
217
218if test -z "$ac_list_mounted_fs"; then
219 # Ultrix
220 AC_MSG_CHECKING([for getmnt function])
221 AC_CACHE_VAL(fu_cv_sys_mounted_getmnt,
222 [AC_TRY_CPP([
223#include <sys/fs_types.h>
224#include <sys/mount.h>],
225 fu_cv_sys_mounted_getmnt=yes,
226 fu_cv_sys_mounted_getmnt=no)])
227 AC_MSG_RESULT($fu_cv_sys_mounted_getmnt)
228 if test $fu_cv_sys_mounted_getmnt = yes; then
229 ac_list_mounted_fs=found
230 AC_DEFINE(MOUNTED_GETMNT, 1,
231 [Define if there is a function named getmnt for reading the list of
232 mounted filesystems. (Ultrix)])
233 fi
234fi
235
236if test -z "$ac_list_mounted_fs"; then
237 # BeOS
238 AC_CHECK_FUNCS(next_dev fs_stat_dev)
239 AC_CHECK_HEADERS(fs_info.h)
240 AC_MSG_CHECKING([for BEOS mounted file system support functions])
241 if test $ac_cv_header_fs_info_h = yes \
242 && test $ac_cv_func_next_dev = yes \
243 && test $ac_cv_func_fs_stat_dev = yes; then
244 fu_result=yes
245 else
246 fu_result=no
247 fi
248 AC_MSG_RESULT($fu_result)
249 if test $fu_result = yes; then
250 ac_list_mounted_fs=found
251 AC_DEFINE(MOUNTED_FS_STAT_DEV, 1,
252 [Define if there are functions named next_dev and fs_stat_dev for
253 reading the list of mounted filesystems. (BeOS)])
254 fi
255fi
256
257if test -z "$ac_list_mounted_fs"; then
258 # SVR2
259 AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
260 AC_CACHE_VAL(fu_cv_sys_mounted_fread,
261 [AC_TRY_CPP([#include <mnttab.h>],
262 fu_cv_sys_mounted_fread=yes,
263 fu_cv_sys_mounted_fread=no)])
264 AC_MSG_RESULT($fu_cv_sys_mounted_fread)
265 if test $fu_cv_sys_mounted_fread = yes; then
266 ac_list_mounted_fs=found
267 AC_DEFINE(MOUNTED_FREAD, 1,
268 [Define if there is no specific function for reading the list of
269 mounted filesystems. fread will be used to read /etc/mnttab.
270 (SVR2) ])
271 fi
272fi
273
274if test -z "$ac_list_mounted_fs"; then
275 AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
276 # FIXME -- no need to abort building the whole package
277 # Can't build mountlist.c or anything that needs its functions
278fi
279
280AS_IF([test $ac_list_mounted_fs = found], [$1], [$2])
281
282 ])