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(mntent.h sys/param.h sys/ucred.h sys/mount.h sys/fs_types.h)
17 # include <sys/param.h> /* needed by powerpc-apple-darwin1.3.7 */
20 # include <sys/ucred.h> /* needed by powerpc-apple-darwin1.3.7 */
23 # include <sys/mount.h>
25 #if HAVE_SYS_FS_TYPES_H
26 # include <sys/fs_types.h> /* needed by powerpc-apple-darwin1.3.7 */
29 AC_CHECK_MEMBERS([struct fsstat.f_fstypename],,,[$getfsstat_includes])
31 # Determine how to get the list of mounted filesystems.
34 # If the getmntent function is available but not in the standard library,
35 # make sure LIBS contains -lsun (on Irix4) or -lseq (on PTX).
38 # This test must precede the ones for getmntent because Unicos-9 is
39 # reported to have the getmntent function, but its support is incompatible
40 # with other getmntent implementations.
42 # NOTE: Normally, I wouldn't use a check for system type as I've done for
43 # `CRAY' below since that goes against the whole autoconf philosophy. But
44 # I think there is too great a chance that some non-Cray system has a
45 # function named listmntent to risk the false positive.
47 if test -z "$ac_list_mounted_fs"; then
49 AC_MSG_CHECKING([for listmntent of Cray/Unicos-9])
50 AC_CACHE_VAL(fu_cv_sys_mounted_cray_listmntent,
51 [fu_cv_sys_mounted_cray_listmntent=no
56 ], [test $ac_cv_func_listmntent = yes \
57 && fu_cv_sys_mounted_cray_listmntent=yes]
61 AC_MSG_RESULT($fu_cv_sys_mounted_cray_listmntent)
62 if test $fu_cv_sys_mounted_cray_listmntent = yes; then
63 ac_list_mounted_fs=found
64 AC_DEFINE(MOUNTED_LISTMNTENT, 1,
65 [Define if there is a function named listmntent that can be used to
66 list all mounted filesystems. (UNICOS)])
70 if test $ac_cv_func_getmntent = yes; then
72 # This system has the getmntent function.
73 # Determine whether it's the one-argument variant or the two-argument one.
75 if test -z "$ac_list_mounted_fs"; then
76 # 4.3BSD, SunOS, HP-UX, Dynix, Irix
77 AC_MSG_CHECKING([for one-argument getmntent function])
78 AC_CACHE_VAL(fu_cv_sys_mounted_getmntent1,
80 /* SunOS 4.1.x /usr/include/mntent.h needs this for FILE */
85 # if defined _PATH_MOUNTED /* GNU libc */
86 # define MOUNTED _PATH_MOUNTED
88 # if defined MNT_MNTTAB /* HP-UX. */
89 # define MOUNTED MNT_MNTTAB
91 # if defined MNTTABNAME /* Dynix. */
92 # define MOUNTED MNTTABNAME
96 [ struct mntent *mnt = 0; char *table = MOUNTED; ],
97 fu_cv_sys_mounted_getmntent1=yes,
98 fu_cv_sys_mounted_getmntent1=no)])
99 AC_MSG_RESULT($fu_cv_sys_mounted_getmntent1)
100 if test $fu_cv_sys_mounted_getmntent1 = yes; then
101 ac_list_mounted_fs=found
102 AC_DEFINE(MOUNTED_GETMNTENT1, 1,
103 [Define if there is a function named getmntent for reading the list
104 of mounted filesystems, and that function takes a single argument.
105 (4.3BSD, SunOS, HP-UX, Dynix, Irix)])
109 if test -z "$ac_list_mounted_fs"; then
111 AC_MSG_CHECKING([for two-argument getmntent function])
112 AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2,
113 [AC_EGREP_HEADER(getmntent, sys/mnttab.h,
114 fu_cv_sys_mounted_getmntent2=yes,
115 fu_cv_sys_mounted_getmntent2=no)])
116 AC_MSG_RESULT($fu_cv_sys_mounted_getmntent2)
117 if test $fu_cv_sys_mounted_getmntent2 = yes; then
118 ac_list_mounted_fs=found
119 AC_DEFINE(MOUNTED_GETMNTENT2, 1,
120 [Define if there is a function named getmntent for reading the list of
121 mounted filesystems, and that function takes two arguments. (SVR4)])
127 if test -z "$ac_list_mounted_fs"; then
128 # DEC Alpha running OSF/1, and Apple Darwin 1.3.
129 # powerpc-apple-darwin1.3.7 needs sys/param.h sys/ucred.h sys/fs_types.h
131 AC_MSG_CHECKING([for getfsstat function])
132 AC_CACHE_VAL(fu_cv_sys_mounted_getfsstat,
134 #include <sys/types.h>
135 #if HAVE_STRUCT_FSSTAT_F_FSTYPENAME
136 # define FS_TYPE(Ent) ((Ent).f_fstypename)
138 # define FS_TYPE(Ent) mnt_names[(Ent).f_type]
142 [struct statfs *stats;
143 int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT);
144 char *t = FS_TYPE (*stats); ],
145 fu_cv_sys_mounted_getfsstat=yes,
146 fu_cv_sys_mounted_getfsstat=no)])
147 AC_MSG_RESULT($fu_cv_sys_mounted_getfsstat)
148 if test $fu_cv_sys_mounted_getfsstat = yes; then
149 ac_list_mounted_fs=found
150 AC_DEFINE(MOUNTED_GETFSSTAT, 1,
151 [Define if there is a function named getfsstat for reading the
152 list of mounted filesystems. (DEC Alpha running OSF/1)])
156 if test -z "$ac_list_mounted_fs"; then
158 AC_MSG_CHECKING([for mntctl function and struct vmount])
159 AC_CACHE_VAL(fu_cv_sys_mounted_vmount,
160 [AC_TRY_CPP([#include <fshelp.h>],
161 fu_cv_sys_mounted_vmount=yes,
162 fu_cv_sys_mounted_vmount=no)])
163 AC_MSG_RESULT($fu_cv_sys_mounted_vmount)
164 if test $fu_cv_sys_mounted_vmount = yes; then
165 ac_list_mounted_fs=found
166 AC_DEFINE(MOUNTED_VMOUNT, 1,
167 [Define if there is a function named mntctl that can be used to read
168 the list of mounted filesystems, and there is a system header file
169 that declares `struct vmount.' (AIX)])
173 if test -z "$ac_list_mounted_fs"; then
175 AC_MSG_CHECKING([for FIXME existence of three headers])
176 AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp,
178 #include <sys/statfs.h>
179 #include <sys/fstyp.h>
180 #include <mnttab.h>],
181 fu_cv_sys_mounted_fread_fstyp=yes,
182 fu_cv_sys_mounted_fread_fstyp=no)])
183 AC_MSG_RESULT($fu_cv_sys_mounted_fread_fstyp)
184 if test $fu_cv_sys_mounted_fread_fstyp = yes; then
185 ac_list_mounted_fs=found
186 AC_DEFINE(MOUNTED_FREAD_FSTYP, 1,
187 [Define if (like SVR2) there is no specific function for reading the
188 list of mounted filesystems, and your system has these header files:
189 <sys/fstyp.h> and <sys/statfs.h>. (SVR3)])
193 if test -z "$ac_list_mounted_fs"; then
194 # 4.4BSD and DEC OSF/1.
195 AC_MSG_CHECKING([for getmntinfo function])
196 AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo,
198 test "$ac_cv_func_getmntinfo" = yes \
199 && fu_cv_sys_mounted_getmntinfo=yes \
200 || fu_cv_sys_mounted_getmntinfo=no
202 AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo)
203 if test $fu_cv_sys_mounted_getmntinfo = yes; then
204 ac_list_mounted_fs=found
205 AC_DEFINE(MOUNTED_GETMNTINFO, 1,
206 [Define if there is a function named getmntinfo for reading the
207 list of mounted filesystems. (4.4BSD, Darwin)])
211 if test -z "$ac_list_mounted_fs"; then
213 AC_MSG_CHECKING([for getmnt function])
214 AC_CACHE_VAL(fu_cv_sys_mounted_getmnt,
216 #include <sys/fs_types.h>
217 #include <sys/mount.h>],
218 fu_cv_sys_mounted_getmnt=yes,
219 fu_cv_sys_mounted_getmnt=no)])
220 AC_MSG_RESULT($fu_cv_sys_mounted_getmnt)
221 if test $fu_cv_sys_mounted_getmnt = yes; then
222 ac_list_mounted_fs=found
223 AC_DEFINE(MOUNTED_GETMNT, 1,
224 [Define if there is a function named getmnt for reading the list of
225 mounted filesystems. (Ultrix)])
229 if test -z "$ac_list_mounted_fs"; then
231 AC_CHECK_FUNCS(next_dev fs_stat_dev)
232 AC_CHECK_HEADERS(fs_info.h)
233 AC_MSG_CHECKING([for BEOS mounted file system support functions])
234 if test $ac_cv_header_fs_info_h = yes \
235 && test $ac_cv_func_next_dev = yes \
236 && test $ac_cv_func_fs_stat_dev = yes; then
241 AC_MSG_RESULT($fu_result)
242 if test $fu_result = yes; then
243 ac_list_mounted_fs=found
244 AC_DEFINE(MOUNTED_FS_STAT_DEV, 1,
245 [Define if there are functions named next_dev and fs_stat_dev for
246 reading the list of mounted filesystems. (BeOS)])
250 if test -z "$ac_list_mounted_fs"; then
252 AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
253 AC_CACHE_VAL(fu_cv_sys_mounted_fread,
254 [AC_TRY_CPP([#include <mnttab.h>],
255 fu_cv_sys_mounted_fread=yes,
256 fu_cv_sys_mounted_fread=no)])
257 AC_MSG_RESULT($fu_cv_sys_mounted_fread)
258 if test $fu_cv_sys_mounted_fread = yes; then
259 ac_list_mounted_fs=found
260 AC_DEFINE(MOUNTED_FREAD, 1,
261 [Define if there is no specific function for reading the list of
262 mounted filesystems. fread will be used to read /etc/mnttab. (SVR2) ])
266 if test -z "$ac_list_mounted_fs"; then
267 AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
268 # FIXME -- no need to abort building the whole package
269 # Can't build mountlist.c or anything that needs its functions
272 AS_IF([test $ac_list_mounted_fs = found], [$1], [$2])