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,
66 # if defined _PATH_MOUNTED /* GNU libc */
67 # define MOUNTED _PATH_MOUNTED
69 # if defined MNT_MNTTAB /* HP-UX. */
70 # define MOUNTED MNT_MNTTAB
72 # if defined MNTTABNAME /* Dynix. */
73 # define MOUNTED MNTTABNAME
77 [ struct mntent *mnt = 0; char *table = MOUNTED; ],
78 fu_cv_sys_mounted_getmntent1=yes,
79 fu_cv_sys_mounted_getmntent1=no)])
80 AC_MSG_RESULT($fu_cv_sys_mounted_getmntent1)
81 if test $fu_cv_sys_mounted_getmntent1 = yes; then
82 ac_list_mounted_fs=found
83 AC_DEFINE(MOUNTED_GETMNTENT1, 1,
84 [Define if there is a function named getmntent for reading the list
85 of mounted filesystems, and that function takes a single argument.
86 (4.3BSD, SunOS, HP-UX, Dynix, Irix)])
90 if test -z "$ac_list_mounted_fs"; then
92 AC_MSG_CHECKING([for two-argument getmntent function])
93 AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2,
94 [AC_EGREP_HEADER(getmntent, sys/mnttab.h,
95 fu_cv_sys_mounted_getmntent2=yes,
96 fu_cv_sys_mounted_getmntent2=no)])
97 AC_MSG_RESULT($fu_cv_sys_mounted_getmntent2)
98 if test $fu_cv_sys_mounted_getmntent2 = yes; then
99 ac_list_mounted_fs=found
100 AC_DEFINE(MOUNTED_GETMNTENT2, 1,
101 [Define if there is a function named getmntent for reading the list of
102 mounted filesystems, and that function takes two arguments. (SVR4)])
106 if test -z "$ac_list_mounted_fs"; then
107 AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
112 if test -z "$ac_list_mounted_fs"; then
113 # DEC Alpha running OSF/1.
114 AC_MSG_CHECKING([for getfsstat function])
115 AC_CACHE_VAL(fu_cv_sys_mounted_getsstat,
117 #include <sys/types.h>
118 #include <sys/mount.h>
119 #include <sys/fs_types.h>],
120 [struct statfs *stats;
121 int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); ],
122 fu_cv_sys_mounted_getsstat=yes,
123 fu_cv_sys_mounted_getsstat=no)])
124 AC_MSG_RESULT($fu_cv_sys_mounted_getsstat)
125 if test $fu_cv_sys_mounted_getsstat = yes; then
126 ac_list_mounted_fs=found
127 AC_DEFINE(MOUNTED_GETFSSTAT, 1,
128 [Define if there is a function named getfsstat for reading the
129 list of mounted filesystems. (DEC Alpha running OSF/1)])
133 if test -z "$ac_list_mounted_fs"; then
135 AC_MSG_CHECKING([for mntctl function and struct vmount])
136 AC_CACHE_VAL(fu_cv_sys_mounted_vmount,
137 [AC_TRY_CPP([#include <fshelp.h>],
138 fu_cv_sys_mounted_vmount=yes,
139 fu_cv_sys_mounted_vmount=no)])
140 AC_MSG_RESULT($fu_cv_sys_mounted_vmount)
141 if test $fu_cv_sys_mounted_vmount = yes; then
142 ac_list_mounted_fs=found
143 AC_DEFINE(MOUNTED_VMOUNT, 1,
144 [Define if there is a function named mntctl that can be used to read
145 the list of mounted filesystems, and there is a system header file
146 that declares `struct vmount.' (AIX)])
150 if test -z "$ac_list_mounted_fs"; then
152 AC_MSG_CHECKING([for FIXME existence of three headers])
153 AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp,
155 #include <sys/statfs.h>
156 #include <sys/fstyp.h>
157 #include <mnttab.h>],
158 fu_cv_sys_mounted_fread_fstyp=yes,
159 fu_cv_sys_mounted_fread_fstyp=no)])
160 AC_MSG_RESULT($fu_cv_sys_mounted_fread_fstyp)
161 if test $fu_cv_sys_mounted_fread_fstyp = yes; then
162 ac_list_mounted_fs=found
163 AC_DEFINE(MOUNTED_FREAD_FSTYP, 1,
164 [Define if (like SVR2) there is no specific function for reading the
165 list of mounted filesystems, and your system has these header files:
166 <sys/fstyp.h> and <sys/statfs.h>. (SVR3)])
170 if test -z "$ac_list_mounted_fs"; then
171 # 4.4BSD and DEC OSF/1.
172 AC_MSG_CHECKING([for getmntinfo function])
173 AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo,
176 if test $ac_cv_func_getmntinfo = yes; then
177 AC_EGREP_HEADER(f_type;, sys/mount.h,
181 && fu_cv_sys_mounted_getmntinfo=yes \
182 || fu_cv_sys_mounted_getmntinfo=no
184 AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo)
185 if test $fu_cv_sys_mounted_getmntinfo = yes; then
186 ac_list_mounted_fs=found
187 AC_DEFINE(MOUNTED_GETMNTINFO, 1,
188 [Define if there is a function named getmntinfo for reading the
189 list of mounted filesystems. (4.4BSD)])
193 if test -z "$ac_list_mounted_fs"; then
195 AC_MSG_CHECKING([for getmnt function])
196 AC_CACHE_VAL(fu_cv_sys_mounted_getmnt,
198 #include <sys/fs_types.h>
199 #include <sys/mount.h>],
200 fu_cv_sys_mounted_getmnt=yes,
201 fu_cv_sys_mounted_getmnt=no)])
202 AC_MSG_RESULT($fu_cv_sys_mounted_getmnt)
203 if test $fu_cv_sys_mounted_getmnt = yes; then
204 ac_list_mounted_fs=found
205 AC_DEFINE(MOUNTED_GETMNT, 1,
206 [Define if there is a function named getmnt for reading the list of
207 mounted filesystems. (Ultrix)])
211 if test -z "$ac_list_mounted_fs"; then
213 AC_CHECK_FUNCS(next_dev fs_stat_dev)
214 AC_CHECK_HEADERS(fs_info.h)
215 AC_MSG_CHECKING([for BEOS mounted file system support functions])
216 if test $ac_cv_header_fs_info_h = yes \
217 && test $ac_cv_func_next_dev = yes \
218 && test $ac_cv_func_fs_stat_dev = yes; then
223 AC_MSG_RESULT($fu_result)
224 if test $fu_result = yes; then
225 ac_list_mounted_fs=found
226 AC_DEFINE(MOUNTED_FS_STAT_DEV, 1,
227 [Define if there are functions named next_dev and fs_stat_dev for
228 reading the list of mounted filesystems. (BeOS)])
232 if test -z "$ac_list_mounted_fs"; then
234 AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
235 AC_CACHE_VAL(fu_cv_sys_mounted_fread,
236 [AC_TRY_CPP([#include <mnttab.h>],
237 fu_cv_sys_mounted_fread=yes,
238 fu_cv_sys_mounted_fread=no)])
239 AC_MSG_RESULT($fu_cv_sys_mounted_fread)
240 if test $fu_cv_sys_mounted_fread = yes; then
241 ac_list_mounted_fs=found
242 AC_DEFINE(MOUNTED_FREAD, 1,
243 [Define if there is no specific function for reading the list of
244 mounted filesystems. fread will be used to read /etc/mnttab. (SVR2) ])
248 if test -z "$ac_list_mounted_fs"; then
249 AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
250 # FIXME -- no need to abort building the whole package
251 # Can't build mountlist.c or anything that needs its functions
254 AS_IF([test $ac_list_mounted_fs = found], [$1], [$2])