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 AC_DEFUN(jm_LIST_MOUNTED_FILESYSTEMS,
18 # Determine how to get the list of mounted filesystems.
21 # If the getmntent function is available but not in the standard library,
22 # make sure LIBS contains -lsun (on Irix4) or -lseq (on PTX).
25 # This test must precede the ones for getmntent because Unicos-9 is
26 # reported to have the getmntent function, but its support is incompatible
27 # with other getmntent implementations.
29 # NOTE: Normally, I wouldn't use a check for system type as I've done for
30 # `CRAY' below since that goes against the whole autoconf philosophy. But
31 # I think there is too great a chance that some non-Cray system has a
32 # function named listmntent to risk the false positive.
34 if test -z "$list_mounted_fs"; then
36 AC_MSG_CHECKING([for listmntent of Cray/Unicos-9])
37 AC_CACHE_VAL(fu_cv_sys_mounted_cray_listmntent,
38 [fu_cv_sys_mounted_cray_listmntent=no
43 ], [test $ac_cv_func_listmntent = yes \
44 && fu_cv_sys_mounted_cray_listmntent=yes]
48 AC_MSG_RESULT($fu_cv_sys_mounted_cray_listmntent)
49 if test $fu_cv_sys_mounted_cray_listmntent = yes; then
51 AC_DEFINE(MOUNTED_LISTMNTENT, 1,
52 [Define if there is a function named listmntent that can be used to
53 list all mounted filesystems. (UNICOS)])
57 if test $ac_cv_func_getmntent = yes; then
59 # This system has the getmntent function.
60 # Determine whether it's the one-argument variant or the two-argument one.
62 if test -z "$list_mounted_fs"; then
63 # 4.3BSD, SunOS, HP-UX, Dynix, Irix
64 AC_MSG_CHECKING([for one-argument getmntent function])
65 AC_CACHE_VAL(fu_cv_sys_mounted_getmntent1,
66 [test $ac_cv_header_mntent_h = yes \
67 && fu_cv_sys_mounted_getmntent1=yes \
68 || fu_cv_sys_mounted_getmntent1=no])
69 AC_MSG_RESULT($fu_cv_sys_mounted_getmntent1)
70 if test $fu_cv_sys_mounted_getmntent1 = yes; then
72 AC_DEFINE(MOUNTED_GETMNTENT1, 1,
73 [Define if there is a function named getmntent for reading the list
74 of mounted filesystems, and that function takes a single argument.
75 (4.3BSD, SunOS, HP-UX, Dynix, Irix)])
79 if test -z "$list_mounted_fs"; then
81 AC_MSG_CHECKING([for two-argument getmntent function])
82 AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2,
83 [AC_EGREP_HEADER(getmntent, sys/mnttab.h,
84 fu_cv_sys_mounted_getmntent2=yes,
85 fu_cv_sys_mounted_getmntent2=no)])
86 AC_MSG_RESULT($fu_cv_sys_mounted_getmntent2)
87 if test $fu_cv_sys_mounted_getmntent2 = yes; then
89 AC_DEFINE(MOUNTED_GETMNTENT2, 1,
90 [Define if there is a function named getmntent for reading the list of
91 mounted filesystems, and that function takes two arguments. (SVR4)])
95 if test -z "$list_mounted_fs"; then
96 AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
101 if test -z "$list_mounted_fs"; then
102 # DEC Alpha running OSF/1.
103 AC_MSG_CHECKING([for getfsstat function])
104 AC_CACHE_VAL(fu_cv_sys_mounted_getsstat,
106 #include <sys/types.h>
107 #include <sys/mount.h>
108 #include <sys/fs_types.h>],
109 [struct statfs *stats;
110 int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); ],
111 fu_cv_sys_mounted_getsstat=yes,
112 fu_cv_sys_mounted_getsstat=no)])
113 AC_MSG_RESULT($fu_cv_sys_mounted_getsstat)
114 if test $fu_cv_sys_mounted_getsstat = yes; then
115 list_mounted_fs=found
116 AC_DEFINE(MOUNTED_GETFSSTAT, 1,
117 [Define if there is a function named getfsstat for reading the
118 list of mounted filesystems. (DEC Alpha running OSF/1)])
122 if test -z "$list_mounted_fs"; then
124 AC_MSG_CHECKING([for mntctl function and struct vmount])
125 AC_CACHE_VAL(fu_cv_sys_mounted_vmount,
126 [AC_TRY_CPP([#include <fshelp.h>],
127 fu_cv_sys_mounted_vmount=yes,
128 fu_cv_sys_mounted_vmount=no)])
129 AC_MSG_RESULT($fu_cv_sys_mounted_vmount)
130 if test $fu_cv_sys_mounted_vmount = yes; then
131 list_mounted_fs=found
132 AC_DEFINE(MOUNTED_VMOUNT, 1,
133 [Define if there is a function named mntctl that can be used to read
134 the list of mounted filesystems, and there is a system header file
135 that declares `struct vmount.' (AIX)])
139 if test -z "$list_mounted_fs"; then
141 AC_MSG_CHECKING([for FIXME existence of three headers])
142 AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp,
144 #include <sys/statfs.h>
145 #include <sys/fstyp.h>
146 #include <mnttab.h>],
147 fu_cv_sys_mounted_fread_fstyp=yes,
148 fu_cv_sys_mounted_fread_fstyp=no)])
149 AC_MSG_RESULT($fu_cv_sys_mounted_fread_fstyp)
150 if test $fu_cv_sys_mounted_fread_fstyp = yes; then
151 list_mounted_fs=found
152 AC_DEFINE(MOUNTED_FREAD_FSTYP, 1,
153 [Define if (like SVR2) there is no specific function for reading the
154 list of mounted filesystems, and your system has these header files:
155 <sys/fstyp.h> and <sys/statfs.h>. (SVR3)])
159 if test -z "$list_mounted_fs"; then
160 # 4.4BSD and DEC OSF/1.
161 AC_MSG_CHECKING([for getmntinfo function])
162 AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo,
165 if test $ac_cv_func_getmntinfo = yes; then
166 AC_EGREP_HEADER(f_type;, sys/mount.h,
170 && fu_cv_sys_mounted_getmntinfo=yes \
171 || fu_cv_sys_mounted_getmntinfo=no
173 AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo)
174 if test $fu_cv_sys_mounted_getmntinfo = yes; then
175 list_mounted_fs=found
176 AC_DEFINE(MOUNTED_GETMNTINFO, 1,
177 [Define if there is a function named getmntinfo for reading the
178 list of mounted filesystems. (4.4BSD)])
182 # FIXME: add a test for netbsd-1.1 here
184 if test -z "$list_mounted_fs"; then
186 AC_MSG_CHECKING([for getmnt function])
187 AC_CACHE_VAL(fu_cv_sys_mounted_getmnt,
189 #include <sys/fs_types.h>
190 #include <sys/mount.h>],
191 fu_cv_sys_mounted_getmnt=yes,
192 fu_cv_sys_mounted_getmnt=no)])
193 AC_MSG_RESULT($fu_cv_sys_mounted_getmnt)
194 if test $fu_cv_sys_mounted_getmnt = yes; then
195 list_mounted_fs=found
196 AC_DEFINE(MOUNTED_GETMNT, 1,
197 [Define if there is a function named getmnt for reading the list of
198 mounted filesystems. (Ultrix)])
202 if test -z "$list_mounted_fs"; then
204 AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
205 AC_CACHE_VAL(fu_cv_sys_mounted_fread,
206 [AC_TRY_CPP([#include <mnttab.h>],
207 fu_cv_sys_mounted_fread=yes,
208 fu_cv_sys_mounted_fread=no)])
209 AC_MSG_RESULT($fu_cv_sys_mounted_fread)
210 if test $fu_cv_sys_mounted_fread = yes; then
211 list_mounted_fs=found
212 AC_DEFINE(MOUNTED_FREAD, 1,
213 [Define if there is no specific function for reading the list of
214 mounted filesystems. fread will be used to read /etc/mnttab. (SVR2) ])
218 if test -z "$list_mounted_fs"; then
219 AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
220 # FIXME -- no need to abort building the whole package
221 # Can't build mountlist.c or anything that needs its functions