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