2 dnl Copyright (C) 2002-2006, 2009-2020 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
11 AC_DEFUN([gl_MOUNTLIST],
13 AC_REQUIRE([AC_CANONICAL_HOST])
14 AC_CHECK_FUNCS([listmntent])
15 AC_CHECK_HEADERS_ONCE([sys/param.h sys/statvfs.h])
17 # We must include grp.h before ucred.h on OSF V4.0, since ucred.h uses
18 # NGROUPS (as the array dimension for a struct member) without a definition.
19 AC_CHECK_HEADERS([sys/ucred.h], [], [], [#include <grp.h>])
21 AC_CHECK_HEADERS([sys/mount.h], [], [],
24 #include <sys/param.h>
28 AC_CHECK_HEADERS([mntent.h sys/fs_types.h])
32 # include <sys/param.h> /* needed by powerpc-apple-darwin1.3.7 */
35 # include <grp.h> /* needed for definition of NGROUPS */
36 # include <sys/ucred.h> /* needed by powerpc-apple-darwin1.3.7 */
39 # include <sys/mount.h>
41 #if HAVE_SYS_FS_TYPES_H
42 # include <sys/fs_types.h> /* needed by powerpc-apple-darwin1.3.7 */
45 AC_CHECK_MEMBERS([struct fsstat.f_fstypename],,,[$getfsstat_includes])
47 # Determine how to get the list of mounted file systems.
50 # If the getmntent function is available but not in the standard library,
51 # make sure LIBS contains the appropriate -l option.
54 if test -z "$ac_list_mounted_fs"; then
56 AC_CACHE_CHECK([for mntctl function and struct vmount],
57 [fu_cv_sys_mounted_vmount],
58 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <fshelp.h>]])],
59 [fu_cv_sys_mounted_vmount=yes],
60 [fu_cv_sys_mounted_vmount=no])])
61 if test $fu_cv_sys_mounted_vmount = yes; then
62 ac_list_mounted_fs=found
63 AC_DEFINE([MOUNTED_VMOUNT], [1],
64 [Define if there is a function named mntctl that can be used to read
65 the list of mounted file systems, and there is a system header file
66 that declares 'struct vmount'. (AIX)])
70 if test $ac_cv_func_getmntent = yes; then
72 # This system has the getmntent function.
73 # Determine whether it's the one-argument variant or the two-argument one.
75 if test -z "$ac_list_mounted_fs"; then
76 # glibc, HP-UX, IRIX, Cygwin, Android, also (obsolete) 4.3BSD, SunOS.
77 AC_CACHE_CHECK([for one-argument getmntent function],
78 [fu_cv_sys_mounted_getmntent1],
81 /* SunOS 4.1.x /usr/include/mntent.h needs this for FILE */
85 #if defined __ANDROID__ /* Android */
87 # define MOUNTED "/proc/mounts"
88 #elif !defined MOUNTED
89 # if defined _PATH_MOUNTED /* GNU libc */
90 # define MOUNTED _PATH_MOUNTED
92 # if defined MNT_MNTTAB /* HP-UX. */
93 # define MOUNTED MNT_MNTTAB
97 [[struct mntent *mnt = 0; char *table = MOUNTED;
98 if (sizeof mnt && sizeof table) return 0;
100 [fu_cv_sys_mounted_getmntent1=yes],
101 [fu_cv_sys_mounted_getmntent1=no])
103 if test $fu_cv_sys_mounted_getmntent1 = yes; then
104 ac_list_mounted_fs=found
105 AC_DEFINE([MOUNTED_GETMNTENT1], [1],
106 [Define if there is a function named getmntent for reading the list
107 of mounted file systems, and that function takes a single argument.
108 (4.3BSD, SunOS, HP-UX, Irix)])
109 AC_CHECK_FUNCS([setmntent endmntent hasmntopt])
113 if test -z "$ac_list_mounted_fs"; then
115 AC_CACHE_CHECK([for getextmntent function],
116 [fu_cv_sys_mounted_getextmntent],
117 [AC_EGREP_HEADER([getextmntent], [sys/mnttab.h],
118 [fu_cv_sys_mounted_getextmntent=yes],
119 [fu_cv_sys_mounted_getextmntent=no])])
120 if test $fu_cv_sys_mounted_getextmntent = yes; then
121 ac_list_mounted_fs=found
122 AC_DEFINE([MOUNTED_GETEXTMNTENT], [1],
123 [Define if there is a function named getextmntent for reading the list
124 of mounted file systems. (Solaris)])
128 if test -z "$ac_list_mounted_fs"; then
129 # Solaris < 8, also (obsolete) SVR4.
130 # Solaris >= 8 has the two-argument getmntent but is already handled above.
131 AC_CACHE_CHECK([for two-argument getmntent function],
132 [fu_cv_sys_mounted_getmntent2],
133 [AC_EGREP_HEADER([getmntent], [sys/mnttab.h],
134 [fu_cv_sys_mounted_getmntent2=yes],
135 [fu_cv_sys_mounted_getmntent2=no])
137 if test $fu_cv_sys_mounted_getmntent2 = yes; then
138 ac_list_mounted_fs=found
139 AC_DEFINE([MOUNTED_GETMNTENT2], [1],
140 [Define if there is a function named getmntent for reading the list of
141 mounted file systems, and that function takes two arguments. (SVR4)])
142 AC_CHECK_FUNCS([hasmntopt])
148 if test -z "$ac_list_mounted_fs"; then
149 # OSF/1, also (obsolete) Apple Darwin 1.3.
150 # powerpc-apple-darwin1.3.7 needs sys/param.h sys/ucred.h sys/fs_types.h
152 AC_CACHE_CHECK([for getfsstat function],
153 [fu_cv_sys_mounted_getfsstat],
156 #include <sys/types.h>
157 #if HAVE_STRUCT_FSSTAT_F_FSTYPENAME
158 # define FS_TYPE(Ent) ((Ent).f_fstypename)
160 # define FS_TYPE(Ent) mnt_names[(Ent).f_type]
164 [[struct statfs *stats;
165 int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT);
166 char *t = FS_TYPE (*stats);
168 [fu_cv_sys_mounted_getfsstat=yes],
169 [fu_cv_sys_mounted_getfsstat=no])
171 if test $fu_cv_sys_mounted_getfsstat = yes; then
172 ac_list_mounted_fs=found
173 AC_DEFINE([MOUNTED_GETFSSTAT], [1],
174 [Define if there is a function named getfsstat for reading the
175 list of mounted file systems. (DEC Alpha running OSF/1)])
179 if test -z "$ac_list_mounted_fs"; then
181 AC_CACHE_CHECK([for FIXME existence of three headers],
182 [fu_cv_sys_mounted_fread_fstyp],
183 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
184 #include <sys/statfs.h>
185 #include <sys/fstyp.h>
188 [fu_cv_sys_mounted_fread_fstyp=yes],
189 [fu_cv_sys_mounted_fread_fstyp=no])
191 if test $fu_cv_sys_mounted_fread_fstyp = yes; then
192 ac_list_mounted_fs=found
193 AC_DEFINE([MOUNTED_FREAD_FSTYP], [1],
194 [Define if (like SVR2) there is no specific function for reading the
195 list of mounted file systems, and your system has these header files:
196 <sys/fstyp.h> and <sys/statfs.h>. (SVR3)])
200 if test -z "$ac_list_mounted_fs"; then
201 # Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix, also (obsolete) 4.4BSD.
202 # OSF/1 also has getmntinfo but is already handled above.
203 # We cannot use AC_CHECK_FUNCS([getmntinfo]) here, because at the linker
204 # level the function is sometimes called getmntinfo64 or getmntinfo$INODE64
205 # on Mac OS X, __getmntinfo13 on NetBSD and Minix, _F64_getmntinfo on OSF/1.
206 AC_CACHE_CHECK([for getmntinfo function],
207 [fu_cv_sys_mounted_getmntinfo],
211 # include <sys/param.h>
213 #include <sys/types.h>
215 # include <sys/mount.h>
217 #if HAVE_SYS_STATVFS_H
218 # include <sys/statvfs.h>
222 [[int count = getmntinfo (NULL, MNT_WAIT);
224 [fu_cv_sys_mounted_getmntinfo=yes],
225 [fu_cv_sys_mounted_getmntinfo=no])
227 if test $fu_cv_sys_mounted_getmntinfo = yes; then
228 AC_CACHE_CHECK([whether getmntinfo returns statvfs structures],
229 [fu_cv_sys_mounted_getmntinfo2],
233 # include <sys/param.h>
235 #include <sys/types.h>
237 # include <sys/mount.h>
239 #if HAVE_SYS_STATVFS_H
240 # include <sys/statvfs.h>
246 int getmntinfo (struct statfs **, int);
248 [fu_cv_sys_mounted_getmntinfo2=no],
249 [fu_cv_sys_mounted_getmntinfo2=yes])
251 if test $fu_cv_sys_mounted_getmntinfo2 = no; then
252 # Mac OS X, FreeBSD, OpenBSD, also (obsolete) 4.4BSD.
253 ac_list_mounted_fs=found
254 AC_DEFINE([MOUNTED_GETMNTINFO], [1],
255 [Define if there is a function named getmntinfo for reading the
256 list of mounted file systems and it returns an array of
257 'struct statfs'. (4.4BSD, Darwin)])
260 ac_list_mounted_fs=found
261 AC_DEFINE([MOUNTED_GETMNTINFO2], [1],
262 [Define if there is a function named getmntinfo for reading the
263 list of mounted file systems and it returns an array of
264 'struct statvfs'. (NetBSD 3.0)])
269 if test -z "$ac_list_mounted_fs"; then
270 # Haiku, also (obsolete) BeOS.
271 AC_CHECK_FUNCS([next_dev fs_stat_dev])
272 AC_CHECK_HEADERS([fs_info.h])
273 AC_CACHE_CHECK([for BEOS mounted file system support functions],
274 [fu_cv_sys_mounted_fs_stat_dev],
275 [if test $ac_cv_header_fs_info_h = yes \
276 && test $ac_cv_func_next_dev = yes \
277 && test $ac_cv_func_fs_stat_dev = yes; then
278 fu_cv_sys_mounted_fs_stat_dev=yes
280 fu_cv_sys_mounted_fs_stat_dev=no
283 if test $fu_cv_sys_mounted_fs_stat_dev = yes; then
284 ac_list_mounted_fs=found
285 AC_DEFINE([MOUNTED_FS_STAT_DEV], [1],
286 [Define if there are functions named next_dev and fs_stat_dev for
287 reading the list of mounted file systems. (BeOS)])
291 if test -z "$ac_list_mounted_fs"; then
292 # Interix / BSD alike statvfs
293 # the code is really interix specific, so make sure, we're on it.
296 AC_CHECK_FUNCS([statvfs])
297 if test $ac_cv_func_statvfs = yes; then
298 ac_list_mounted_fs=found
299 AC_DEFINE([MOUNTED_INTERIX_STATVFS], [1],
300 [Define if we are on interix, and ought to use statvfs plus
301 some special knowledge on where mounted file systems can be
308 if test -z "$ac_list_mounted_fs"; then
309 AC_MSG_ERROR([could not determine how to read list of mounted file systems])
310 # FIXME -- no need to abort building the whole package
311 # Can't build mountlist.c or anything that needs its functions
314 if test $ac_list_mounted_fs = found; then
315 gl_cv_list_mounted_fs=yes
317 gl_cv_list_mounted_fs=no
321 # Prerequisites of lib/mountlist.c not done by gl_MOUNTLIST.
322 AC_DEFUN([gl_PREREQ_MOUNTLIST_EXTRA],
324 dnl Note gl_MOUNTLIST checks for mntent.h, not sys/mntent.h.
325 AC_CHECK_HEADERS([sys/mntent.h])
326 AC_HEADER_MAJOR()dnl for use of makedev ()
330 # Replace Autoconf's AC_FUNC_GETMNTENT to omit checks that are unnecessary
332 AC_DEFUN([AC_FUNC_GETMNTENT],
334 # getmntent is in the standard C library on UNICOS, in -lsun on Irix 4,
336 AC_SEARCH_LIBS([getmntent], [sun gen])
337 AC_CHECK_FUNCS([getmntent])