2 # See if we need to use our replacement for Solaris' openat et al functions.
4 dnl Copyright (C) 2004-2009 Free Software Foundation, Inc.
5 dnl This file is free software; the Free Software Foundation
6 dnl gives unlimited permission to copy and/or distribute it,
7 dnl with or without modifications, as long as this notice is preserved.
9 # Written by Jim Meyering.
11 AC_DEFUN([gl_FUNC_OPENAT],
13 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
16 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
21 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
25 AC_LIBOBJ([openat-proc])
26 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
27 AC_CHECK_FUNCS_ONCE([lchmod])
28 AC_REPLACE_FUNCS([fchmodat fstatat mkdirat openat unlinkat])
29 AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
30 case $ac_cv_func_openat+$ac_cv_func_lstat_dereferences_slashed_symlink in
33 # Solaris 9 has *at functions, but uniformly mishandles trailing
34 # slash in all of them.
44 HAVE_UNLINKAT=0 # No known system with unlinkat but not openat
45 HAVE_FSTATAT=0 # No known system with fstatat but not openat
48 if test $ac_cv_func_fchmodat != yes; then
51 if test $ac_cv_func_mkdirat != yes; then
57 # gl_FUNC_FCHOWNAT_DEREF_BUG([ACTION-IF-BUGGY[, ACTION-IF-NOT_BUGGY]])
58 AC_DEFUN([gl_FUNC_FCHOWNAT_DEREF_BUG],
60 AC_CACHE_CHECK([whether fchownat works with AT_SYMLINK_NOFOLLOW],
61 gl_cv_func_fchownat_nofollow_works,
63 gl_dangle=conftest.dangle
64 # Remove any remnants of a previous test.
66 # Arrange for deletion of the temporary file this test creates.
67 ac_clean_files="$ac_clean_files $gl_dangle"
68 ln -s conftest.no-such $gl_dangle
76 #include <sys/types.h>
80 return (fchownat (AT_FDCWD, "$gl_dangle", -1, getgid (),
81 AT_SYMLINK_NOFOLLOW) != 0
85 [gl_cv_func_fchownat_nofollow_works=yes],
86 [gl_cv_func_fchownat_nofollow_works=no],
87 [gl_cv_func_fchownat_nofollow_works=no],
90 AS_IF([test $gl_cv_func_fchownat_nofollow_works = no], [$1], [$2])
93 # If we have the fchownat function, and it has the bug (in glibc-2.4)
94 # that it dereferences symlinks even with AT_SYMLINK_NOFOLLOW, then
95 # use the replacement function.
96 # Also use the replacement function if fchownat is simply not available.
97 AC_DEFUN([gl_FUNC_FCHOWNAT],
99 AC_CHECK_FUNC([fchownat],
100 [gl_FUNC_FCHOWNAT_DEREF_BUG([REPLACE_FCHOWNAT=1])],
102 if test $HAVE_FCHOWNAT = 0 || test $REPLACE_FCHOWNAT = 1; then
103 AC_LIBOBJ([fchownat])
107 AC_DEFUN([gl_PREREQ_OPENAT],
109 AC_REQUIRE([gl_PROMOTED_TYPE_MODE_T])