| 1 |
# fstatat.m4 |
| 2 |
# serial 5 |
| 3 |
dnl Copyright (C) 2004-2024 Free Software Foundation, Inc. |
| 4 |
dnl This file is free software; the Free Software Foundation |
| 5 |
dnl gives unlimited permission to copy and/or distribute it, |
| 6 |
dnl with or without modifications, as long as this notice is preserved. |
| 7 |
dnl This file is offered as-is, without any warranty. |
| 8 |
|
| 9 |
# Written by Jim Meyering. |
| 10 |
|
| 11 |
# If we have the fstatat function, and it has the bug (in AIX 7.1) |
| 12 |
# that it does not fill in st_size correctly, use the replacement function. |
| 13 |
AC_DEFUN([gl_FUNC_FSTATAT], |
| 14 |
[ |
| 15 |
AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) |
| 16 |
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) |
| 17 |
AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK]) |
| 18 |
AC_REQUIRE([AC_CANONICAL_HOST]) |
| 19 |
AC_CHECK_FUNCS_ONCE([fstatat]) |
| 20 |
|
| 21 |
if test $ac_cv_func_fstatat = no; then |
| 22 |
HAVE_FSTATAT=0 |
| 23 |
else |
| 24 |
dnl Test for an AIX 7.1 bug; see |
| 25 |
dnl <https://lists.gnu.org/r/bug-tar/2011-09/msg00015.html>. |
| 26 |
AC_CACHE_CHECK([whether fstatat (..., 0) works], |
| 27 |
[gl_cv_func_fstatat_zero_flag], |
| 28 |
[AC_RUN_IFELSE( |
| 29 |
[AC_LANG_SOURCE( |
| 30 |
[[ |
| 31 |
#include <fcntl.h> |
| 32 |
#include <sys/stat.h> |
| 33 |
int |
| 34 |
main (void) |
| 35 |
{ |
| 36 |
struct stat a; |
| 37 |
return fstatat (AT_FDCWD, ".", &a, 0) != 0; |
| 38 |
} |
| 39 |
]])], |
| 40 |
[gl_cv_func_fstatat_zero_flag=yes], |
| 41 |
[gl_cv_func_fstatat_zero_flag=no], |
| 42 |
[case "$host_os" in |
| 43 |
aix*) gl_cv_func_fstatat_zero_flag="guessing no";; |
| 44 |
*) gl_cv_func_fstatat_zero_flag="guessing yes";; |
| 45 |
esac |
| 46 |
]) |
| 47 |
]) |
| 48 |
|
| 49 |
case $gl_cv_func_fstatat_zero_flag+$gl_cv_func_lstat_dereferences_slashed_symlink in |
| 50 |
*yes+*yes) ;; |
| 51 |
*) REPLACE_FSTATAT=1 ;; |
| 52 |
esac |
| 53 |
|
| 54 |
case $host_os in |
| 55 |
darwin* | solaris*) |
| 56 |
REPLACE_FSTATAT=1 ;; |
| 57 |
esac |
| 58 |
|
| 59 |
case $REPLACE_FSTATAT,$gl_cv_func_fstatat_zero_flag in |
| 60 |
1,*yes) |
| 61 |
AC_DEFINE([HAVE_WORKING_FSTATAT_ZERO_FLAG], [1], |
| 62 |
[Define to 1 if fstatat (..., 0) works. |
| 63 |
For example, it does not work in AIX 7.1.]) |
| 64 |
;; |
| 65 |
esac |
| 66 |
fi |
| 67 |
]) |