xref: /netbsd-src/external/bsd/am-utils/dist/m4/macros/func_bad_hasmntopt.m4 (revision a53f50b9b44dc9467ccc9c464999b1d1c509cb0c)
1dnl ######################################################################
2dnl Check if we have as buggy hasmntopt() libc function
3AC_DEFUN([AMU_FUNC_BAD_HASMNTOPT],
4[
5AC_CACHE_CHECK([for working hasmntopt], ac_cv_func_hasmntopt_working,
6[AC_TRY_RUN(
7AMU_MOUNT_HEADERS(
8[[
9#ifdef HAVE_MNTENT_H
10/* some systems need <stdio.h> before <mntent.h> is included */
11# ifdef HAVE_STDIO_H
12#  include <stdio.h>
13# endif /* HAVE_STDIO_H */
14# include <mntent.h>
15#endif /* HAVE_MNTENT_H */
16#ifdef HAVE_SYS_MNTENT_H
17# include <sys/mntent.h>
18#endif /* HAVE_SYS_MNTENT_H */
19#ifdef HAVE_SYS_MNTTAB_H
20# include <sys/mnttab.h>
21#endif /* HAVE_SYS_MNTTAB_H */
22#if defined(HAVE_MNTTAB_H) && !defined(MNTTAB)
23# include <mnttab.h>
24#endif /* defined(HAVE_MNTTAB_H) && !defined(MNTTAB) */
25#ifdef HAVE_STRUCT_MNTENT
26typedef struct mntent mntent_t;
27#else /* not HAVE_STRUCT_MNTENT */
28# ifdef HAVE_STRUCT_MNTTAB
29typedef struct mnttab mntent_t;
30/* map struct mnttab field names to struct mntent field names */
31#  define mnt_opts	mnt_mntopts
32# endif /* not HAVE_STRUCT_MNTTAB */
33#endif /* not HAVE_STRUCT_MNTENT */
34
35int main()
36{
37  mntent_t mnt;
38  char *tmp = NULL;
39
40 /*
41  * Test if hasmntopt will incorrectly find the string "soft", which
42  * is part of the large "softlookup" function.
43  */
44  mnt.mnt_opts = "hard,softlookup,ro";
45
46  if ((tmp = hasmntopt(&mnt, "soft")))
47    exit(1);
48  exit(0);
49}
50]]),
51	[ac_cv_func_hasmntopt_working=yes],
52	[ac_cv_func_hasmntopt_working=no]
53)])
54if test $ac_cv_func_hasmntopt_working = no
55then
56	AC_LIBOBJ([hasmntopt])
57 	AC_DEFINE(HAVE_BAD_HASMNTOPT)
58fi
59])
60