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.
14 AC_DEFUN(jm_LIST_MOUNTED_FILESYSTEMS,
16 # Determine how to get the list of mounted filesystems.
19 # If the getmntent function is available but not in the standard library,
20 # make sure LIBS contains -lsun (on Irix4) or -lseq (on PTX).
23 # This test must precede the ones for getmntent because Unicos-9 is
24 # reported to have the getmntent function, but its support is incompatible
25 # with other getmntent implementations.
27 # NOTE: Normally, I wouldn't use a check for system type as I've done for
28 # `CRAY' below since that goes against the whole autoconf philosophy. But
29 # I think there is too great a chance that some non-Cray system has a
30 # function named listmntent to risk the false positive.
32 if test -z "$list_mounted_fs"; then
34 AC_MSG_CHECKING([for listmntent of Cray/Unicos-9])
35 AC_CACHE_VAL(fu_cv_sys_mounted_cray_listmntent,
36 [fu_cv_sys_mounted_cray_listmntent=no
41 ], [test $ac_cv_func_listmntent = yes \
42 && fu_cv_sys_mounted_cray_listmntent=yes]
46 AC_MSG_RESULT($fu_cv_sys_mounted_cray_listmntent)
47 if test $fu_cv_sys_mounted_cray_listmntent = yes; then
49 AC_DEFINE(MOUNTED_LISTMNTENT, 1,
50 [Define if there is a function named listmntent that can be used to
51 list all mounted filesystems. (UNICOS)])
55 if test $ac_cv_func_getmntent = yes; then
57 # This system has the getmntent function.
58 # Determine whether it's the one-argument variant or the two-argument one.
60 if test -z "$list_mounted_fs"; then
61 # 4.3BSD, SunOS, HP-UX, Dynix, Irix
62 AC_MSG_CHECKING([for one-argument getmntent function])
63 AC_CACHE_VAL(fu_cv_sys_mounted_getmntent1,
64 [test $ac_cv_header_mntent_h = yes \
65 && fu_cv_sys_mounted_getmntent1=yes \
66 || fu_cv_sys_mounted_getmntent1=no])
67 AC_MSG_RESULT($fu_cv_sys_mounted_getmntent1)
68 if test $fu_cv_sys_mounted_getmntent1 = yes; then
70 AC_DEFINE(MOUNTED_GETMNTENT1, 1,
71 [Define if there is a function named getmntent for reading the list
72 of mounted filesystems, and that function takes a single argument.
73 (4.3BSD, SunOS, HP-UX, Dynix, Irix)])
77 if test -z "$list_mounted_fs"; then
79 AC_MSG_CHECKING([for two-argument getmntent function])
80 AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2,
81 [AC_EGREP_HEADER(getmntent, sys/mnttab.h,
82 fu_cv_sys_mounted_getmntent2=yes,
83 fu_cv_sys_mounted_getmntent2=no)])
84 AC_MSG_RESULT($fu_cv_sys_mounted_getmntent2)
85 if test $fu_cv_sys_mounted_getmntent2 = yes; then
87 AC_DEFINE(MOUNTED_GETMNTENT2, 1,
88 [Define if there is a function named getmntent for reading the list of
89 mounted filesystems, and that function takes two arguments. (SVR4)])
93 if test -z "$list_mounted_fs"; then
94 AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
99 if test -z "$list_mounted_fs"; then
100 # DEC Alpha running OSF/1.
101 AC_MSG_CHECKING([for getfsstat function])
102 AC_CACHE_VAL(fu_cv_sys_mounted_getsstat,
104 #include <sys/types.h>
105 #include <sys/mount.h>
106 #include <sys/fs_types.h>],
107 [struct statfs *stats;
108 int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); ],
109 fu_cv_sys_mounted_getsstat=yes,
110 fu_cv_sys_mounted_getsstat=no)])
111 AC_MSG_RESULT($fu_cv_sys_mounted_getsstat)
112 if test $fu_cv_sys_mounted_getsstat = yes; then
113 list_mounted_fs=found
114 AC_DEFINE(MOUNTED_GETFSSTAT, 1,
115 [Define if there is a function named getfsstat for reading the
116 list of mounted filesystems. (DEC Alpha running OSF/1)])
120 if test -z "$list_mounted_fs"; then
122 AC_MSG_CHECKING([for mntctl function and struct vmount])
123 AC_CACHE_VAL(fu_cv_sys_mounted_vmount,
124 [AC_TRY_CPP([#include <fshelp.h>],
125 fu_cv_sys_mounted_vmount=yes,
126 fu_cv_sys_mounted_vmount=no)])
127 AC_MSG_RESULT($fu_cv_sys_mounted_vmount)
128 if test $fu_cv_sys_mounted_vmount = yes; then
129 list_mounted_fs=found
130 AC_DEFINE(MOUNTED_VMOUNT, 1,
131 [Define if there is a function named mntctl that can be used to read
132 the list of mounted filesystems, and there is a system header file
133 that declares \`struct vmount.' (AIX)])
137 if test -z "$list_mounted_fs"; then
139 AC_MSG_CHECKING([for FIXME existence of three headers])
140 AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp,
142 #include <sys/statfs.h>
143 #include <sys/fstyp.h>
144 #include <mnttab.h>],
145 fu_cv_sys_mounted_fread_fstyp=yes,
146 fu_cv_sys_mounted_fread_fstyp=no)])
147 AC_MSG_RESULT($fu_cv_sys_mounted_fread_fstyp)
148 if test $fu_cv_sys_mounted_fread_fstyp = yes; then
149 list_mounted_fs=found
150 AC_DEFINE(MOUNTED_FREAD_FSTYP, 1,
151 [Define if (like SVR2) there is no specific function for reading the
152 list of mounted filesystems, and your system has these header files:
153 <sys/fstyp.h> and <sys/statfs.h>. (SVR3)])
157 if test -z "$list_mounted_fs"; then
158 # 4.4BSD and DEC OSF/1.
159 AC_MSG_CHECKING([for getmntinfo function])
160 AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo,
163 if test $ac_cv_func_getmntinfo = yes; then
164 AC_EGREP_HEADER(f_type;, sys/mount.h,
168 && fu_cv_sys_mounted_getmntinfo=yes \
169 || fu_cv_sys_mounted_getmntinfo=no
171 AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo)
172 if test $fu_cv_sys_mounted_getmntinfo = yes; then
173 list_mounted_fs=found
174 AC_DEFINE(MOUNTED_GETMNTINFO, 1,
175 [Define if there is a function named getmntinfo for reading the
176 list of mounted filesystems. (4.4BSD)])
180 # FIXME: add a test for netbsd-1.1 here
182 if test -z "$list_mounted_fs"; then
184 AC_MSG_CHECKING([for getmnt function])
185 AC_CACHE_VAL(fu_cv_sys_mounted_getmnt,
187 #include <sys/fs_types.h>
188 #include <sys/mount.h>],
189 fu_cv_sys_mounted_getmnt=yes,
190 fu_cv_sys_mounted_getmnt=no)])
191 AC_MSG_RESULT($fu_cv_sys_mounted_getmnt)
192 if test $fu_cv_sys_mounted_getmnt = yes; then
193 list_mounted_fs=found
194 AC_DEFINE(MOUNTED_GETMNT, 1,
195 [Define if there is a function named getmnt for reading the list of
196 mounted filesystems. (Ultrix)])
200 if test -z "$list_mounted_fs"; then
202 AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
203 AC_CACHE_VAL(fu_cv_sys_mounted_fread,
204 [AC_TRY_CPP([#include <mnttab.h>],
205 fu_cv_sys_mounted_fread=yes,
206 fu_cv_sys_mounted_fread=no)])
207 AC_MSG_RESULT($fu_cv_sys_mounted_fread)
208 if test $fu_cv_sys_mounted_fread = yes; then
209 list_mounted_fs=found
210 AC_DEFINE(MOUNTED_FREAD, 1,
211 [Define if there is no specific function for reading the list of
212 mounted filesystems. fread will be used to read /etc/mnttab. (SVR2) ])
216 if test -z "$list_mounted_fs"; then
217 AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
218 # FIXME -- no need to abort building the whole package
219 # Can't build mountlist.c or anything that needs its functions