5 dnl This is not pretty. I've just taken the autoconf code and wrapped
9 # jm_LIST_MOUNTED_FILESYSTEMS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
10 AC_DEFUN([jm_LIST_MOUNTED_FILESYSTEMS],
12 AC_CHECK_FUNCS(listmntent getmntinfo)
13 AC_CHECK_HEADERS_ONCE(sys/param.h)
14 AC_CHECK_HEADERS(mntent.h sys/ucred.h sys/mount.h sys/fs_types.h)
18 # include <sys/param.h> /* needed by powerpc-apple-darwin1.3.7 */
21 # include <sys/ucred.h> /* needed by powerpc-apple-darwin1.3.7 */
24 # include <sys/mount.h>
26 #if HAVE_SYS_FS_TYPES_H
27 # include <sys/fs_types.h> /* needed by powerpc-apple-darwin1.3.7 */
30 AC_CHECK_MEMBERS([struct fsstat.f_fstypename],,,[$getfsstat_includes])
32 # Determine how to get the list of mounted filesystems.
35 # If the getmntent function is available but not in the standard library,
36 # make sure LIBS contains -lsun (on Irix4) or -lseq (on PTX).
39 # This test must precede the ones for getmntent because Unicos-9 is
40 # reported to have the getmntent function, but its support is incompatible
41 # with other getmntent implementations.
43 # NOTE: Normally, I wouldn't use a check for system type as I've done for
44 # `CRAY' below since that goes against the whole autoconf philosophy. But
45 # I think there is too great a chance that some non-Cray system has a
46 # function named listmntent to risk the false positive.
48 if test -z "$ac_list_mounted_fs"; then
50 AC_MSG_CHECKING([for listmntent of Cray/Unicos-9])
51 AC_CACHE_VAL(fu_cv_sys_mounted_cray_listmntent,
52 [fu_cv_sys_mounted_cray_listmntent=no
57 ], [test $ac_cv_func_listmntent = yes \
58 && fu_cv_sys_mounted_cray_listmntent=yes]
62 AC_MSG_RESULT($fu_cv_sys_mounted_cray_listmntent)
63 if test $fu_cv_sys_mounted_cray_listmntent = yes; then
64 ac_list_mounted_fs=found
65 AC_DEFINE(MOUNTED_LISTMNTENT, 1,
66 [Define if there is a function named listmntent that can be used to
67 list all mounted filesystems. (UNICOS)])
71 if test $ac_cv_func_getmntent = yes; then
73 # This system has the getmntent function.
74 # Determine whether it's the one-argument variant or the two-argument one.
76 if test -z "$ac_list_mounted_fs"; then
77 # 4.3BSD, SunOS, HP-UX, Dynix, Irix
78 AC_MSG_CHECKING([for one-argument getmntent function])
79 AC_CACHE_VAL(fu_cv_sys_mounted_getmntent1,
81 /* SunOS 4.1.x /usr/include/mntent.h needs this for FILE */
86 # if defined _PATH_MOUNTED /* GNU libc */
87 # define MOUNTED _PATH_MOUNTED
89 # if defined MNT_MNTTAB /* HP-UX. */
90 # define MOUNTED MNT_MNTTAB
92 # if defined MNTTABNAME /* Dynix. */
93 # define MOUNTED MNTTABNAME
97 [ struct mntent *mnt = 0; char *table = MOUNTED; ],
98 fu_cv_sys_mounted_getmntent1=yes,
99 fu_cv_sys_mounted_getmntent1=no)])
100 AC_MSG_RESULT($fu_cv_sys_mounted_getmntent1)
101 if test $fu_cv_sys_mounted_getmntent1 = yes; then
102 ac_list_mounted_fs=found
103 AC_DEFINE(MOUNTED_GETMNTENT1, 1,
104 [Define if there is a function named getmntent for reading the list
105 of mounted filesystems, and that function takes a single argument.
106 (4.3BSD, SunOS, HP-UX, Dynix, Irix)])
110 if test -z "$ac_list_mounted_fs"; then
112 AC_MSG_CHECKING([for two-argument getmntent function])
113 AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2,
114 [AC_EGREP_HEADER(getmntent, sys/mnttab.h,
115 fu_cv_sys_mounted_getmntent2=yes,
116 fu_cv_sys_mounted_getmntent2=no)])
117 AC_MSG_RESULT($fu_cv_sys_mounted_getmntent2)
118 if test $fu_cv_sys_mounted_getmntent2 = yes; then
119 ac_list_mounted_fs=found
120 AC_DEFINE(MOUNTED_GETMNTENT2, 1,
121 [Define if there is a function named getmntent for reading the list of
122 mounted filesystems, and that function takes two arguments. (SVR4)])
128 if test -z "$ac_list_mounted_fs"; then
129 # DEC Alpha running OSF/1, and Apple Darwin 1.3.
130 # powerpc-apple-darwin1.3.7 needs sys/param.h sys/ucred.h sys/fs_types.h
132 AC_MSG_CHECKING([for getfsstat function])
133 AC_CACHE_VAL(fu_cv_sys_mounted_getfsstat,
135 #include <sys/types.h>
136 #if HAVE_STRUCT_FSSTAT_F_FSTYPENAME
137 # define FS_TYPE(Ent) ((Ent).f_fstypename)
139 # define FS_TYPE(Ent) mnt_names[(Ent).f_type]
143 [struct statfs *stats;
144 int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT);
145 char *t = FS_TYPE (*stats); ],
146 fu_cv_sys_mounted_getfsstat=yes,
147 fu_cv_sys_mounted_getfsstat=no)])
148 AC_MSG_RESULT($fu_cv_sys_mounted_getfsstat)
149 if test $fu_cv_sys_mounted_getfsstat = yes; then
150 ac_list_mounted_fs=found
151 AC_DEFINE(MOUNTED_GETFSSTAT, 1,
152 [Define if there is a function named getfsstat for reading the
153 list of mounted filesystems. (DEC Alpha running OSF/1)])
157 if test -z "$ac_list_mounted_fs"; then
159 AC_MSG_CHECKING([for mntctl function and struct vmount])
160 AC_CACHE_VAL(fu_cv_sys_mounted_vmount,
161 [AC_TRY_CPP([#include <fshelp.h>],
162 fu_cv_sys_mounted_vmount=yes,
163 fu_cv_sys_mounted_vmount=no)])
164 AC_MSG_RESULT($fu_cv_sys_mounted_vmount)
165 if test $fu_cv_sys_mounted_vmount = yes; then
166 ac_list_mounted_fs=found
167 AC_DEFINE(MOUNTED_VMOUNT, 1,
168 [Define if there is a function named mntctl that can be used to read
169 the list of mounted filesystems, and there is a system header file
170 that declares `struct vmount.' (AIX)])
174 if test -z "$ac_list_mounted_fs"; then
176 AC_MSG_CHECKING([for FIXME existence of three headers])
177 AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp,
179 #include <sys/statfs.h>
180 #include <sys/fstyp.h>
181 #include <mnttab.h>],
182 fu_cv_sys_mounted_fread_fstyp=yes,
183 fu_cv_sys_mounted_fread_fstyp=no)])
184 AC_MSG_RESULT($fu_cv_sys_mounted_fread_fstyp)
185 if test $fu_cv_sys_mounted_fread_fstyp = yes; then
186 ac_list_mounted_fs=found
187 AC_DEFINE(MOUNTED_FREAD_FSTYP, 1,
188 [Define if (like SVR2) there is no specific function for reading the
189 list of mounted filesystems, and your system has these header files:
190 <sys/fstyp.h> and <sys/statfs.h>. (SVR3)])
194 if test -z "$ac_list_mounted_fs"; then
195 # 4.4BSD and DEC OSF/1.
196 AC_MSG_CHECKING([for getmntinfo function])
197 AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo,
199 test "$ac_cv_func_getmntinfo" = yes \
200 && fu_cv_sys_mounted_getmntinfo=yes \
201 || fu_cv_sys_mounted_getmntinfo=no
203 AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo)
204 if test $fu_cv_sys_mounted_getmntinfo = yes; then
205 ac_list_mounted_fs=found
206 AC_DEFINE(MOUNTED_GETMNTINFO, 1,
207 [Define if there is a function named getmntinfo for reading the
208 list of mounted filesystems. (4.4BSD, Darwin)])
212 if test -z "$ac_list_mounted_fs"; then
214 AC_MSG_CHECKING([for getmnt function])
215 AC_CACHE_VAL(fu_cv_sys_mounted_getmnt,
217 #include <sys/fs_types.h>
218 #include <sys/mount.h>],
219 fu_cv_sys_mounted_getmnt=yes,
220 fu_cv_sys_mounted_getmnt=no)])
221 AC_MSG_RESULT($fu_cv_sys_mounted_getmnt)
222 if test $fu_cv_sys_mounted_getmnt = yes; then
223 ac_list_mounted_fs=found
224 AC_DEFINE(MOUNTED_GETMNT, 1,
225 [Define if there is a function named getmnt for reading the list of
226 mounted filesystems. (Ultrix)])
230 if test -z "$ac_list_mounted_fs"; then
232 AC_CHECK_FUNCS(next_dev fs_stat_dev)
233 AC_CHECK_HEADERS(fs_info.h)
234 AC_MSG_CHECKING([for BEOS mounted file system support functions])
235 if test $ac_cv_header_fs_info_h = yes \
236 && test $ac_cv_func_next_dev = yes \
237 && test $ac_cv_func_fs_stat_dev = yes; then
242 AC_MSG_RESULT($fu_result)
243 if test $fu_result = yes; then
244 ac_list_mounted_fs=found
245 AC_DEFINE(MOUNTED_FS_STAT_DEV, 1,
246 [Define if there are functions named next_dev and fs_stat_dev for
247 reading the list of mounted filesystems. (BeOS)])
251 if test -z "$ac_list_mounted_fs"; then
253 AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
254 AC_CACHE_VAL(fu_cv_sys_mounted_fread,
255 [AC_TRY_CPP([#include <mnttab.h>],
256 fu_cv_sys_mounted_fread=yes,
257 fu_cv_sys_mounted_fread=no)])
258 AC_MSG_RESULT($fu_cv_sys_mounted_fread)
259 if test $fu_cv_sys_mounted_fread = yes; then
260 ac_list_mounted_fs=found
261 AC_DEFINE(MOUNTED_FREAD, 1,
262 [Define if there is no specific function for reading the list of
263 mounted filesystems. fread will be used to read /etc/mnttab.
268 if test -z "$ac_list_mounted_fs"; then
269 AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
270 # FIXME -- no need to abort building the whole package
271 # Can't build mountlist.c or anything that needs its functions
274 AS_IF([test $ac_list_mounted_fs = found], [$1], [$2])