Hash :
b1c67ccf
Author :
Date :
2024-08-19T16:20:08
hasmntopt: New module. * lib/mntent.in.h: Add config.h check. (hasmntopt): New declaration. * lib/hasmntopt.c: New file, based on glibc/misc/mntent_r.c. * m4/hasmntopt.m4: New file. * m4/mntent_h.m4 (gl_MNTENT_H): Test whether hasmntopt is declared. (gl_MNTENT_H_REQUIRE_DEFAULTS): Initialize GNULIB_HASMNTOPT. (gl_MNTENT_H_DEFAULTS): Initialize HAVE_HASMNTOPT, HAVE_SETMNTENT, REPLACE_HASMNTOPT. * modules/mntent (Depends-on): Add snippet/arg-nonnull, snippet/c++defs, snippet/warn-on-use. (Makefile.am): Insert c++defs.h, arg-nonnull.h, warn-on-use.h into mntent.h. Substitute GNULIB_HASMNTOPT, HAVE_HASMNTOPT, HAVE_SETMNTENT, REPLACE_HASMNTOPT. * modules/hasmntopt: New file. * doc/glibc-functions/hasmntopt.texi: Mention the new module and the musl bug. * doc/glibc-functions/setmntent.texi: Update info about Android. * doc/glibc-functions/getmntent_r.texi: Likewise. * doc/glibc-functions/endmntent.texi: Likewise.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
# hasmntopt.m4
# serial 1
dnl Copyright (C) 2024 Free Software Foundation, Inc.
dnl
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_HASMNTOPT],
[
AC_REQUIRE([gl_MNTENT_H_DEFAULTS])
AC_REQUIRE([AC_CANONICAL_HOST])
gl_CHECK_FUNCS_ANDROID([setmntent],
[[#include <stdio.h>
#include <mntent.h>
]])
if test $ac_cv_func_setmntent != yes; then
HAVE_SETMNTENT=0
fi
gl_CHECK_FUNCS_ANDROID([hasmntopt],
[[#include <stdio.h>
#include <mntent.h>
]])
if test $ac_cv_func_hasmntopt = yes; then
dnl hasmntopt has the dumbest possible implementation on musl libc 1.2.5:
dnl it confuses the "atime" option with the "noatime" option.
AC_CACHE_CHECK([whether hasmntopt works],
[gl_cv_func_hasmntopt_works],
[AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[[#include <mntent.h>
#include <stddef.h>
]],
[[int result = 0;
/* This test fails on musl libc 1.2.5. */
{
char options[] = "rw,noatime";
struct mntent me;
me.mnt_opts = options;
if (hasmntopt (&me, "atime") != NULL)
result |= 1;
}
return result;
]])
],
[gl_cv_func_hasmntopt_works=yes],
[gl_cv_func_hasmntopt_works=no],
[case "$host_os" in
# Guess yes on glibc systems.
*-gnu* | gnu*) gl_cv_func_hasmntopt_works="guessing yes" ;;
# Guess no on musl systems.
*-musl* | midipix*) gl_cv_func_hasmntopt_works="guessing no" ;;
*) gl_cv_func_hasmntopt_works="$gl_cross_guess_normal" ;;
esac
])
])
case "$gl_cv_func_hasmntopt_works" in
*yes) ;;
*) REPLACE_HASMNTOPT=1 ;;
esac
else
HAVE_HASMNTOPT=0
case "$gl_cv_onwards_func_hasmntopt" in
future*) REPLACE_HASMNTOPT=1 ;;
esac
fi
])
# Prerequisites of lib/hasmntopt.c.
AC_DEFUN([gl_PREREQ_HASMNTOPT],
[
:
])