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)
15 # Determine how to get the list of mounted filesystems.
18 # If the getmntent function is available but not in the standard library,
19 # make sure LIBS contains -lsun (on Irix4) or -lseq (on PTX).
22 # This test must precede the ones for getmntent because Unicos-9 is
23 # reported to have the getmntent function, but its support is incompatible
24 # with other getmntent implementations.
26 # NOTE: Normally, I wouldn't use a check for system type as I've done for
27 # `CRAY' below since that goes against the whole autoconf philosophy. But
28 # I think there is too great a chance that some non-Cray system has a
29 # function named listmntent to risk the false positive.
31 if test -z "$ac_list_mounted_fs"; then
33 AC_MSG_CHECKING([for listmntent of Cray/Unicos-9])
34 AC_CACHE_VAL(fu_cv_sys_mounted_cray_listmntent,
35 [fu_cv_sys_mounted_cray_listmntent=no
40 ], [test $ac_cv_func_listmntent = yes \
41 && fu_cv_sys_mounted_cray_listmntent=yes]
45 AC_MSG_RESULT($fu_cv_sys_mounted_cray_listmntent)
46 if test $fu_cv_sys_mounted_cray_listmntent = yes; then
47 ac_list_mounted_fs=found
48 AC_DEFINE(MOUNTED_LISTMNTENT, 1,
49 [Define if there is a function named listmntent that can be used to
50 list all mounted filesystems. (UNICOS)])
54 if test $ac_cv_func_getmntent = yes; then
56 # This system has the getmntent function.
57 # Determine whether it's the one-argument variant or the two-argument one.
59 if test -z "$ac_list_mounted_fs"; then
60 # 4.3BSD, SunOS, HP-UX, Dynix, Irix
61 AC_MSG_CHECKING([for one-argument getmntent function])
62 AC_CACHE_VAL(fu_cv_sys_mounted_getmntent1,
63 [test $ac_cv_header_mntent_h = yes \
64 && fu_cv_sys_mounted_getmntent1=yes \
65 || fu_cv_sys_mounted_getmntent1=no])
66 AC_MSG_RESULT($fu_cv_sys_mounted_getmntent1)
67 if test $fu_cv_sys_mounted_getmntent1 = yes; then
68 ac_list_mounted_fs=found
69 AC_DEFINE(MOUNTED_GETMNTENT1, 1,
70 [Define if there is a function named getmntent for reading the list
71 of mounted filesystems, and that function takes a single argument.
72 (4.3BSD, SunOS, HP-UX, Dynix, Irix)])
76 if test -z "$ac_list_mounted_fs"; then
78 AC_MSG_CHECKING([for two-argument getmntent function])
79 AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2,
80 [AC_EGREP_HEADER(getmntent, sys/mnttab.h,
81 fu_cv_sys_mounted_getmntent2=yes,
82 fu_cv_sys_mounted_getmntent2=no)])
83 AC_MSG_RESULT($fu_cv_sys_mounted_getmntent2)
84 if test $fu_cv_sys_mounted_getmntent2 = yes; then
85 ac_list_mounted_fs=found
86 AC_DEFINE(MOUNTED_GETMNTENT2, 1,
87 [Define if there is a function named getmntent for reading the list of
88 mounted filesystems, and that function takes two arguments. (SVR4)])
92 if test -z "$ac_list_mounted_fs"; then
93 AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
98 if test -z "$ac_list_mounted_fs"; then
99 # DEC Alpha running OSF/1.
100 AC_MSG_CHECKING([for getfsstat function])
101 AC_CACHE_VAL(fu_cv_sys_mounted_getsstat,
103 #include <sys/types.h>
104 #include <sys/mount.h>
105 #include <sys/fs_types.h>],
106 [struct statfs *stats;
107 int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); ],
108 fu_cv_sys_mounted_getsstat=yes,
109 fu_cv_sys_mounted_getsstat=no)])
110 AC_MSG_RESULT($fu_cv_sys_mounted_getsstat)
111 if test $fu_cv_sys_mounted_getsstat = yes; then
112 ac_list_mounted_fs=found
113 AC_DEFINE(MOUNTED_GETFSSTAT, 1,
114 [Define if there is a function named getfsstat for reading the
115 list of mounted filesystems. (DEC Alpha running OSF/1)])
119 if test -z "$ac_list_mounted_fs"; then
121 AC_MSG_CHECKING([for mntctl function and struct vmount])
122 AC_CACHE_VAL(fu_cv_sys_mounted_vmount,
123 [AC_TRY_CPP([#include <fshelp.h>],
124 fu_cv_sys_mounted_vmount=yes,
125 fu_cv_sys_mounted_vmount=no)])
126 AC_MSG_RESULT($fu_cv_sys_mounted_vmount)
127 if test $fu_cv_sys_mounted_vmount = yes; then
128 ac_list_mounted_fs=found
129 AC_DEFINE(MOUNTED_VMOUNT, 1,
130 [Define if there is a function named mntctl that can be used to read
131 the list of mounted filesystems, and there is a system header file
132 that declares `struct vmount.' (AIX)])
136 if test -z "$ac_list_mounted_fs"; then
138 AC_MSG_CHECKING([for FIXME existence of three headers])
139 AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp,
141 #include <sys/statfs.h>
142 #include <sys/fstyp.h>
143 #include <mnttab.h>],
144 fu_cv_sys_mounted_fread_fstyp=yes,
145 fu_cv_sys_mounted_fread_fstyp=no)])
146 AC_MSG_RESULT($fu_cv_sys_mounted_fread_fstyp)
147 if test $fu_cv_sys_mounted_fread_fstyp = yes; then
148 ac_list_mounted_fs=found
149 AC_DEFINE(MOUNTED_FREAD_FSTYP, 1,
150 [Define if (like SVR2) there is no specific function for reading the
151 list of mounted filesystems, and your system has these header files:
152 <sys/fstyp.h> and <sys/statfs.h>. (SVR3)])
156 if test -z "$ac_list_mounted_fs"; then
157 # 4.4BSD and DEC OSF/1.
158 AC_MSG_CHECKING([for getmntinfo function])
159 AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo,
162 if test $ac_cv_func_getmntinfo = yes; then
163 AC_EGREP_HEADER(f_type;, sys/mount.h,
167 && fu_cv_sys_mounted_getmntinfo=yes \
168 || fu_cv_sys_mounted_getmntinfo=no
170 AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo)
171 if test $fu_cv_sys_mounted_getmntinfo = yes; then
172 ac_list_mounted_fs=found
173 AC_DEFINE(MOUNTED_GETMNTINFO, 1,
174 [Define if there is a function named getmntinfo for reading the
175 list of mounted filesystems. (4.4BSD)])
179 if test -z "$ac_list_mounted_fs"; then
181 AC_MSG_CHECKING([for getmnt function])
182 AC_CACHE_VAL(fu_cv_sys_mounted_getmnt,
184 #include <sys/fs_types.h>
185 #include <sys/mount.h>],
186 fu_cv_sys_mounted_getmnt=yes,
187 fu_cv_sys_mounted_getmnt=no)])
188 AC_MSG_RESULT($fu_cv_sys_mounted_getmnt)
189 if test $fu_cv_sys_mounted_getmnt = yes; then
190 ac_list_mounted_fs=found
191 AC_DEFINE(MOUNTED_GETMNT, 1,
192 [Define if there is a function named getmnt for reading the list of
193 mounted filesystems. (Ultrix)])
197 if test -z "$ac_list_mounted_fs"; then
199 AC_CHECK_FUNCS(next_dev fs_stat_dev)
200 AC_CHECK_HEADERS(fs_info.h)
201 AC_MSG_CHECKING([for BEOS mounted file system support functions])
202 if test $ac_cv_header_fs_info_h = yes \
203 && test $ac_cv_func_next_dev = yes \
204 && test $ac_cv_func_fs_stat_dev = yes; then
209 AC_MSG_RESULT($fu_result)
210 if test $fu_result = yes; then
211 ac_list_mounted_fs=found
212 AC_DEFINE(MOUNTED_FS_STAT_DEV, 1,
213 [Define if there are functions named next_dev and fs_stat_dev for
214 reading the list of mounted filesystems. (BeOS)])
218 if test -z "$ac_list_mounted_fs"; then
220 AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
221 AC_CACHE_VAL(fu_cv_sys_mounted_fread,
222 [AC_TRY_CPP([#include <mnttab.h>],
223 fu_cv_sys_mounted_fread=yes,
224 fu_cv_sys_mounted_fread=no)])
225 AC_MSG_RESULT($fu_cv_sys_mounted_fread)
226 if test $fu_cv_sys_mounted_fread = yes; then
227 ac_list_mounted_fs=found
228 AC_DEFINE(MOUNTED_FREAD, 1,
229 [Define if there is no specific function for reading the list of
230 mounted filesystems. fread will be used to read /etc/mnttab. (SVR2) ])
234 if test -z "$ac_list_mounted_fs"; then
235 AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
236 # FIXME -- no need to abort building the whole package
237 # Can't build mountlist.c or anything that needs its functions
240 AS_IF([test $ac_list_mounted_fs = found], [$1], [$2])