5 dnl This is not pretty. I've just taken the autoconf code and wrapped
8 dnl CAUTION: This is very fragile. It relies on several checks that
9 dnl are still in fileutils' configure.in:
10 dnl FIXME: add AC_REQUIRE uses to pull in all definitions required
11 dnl for all uses of $ac_cv_func_* and $ac_cv_header_* variables below.
16 # jm_LIST_MOUNTED_FILESYSTEMS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
17 AC_DEFUN(jm_LIST_MOUNTED_FILESYSTEMS,
19 # Determine how to get the list of mounted filesystems.
22 # If the getmntent function is available but not in the standard library,
23 # make sure LIBS contains -lsun (on Irix4) or -lseq (on PTX).
26 # This test must precede the ones for getmntent because Unicos-9 is
27 # reported to have the getmntent function, but its support is incompatible
28 # with other getmntent implementations.
30 # NOTE: Normally, I wouldn't use a check for system type as I've done for
31 # `CRAY' below since that goes against the whole autoconf philosophy. But
32 # I think there is too great a chance that some non-Cray system has a
33 # function named listmntent to risk the false positive.
35 if test -z "$ac_list_mounted_fs"; then
37 AC_MSG_CHECKING([for listmntent of Cray/Unicos-9])
38 AC_CACHE_VAL(fu_cv_sys_mounted_cray_listmntent,
39 [fu_cv_sys_mounted_cray_listmntent=no
44 ], [test $ac_cv_func_listmntent = yes \
45 && fu_cv_sys_mounted_cray_listmntent=yes]
49 AC_MSG_RESULT($fu_cv_sys_mounted_cray_listmntent)
50 if test $fu_cv_sys_mounted_cray_listmntent = yes; then
51 ac_list_mounted_fs=found
52 AC_DEFINE(MOUNTED_LISTMNTENT, 1,
53 [Define if there is a function named listmntent that can be used to
54 list all mounted filesystems. (UNICOS)])
58 if test $ac_cv_func_getmntent = yes; then
60 # This system has the getmntent function.
61 # Determine whether it's the one-argument variant or the two-argument one.
63 if test -z "$ac_list_mounted_fs"; then
64 # 4.3BSD, SunOS, HP-UX, Dynix, Irix
65 AC_MSG_CHECKING([for one-argument getmntent function])
66 AC_CACHE_VAL(fu_cv_sys_mounted_getmntent1,
67 [test $ac_cv_header_mntent_h = yes \
68 && fu_cv_sys_mounted_getmntent1=yes \
69 || fu_cv_sys_mounted_getmntent1=no])
70 AC_MSG_RESULT($fu_cv_sys_mounted_getmntent1)
71 if test $fu_cv_sys_mounted_getmntent1 = yes; then
72 ac_list_mounted_fs=found
73 AC_DEFINE(MOUNTED_GETMNTENT1, 1,
74 [Define if there is a function named getmntent for reading the list
75 of mounted filesystems, and that function takes a single argument.
76 (4.3BSD, SunOS, HP-UX, Dynix, Irix)])
80 if test -z "$ac_list_mounted_fs"; then
82 AC_MSG_CHECKING([for two-argument getmntent function])
83 AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2,
84 [AC_EGREP_HEADER(getmntent, sys/mnttab.h,
85 fu_cv_sys_mounted_getmntent2=yes,
86 fu_cv_sys_mounted_getmntent2=no)])
87 AC_MSG_RESULT($fu_cv_sys_mounted_getmntent2)
88 if test $fu_cv_sys_mounted_getmntent2 = yes; then
89 ac_list_mounted_fs=found
90 AC_DEFINE(MOUNTED_GETMNTENT2, 1,
91 [Define if there is a function named getmntent for reading the list of
92 mounted filesystems, and that function takes two arguments. (SVR4)])
96 if test -z "$ac_list_mounted_fs"; then
97 AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
102 if test -z "$ac_list_mounted_fs"; then
103 # DEC Alpha running OSF/1.
104 AC_MSG_CHECKING([for getfsstat function])
105 AC_CACHE_VAL(fu_cv_sys_mounted_getsstat,
107 #include <sys/types.h>
108 #include <sys/mount.h>
109 #include <sys/fs_types.h>],
110 [struct statfs *stats;
111 int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); ],
112 fu_cv_sys_mounted_getsstat=yes,
113 fu_cv_sys_mounted_getsstat=no)])
114 AC_MSG_RESULT($fu_cv_sys_mounted_getsstat)
115 if test $fu_cv_sys_mounted_getsstat = yes; then
116 ac_list_mounted_fs=found
117 AC_DEFINE(MOUNTED_GETFSSTAT, 1,
118 [Define if there is a function named getfsstat for reading the
119 list of mounted filesystems. (DEC Alpha running OSF/1)])
123 if test -z "$ac_list_mounted_fs"; then
125 AC_MSG_CHECKING([for mntctl function and struct vmount])
126 AC_CACHE_VAL(fu_cv_sys_mounted_vmount,
127 [AC_TRY_CPP([#include <fshelp.h>],
128 fu_cv_sys_mounted_vmount=yes,
129 fu_cv_sys_mounted_vmount=no)])
130 AC_MSG_RESULT($fu_cv_sys_mounted_vmount)
131 if test $fu_cv_sys_mounted_vmount = yes; then
132 ac_list_mounted_fs=found
133 AC_DEFINE(MOUNTED_VMOUNT, 1,
134 [Define if there is a function named mntctl that can be used to read
135 the list of mounted filesystems, and there is a system header file
136 that declares `struct vmount.' (AIX)])
140 if test -z "$ac_list_mounted_fs"; then
142 AC_MSG_CHECKING([for FIXME existence of three headers])
143 AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp,
145 #include <sys/statfs.h>
146 #include <sys/fstyp.h>
147 #include <mnttab.h>],
148 fu_cv_sys_mounted_fread_fstyp=yes,
149 fu_cv_sys_mounted_fread_fstyp=no)])
150 AC_MSG_RESULT($fu_cv_sys_mounted_fread_fstyp)
151 if test $fu_cv_sys_mounted_fread_fstyp = yes; then
152 ac_list_mounted_fs=found
153 AC_DEFINE(MOUNTED_FREAD_FSTYP, 1,
154 [Define if (like SVR2) there is no specific function for reading the
155 list of mounted filesystems, and your system has these header files:
156 <sys/fstyp.h> and <sys/statfs.h>. (SVR3)])
160 if test -z "$ac_list_mounted_fs"; then
161 # 4.4BSD and DEC OSF/1.
162 AC_MSG_CHECKING([for getmntinfo function])
163 AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo,
166 if test $ac_cv_func_getmntinfo = yes; then
167 AC_EGREP_HEADER(f_type;, sys/mount.h,
171 && fu_cv_sys_mounted_getmntinfo=yes \
172 || fu_cv_sys_mounted_getmntinfo=no
174 AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo)
175 if test $fu_cv_sys_mounted_getmntinfo = yes; then
176 ac_list_mounted_fs=found
177 AC_DEFINE(MOUNTED_GETMNTINFO, 1,
178 [Define if there is a function named getmntinfo for reading the
179 list of mounted filesystems. (4.4BSD)])
183 if test -z "$ac_list_mounted_fs"; then
185 AC_MSG_CHECKING([for getmnt function])
186 AC_CACHE_VAL(fu_cv_sys_mounted_getmnt,
188 #include <sys/fs_types.h>
189 #include <sys/mount.h>],
190 fu_cv_sys_mounted_getmnt=yes,
191 fu_cv_sys_mounted_getmnt=no)])
192 AC_MSG_RESULT($fu_cv_sys_mounted_getmnt)
193 if test $fu_cv_sys_mounted_getmnt = yes; then
194 ac_list_mounted_fs=found
195 AC_DEFINE(MOUNTED_GETMNT, 1,
196 [Define if there is a function named getmnt for reading the list of
197 mounted filesystems. (Ultrix)])
201 if test -z "$ac_list_mounted_fs"; then
203 AC_CHECK_FUNCS(next_dev fs_stat_dev)
204 AC_CHECK_HEADERS(fs_info.h)
205 AC_MSG_CHECKING([for BEOS mounted file system support functions])
206 if test $ac_cv_header_fs_info_h = yes \
207 && test $ac_cv_func_next_dev = yes \
208 && test $ac_cv_func_fs_stat_dev = yes; then
213 AC_MSG_RESULT($fu_result)
214 if test $fu_result = yes; then
215 ac_list_mounted_fs=found
216 AC_DEFINE(MOUNTED_NEXT_DEV, 1,
217 [Define if there are functions named next_dev and fs_stat_dev for
218 reading the list of mounted filesystems. (BeOS)])
222 if test -z "$ac_list_mounted_fs"; then
224 AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
225 AC_CACHE_VAL(fu_cv_sys_mounted_fread,
226 [AC_TRY_CPP([#include <mnttab.h>],
227 fu_cv_sys_mounted_fread=yes,
228 fu_cv_sys_mounted_fread=no)])
229 AC_MSG_RESULT($fu_cv_sys_mounted_fread)
230 if test $fu_cv_sys_mounted_fread = yes; then
231 ac_list_mounted_fs=found
232 AC_DEFINE(MOUNTED_FREAD, 1,
233 [Define if there is no specific function for reading the list of
234 mounted filesystems. fread will be used to read /etc/mnttab. (SVR2) ])
238 if test -z "$ac_list_mounted_fs"; then
239 AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
240 # FIXME -- no need to abort building the whole package
241 # Can't build mountlist.c or anything that needs its functions
244 AC_SHELL_IFELSE([test $ac_list_mounted_fs = found], [$1], [$2])dnl