5 dnl This is not pretty. I've just taken the autoconf code and wrapped
11 # jm_LIST_MOUNTED_FILESYSTEMS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
12 AC_DEFUN(jm_LIST_MOUNTED_FILESYSTEMS,
14 AC_CHECK_FUNCS(listmntent getmntent getmntinfo)
15 AC_CHECK_HEADERS(mntent.h)
17 # Determine how to get the list of mounted filesystems.
20 # If the getmntent function is available but not in the standard library,
21 # make sure LIBS contains -lsun (on Irix4) or -lseq (on PTX).
24 # This test must precede the ones for getmntent because Unicos-9 is
25 # reported to have the getmntent function, but its support is incompatible
26 # with other getmntent implementations.
28 # NOTE: Normally, I wouldn't use a check for system type as I've done for
29 # `CRAY' below since that goes against the whole autoconf philosophy. But
30 # I think there is too great a chance that some non-Cray system has a
31 # function named listmntent to risk the false positive.
33 if test -z "$ac_list_mounted_fs"; then
35 AC_MSG_CHECKING([for listmntent of Cray/Unicos-9])
36 AC_CACHE_VAL(fu_cv_sys_mounted_cray_listmntent,
37 [fu_cv_sys_mounted_cray_listmntent=no
42 ], [test $ac_cv_func_listmntent = yes \
43 && fu_cv_sys_mounted_cray_listmntent=yes]
47 AC_MSG_RESULT($fu_cv_sys_mounted_cray_listmntent)
48 if test $fu_cv_sys_mounted_cray_listmntent = yes; then
49 ac_list_mounted_fs=found
50 AC_DEFINE(MOUNTED_LISTMNTENT, 1,
51 [Define if there is a function named listmntent that can be used to
52 list all mounted filesystems. (UNICOS)])
56 if test $ac_cv_func_getmntent = yes; then
58 # This system has the getmntent function.
59 # Determine whether it's the one-argument variant or the two-argument one.
61 if test -z "$ac_list_mounted_fs"; then
62 # 4.3BSD, SunOS, HP-UX, Dynix, Irix
63 AC_MSG_CHECKING([for one-argument getmntent function])
64 AC_CACHE_VAL(fu_cv_sys_mounted_getmntent1,
65 [test $ac_cv_header_mntent_h = yes \
66 && fu_cv_sys_mounted_getmntent1=yes \
67 || fu_cv_sys_mounted_getmntent1=no])
68 AC_MSG_RESULT($fu_cv_sys_mounted_getmntent1)
69 if test $fu_cv_sys_mounted_getmntent1 = yes; then
70 ac_list_mounted_fs=found
71 AC_DEFINE(MOUNTED_GETMNTENT1, 1,
72 [Define if there is a function named getmntent for reading the list
73 of mounted filesystems, and that function takes a single argument.
74 (4.3BSD, SunOS, HP-UX, Dynix, Irix)])
78 if test -z "$ac_list_mounted_fs"; then
80 AC_MSG_CHECKING([for two-argument getmntent function])
81 AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2,
82 [AC_EGREP_HEADER(getmntent, sys/mnttab.h,
83 fu_cv_sys_mounted_getmntent2=yes,
84 fu_cv_sys_mounted_getmntent2=no)])
85 AC_MSG_RESULT($fu_cv_sys_mounted_getmntent2)
86 if test $fu_cv_sys_mounted_getmntent2 = yes; then
87 ac_list_mounted_fs=found
88 AC_DEFINE(MOUNTED_GETMNTENT2, 1,
89 [Define if there is a function named getmntent for reading the list of
90 mounted filesystems, and that function takes two arguments. (SVR4)])
94 if test -z "$ac_list_mounted_fs"; then
95 AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
100 if test -z "$ac_list_mounted_fs"; then
101 # DEC Alpha running OSF/1.
102 AC_MSG_CHECKING([for getfsstat function])
103 AC_CACHE_VAL(fu_cv_sys_mounted_getsstat,
105 #include <sys/types.h>
106 #include <sys/mount.h>
107 #include <sys/fs_types.h>],
108 [struct statfs *stats;
109 int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); ],
110 fu_cv_sys_mounted_getsstat=yes,
111 fu_cv_sys_mounted_getsstat=no)])
112 AC_MSG_RESULT($fu_cv_sys_mounted_getsstat)
113 if test $fu_cv_sys_mounted_getsstat = yes; then
114 ac_list_mounted_fs=found
115 AC_DEFINE(MOUNTED_GETFSSTAT, 1,
116 [Define if there is a function named getfsstat for reading the
117 list of mounted filesystems. (DEC Alpha running OSF/1)])
121 if test -z "$ac_list_mounted_fs"; then
123 AC_MSG_CHECKING([for mntctl function and struct vmount])
124 AC_CACHE_VAL(fu_cv_sys_mounted_vmount,
125 [AC_TRY_CPP([#include <fshelp.h>],
126 fu_cv_sys_mounted_vmount=yes,
127 fu_cv_sys_mounted_vmount=no)])
128 AC_MSG_RESULT($fu_cv_sys_mounted_vmount)
129 if test $fu_cv_sys_mounted_vmount = yes; then
130 ac_list_mounted_fs=found
131 AC_DEFINE(MOUNTED_VMOUNT, 1,
132 [Define if there is a function named mntctl that can be used to read
133 the list of mounted filesystems, and there is a system header file
134 that declares `struct vmount.' (AIX)])
138 if test -z "$ac_list_mounted_fs"; then
140 AC_MSG_CHECKING([for FIXME existence of three headers])
141 AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp,
143 #include <sys/statfs.h>
144 #include <sys/fstyp.h>
145 #include <mnttab.h>],
146 fu_cv_sys_mounted_fread_fstyp=yes,
147 fu_cv_sys_mounted_fread_fstyp=no)])
148 AC_MSG_RESULT($fu_cv_sys_mounted_fread_fstyp)
149 if test $fu_cv_sys_mounted_fread_fstyp = yes; then
150 ac_list_mounted_fs=found
151 AC_DEFINE(MOUNTED_FREAD_FSTYP, 1,
152 [Define if (like SVR2) there is no specific function for reading the
153 list of mounted filesystems, and your system has these header files:
154 <sys/fstyp.h> and <sys/statfs.h>. (SVR3)])
158 if test -z "$ac_list_mounted_fs"; then
159 # 4.4BSD and DEC OSF/1.
160 AC_MSG_CHECKING([for getmntinfo function])
161 AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo,
164 if test $ac_cv_func_getmntinfo = yes; then
165 AC_EGREP_HEADER(f_type;, sys/mount.h,
169 && fu_cv_sys_mounted_getmntinfo=yes \
170 || fu_cv_sys_mounted_getmntinfo=no
172 AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo)
173 if test $fu_cv_sys_mounted_getmntinfo = yes; then
174 ac_list_mounted_fs=found
175 AC_DEFINE(MOUNTED_GETMNTINFO, 1,
176 [Define if there is a function named getmntinfo for reading the
177 list of mounted filesystems. (4.4BSD)])
181 if test -z "$ac_list_mounted_fs"; then
183 AC_MSG_CHECKING([for getmnt function])
184 AC_CACHE_VAL(fu_cv_sys_mounted_getmnt,
186 #include <sys/fs_types.h>
187 #include <sys/mount.h>],
188 fu_cv_sys_mounted_getmnt=yes,
189 fu_cv_sys_mounted_getmnt=no)])
190 AC_MSG_RESULT($fu_cv_sys_mounted_getmnt)
191 if test $fu_cv_sys_mounted_getmnt = yes; then
192 ac_list_mounted_fs=found
193 AC_DEFINE(MOUNTED_GETMNT, 1,
194 [Define if there is a function named getmnt for reading the list of
195 mounted filesystems. (Ultrix)])
199 if test -z "$ac_list_mounted_fs"; then
201 AC_CHECK_FUNCS(next_dev fs_stat_dev)
202 AC_CHECK_HEADERS(fs_info.h)
203 AC_MSG_CHECKING([for BEOS mounted file system support functions])
204 if test $ac_cv_header_fs_info_h = yes \
205 && test $ac_cv_func_next_dev = yes \
206 && test $ac_cv_func_fs_stat_dev = yes; then
211 AC_MSG_RESULT($fu_result)
212 if test $fu_result = yes; then
213 ac_list_mounted_fs=found
214 AC_DEFINE(MOUNTED_FS_STAT_DEV, 1,
215 [Define if there are functions named next_dev and fs_stat_dev for
216 reading the list of mounted filesystems. (BeOS)])
220 if test -z "$ac_list_mounted_fs"; then
222 AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
223 AC_CACHE_VAL(fu_cv_sys_mounted_fread,
224 [AC_TRY_CPP([#include <mnttab.h>],
225 fu_cv_sys_mounted_fread=yes,
226 fu_cv_sys_mounted_fread=no)])
227 AC_MSG_RESULT($fu_cv_sys_mounted_fread)
228 if test $fu_cv_sys_mounted_fread = yes; then
229 ac_list_mounted_fs=found
230 AC_DEFINE(MOUNTED_FREAD, 1,
231 [Define if there is no specific function for reading the list of
232 mounted filesystems. fread will be used to read /etc/mnttab. (SVR2) ])
236 if test -z "$ac_list_mounted_fs"; then
237 AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
238 # FIXME -- no need to abort building the whole package
239 # Can't build mountlist.c or anything that needs its functions
242 AS_IFELSE([test $ac_list_mounted_fs = found], [$1], [$2])dnl