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 -z "$ac_list_mounted_fs"; then
73 AC_MSG_CHECKING([for mntctl function and struct vmount])
74 AC_CACHE_VAL(fu_cv_sys_mounted_vmount,
75 [AC_TRY_CPP([#include <fshelp.h>],
76 fu_cv_sys_mounted_vmount=yes,
77 fu_cv_sys_mounted_vmount=no)])
78 AC_MSG_RESULT($fu_cv_sys_mounted_vmount)
79 if test $fu_cv_sys_mounted_vmount = yes; then
80 ac_list_mounted_fs=found
81 AC_DEFINE(MOUNTED_VMOUNT, 1,
82 [Define if there is a function named mntctl that can be used to read
83 the list of mounted filesystems, and there is a system header file
84 that declares `struct vmount.' (AIX)])
88 if test $ac_cv_func_getmntent = yes; then
90 # This system has the getmntent function.
91 # Determine whether it's the one-argument variant or the two-argument one.
93 if test -z "$ac_list_mounted_fs"; then
94 # 4.3BSD, SunOS, HP-UX, Dynix, Irix
95 AC_MSG_CHECKING([for one-argument getmntent function])
96 AC_CACHE_VAL(fu_cv_sys_mounted_getmntent1,
98 /* SunOS 4.1.x /usr/include/mntent.h needs this for FILE */
103 # if defined _PATH_MOUNTED /* GNU libc */
104 # define MOUNTED _PATH_MOUNTED
106 # if defined MNT_MNTTAB /* HP-UX. */
107 # define MOUNTED MNT_MNTTAB
109 # if defined MNTTABNAME /* Dynix. */
110 # define MOUNTED MNTTABNAME
114 [ struct mntent *mnt = 0; char *table = MOUNTED; ],
115 fu_cv_sys_mounted_getmntent1=yes,
116 fu_cv_sys_mounted_getmntent1=no)])
117 AC_MSG_RESULT($fu_cv_sys_mounted_getmntent1)
118 if test $fu_cv_sys_mounted_getmntent1 = yes; then
119 ac_list_mounted_fs=found
120 AC_DEFINE(MOUNTED_GETMNTENT1, 1,
121 [Define if there is a function named getmntent for reading the list
122 of mounted filesystems, and that function takes a single argument.
123 (4.3BSD, SunOS, HP-UX, Dynix, Irix)])
127 if test -z "$ac_list_mounted_fs"; then
129 AC_MSG_CHECKING([for two-argument getmntent function])
130 AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2,
131 [AC_EGREP_HEADER(getmntent, sys/mnttab.h,
132 fu_cv_sys_mounted_getmntent2=yes,
133 fu_cv_sys_mounted_getmntent2=no)])
134 AC_MSG_RESULT($fu_cv_sys_mounted_getmntent2)
135 if test $fu_cv_sys_mounted_getmntent2 = yes; then
136 ac_list_mounted_fs=found
137 AC_DEFINE(MOUNTED_GETMNTENT2, 1,
138 [Define if there is a function named getmntent for reading the list of
139 mounted filesystems, and that function takes two arguments. (SVR4)])
145 if test -z "$ac_list_mounted_fs"; then
146 # DEC Alpha running OSF/1, and Apple Darwin 1.3.
147 # powerpc-apple-darwin1.3.7 needs sys/param.h sys/ucred.h sys/fs_types.h
149 AC_MSG_CHECKING([for getfsstat function])
150 AC_CACHE_VAL(fu_cv_sys_mounted_getfsstat,
152 #include <sys/types.h>
153 #if HAVE_STRUCT_FSSTAT_F_FSTYPENAME
154 # define FS_TYPE(Ent) ((Ent).f_fstypename)
156 # define FS_TYPE(Ent) mnt_names[(Ent).f_type]
160 [struct statfs *stats;
161 int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT);
162 char *t = FS_TYPE (*stats); ],
163 fu_cv_sys_mounted_getfsstat=yes,
164 fu_cv_sys_mounted_getfsstat=no)])
165 AC_MSG_RESULT($fu_cv_sys_mounted_getfsstat)
166 if test $fu_cv_sys_mounted_getfsstat = yes; then
167 ac_list_mounted_fs=found
168 AC_DEFINE(MOUNTED_GETFSSTAT, 1,
169 [Define if there is a function named getfsstat for reading the
170 list of mounted filesystems. (DEC Alpha running OSF/1)])
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])