From 52c658e92436e7ef2d7c7b6f7ee69ae4431b6d7d Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 2 Sep 2009 17:14:26 -0600 Subject: [PATCH] openat: declare in POSIX headers * NEWS: Mention this. * modules/openat (configure.ac): Declare witnesses. (Depends-on): Add fcntl-h, sys_stat, unistd. (Include): Mention correct headers. * modules/fcntl-h (Depends-on): Add link-warning. (Files): Add openat.m4. (Makefile.am): Substitute witnesses. * modules/sys_stat (Files, Makefile.am): Likewise. * modules/unistd (Files, Makefile.am): Likewise. * m4/openat.m4 (gl_FUNC_OPENAT, gl_FUNC_FCHOWNAT): Set witnesses. (gl_OPENAT_DEFAULTS): New macro. * m4/fcntl_h.m4 (gl_FCNTL_H_DEFAULTS): Use it. * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Likewise. * m4/sys_stat_h.m4 (gl_SYS_STAT_H_DEFAULTS): Likewise. (SYS_STAT_H): Remove unused variable. * doc/posix-headers/fcntl.texi (fcntl.h): Update content. * lib/fcntl--.h (includes): Remove unneeded header. * lib/openat-safer.c (includes): Likewise. * lib/openat.h (AT_FDCWD, AT_SYMLINK_NOFOLLOW, AT_REMOVEDIR) (openat, fstatat, unlinkat, mkdirat, fchmodat, fchownat): Move to appropriate headers. (__OPENAT_PREFIX): Delete. * lib/fcntl.in.h (openat): Provide declaration. (AT_FDCWD): Fix Solaris bug. (AT_SYMLINK_NOFOLLOW, AT_REMOVEDIR): Provide macros. * lib/sys_stat.in.h (fstatat, mkdirat): Provide declaration. * lib/fchmodat.c (includes): Adjust to find declaration. * lib/fchownat.c (includes): Likewise. * lib/mkdirat.c (includes): Likewise. * lib/fstatat.c (includes): Likewise. Ensure original fstatat is still visible. Signed-off-by: Eric Blake --- ChangeLog | 35 +++++++++++++++++++++++++++++++ NEWS | 10 ++++++++- doc/posix-headers/fcntl.texi | 11 +++++++++- lib/fchmodat.c | 8 +++++--- lib/fchownat.c | 7 +++---- lib/fcntl--.h | 1 - lib/fcntl.in.h | 44 +++++++++++++++++++++++++++++++++++++++ lib/fstatat.c | 7 ++++--- lib/mkdirat.c | 7 +++---- lib/openat-safer.c | 1 - lib/openat.h | 45 +--------------------------------------- lib/sys_stat.in.h | 35 +++++++++++++++++++++++++++++++ lib/unistd.in.h | 25 ++++++++++++++++++++++ m4/fcntl_h.m4 | 2 ++ m4/openat.m4 | 49 +++++++++++++++++++++++++++++--------------- m4/sys_stat_h.m4 | 5 ++--- m4/unistd_h.m4 | 3 ++- modules/fcntl-h | 5 +++++ modules/openat | 7 +++++++ modules/sys_stat | 8 +++++++- modules/unistd | 5 +++++ 21 files changed, 237 insertions(+), 83 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4eeb067c7..a73cad1cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,38 @@ +2009-09-03 Eric Blake + + openat: declare in POSIX headers + * NEWS: Mention this. + * modules/openat (configure.ac): Declare witnesses. + (Depends-on): Add fcntl-h, sys_stat, unistd. + (Include): Mention correct headers. + * modules/fcntl-h (Depends-on): Add link-warning. + (Files): Add openat.m4. + (Makefile.am): Substitute witnesses. + * modules/sys_stat (Files, Makefile.am): Likewise. + * modules/unistd (Files, Makefile.am): Likewise. + * m4/openat.m4 (gl_FUNC_OPENAT, gl_FUNC_FCHOWNAT): Set witnesses. + (gl_OPENAT_DEFAULTS): New macro. + * m4/fcntl_h.m4 (gl_FCNTL_H_DEFAULTS): Use it. + * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Likewise. + * m4/sys_stat_h.m4 (gl_SYS_STAT_H_DEFAULTS): Likewise. + (SYS_STAT_H): Remove unused variable. + * doc/posix-headers/fcntl.texi (fcntl.h): Update content. + * lib/fcntl--.h (includes): Remove unneeded header. + * lib/openat-safer.c (includes): Likewise. + * lib/openat.h (AT_FDCWD, AT_SYMLINK_NOFOLLOW, AT_REMOVEDIR) + (openat, fstatat, unlinkat, mkdirat, fchmodat, fchownat): Move to + appropriate headers. + (__OPENAT_PREFIX): Delete. + * lib/fcntl.in.h (openat): Provide declaration. + (AT_FDCWD): Fix Solaris bug. + (AT_SYMLINK_NOFOLLOW, AT_REMOVEDIR): Provide macros. + * lib/sys_stat.in.h (fstatat, mkdirat): Provide declaration. + * lib/fchmodat.c (includes): Adjust to find declaration. + * lib/fchownat.c (includes): Likewise. + * lib/mkdirat.c (includes): Likewise. + * lib/fstatat.c (includes): Likewise. Ensure original fstatat is + still visible. + 2009-09-02 Eric Blake errno: use consistently diff --git a/NEWS b/NEWS index 6a364a5c3..4cd027892 100644 --- a/NEWS +++ b/NEWS @@ -6,7 +6,15 @@ User visible incompatible changes Date Modules Changes -2009-09-30 striconveh The functions mem_cd_iconveh and str_cd_iconveh +2009-09-03 openat The include files are standardized to POSIX 2008. + For openat, include ; for + fchmodat, fstatat, and mkdirat, include + ; for fchownat and unlinkat, + include . For all other + functions provided by this module, + continue to include "openat.h". + +2009-08-30 striconveh The functions mem_cd_iconveh and str_cd_iconveh now take an 'iconveh_t *' argument instead of three iconv_t arguments. diff --git a/doc/posix-headers/fcntl.texi b/doc/posix-headers/fcntl.texi index 6e770a32b..020586c4c 100644 --- a/doc/posix-headers/fcntl.texi +++ b/doc/posix-headers/fcntl.texi @@ -27,7 +27,13 @@ on some platforms but not on others. mingw @item -@samp{AT_FDCWD} and friends are provided by modules like openat. +@samp{AT_FDCWD} is defined with a value too large for an int on some +platforms: +Solaris 10 + +@item +@samp{AT_FDCWD}, @samp{AT_SYMLINK_NOFOLLOW}, and @samp{AT_REMOVEDIR} +are missing on some platforms. @end itemize Portability problems not fixed by Gnulib: @@ -55,4 +61,7 @@ on some platforms. @samp{POSIX_FADV_NORMAL}, @samp{POSIX_FADV_RANDOM}, @samp{POSIX_FADV_SEQUENTIAL}, and @samp{POSIX_FADV_WILLNEED} are not defined on some platforms. + +@item +@samp{AT_EACCESS} and @samp{AT_SYMLINK_FOLLOW} are missing on some platforms. @end itemize diff --git a/lib/fchmodat.c b/lib/fchmodat.c index 935bdcbca..23eee6459 100644 --- a/lib/fchmodat.c +++ b/lib/fchmodat.c @@ -1,5 +1,5 @@ /* Change the protections of file relative to an open directory. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,10 +18,12 @@ #include -#include "openat.h" +#include + #include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ -#include "save-cwd.h" +#include "openat.h" #include "openat-priv.h" +#include "save-cwd.h" #ifndef HAVE_LCHMOD /* Use a different name, to avoid conflicting with any diff --git a/lib/fchownat.c b/lib/fchownat.c index a1d5e60f2..c217b5243 100644 --- a/lib/fchownat.c +++ b/lib/fchownat.c @@ -4,7 +4,7 @@ when the buggy fchownat-with-AT_SYMLINK_NOFOLLOW operates on a symlink, it mistakenly affects the symlink referent, rather than the symlink itself. - Copyright (C) 2006-2007 Free Software Foundation, Inc. + Copyright (C) 2006-2007, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,13 +23,12 @@ #include -#include "openat.h" - #include #include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ -#include "save-cwd.h" +#include "openat.h" #include "openat-priv.h" +#include "save-cwd.h" /* Replacement for Solaris' function by the same name. Invoke chown or lchown on file, FILE, using OWNER and GROUP, in the diff --git a/lib/fcntl--.h b/lib/fcntl--.h index 9e311ce7e..588b69aab 100644 --- a/lib/fcntl--.h +++ b/lib/fcntl--.h @@ -27,7 +27,6 @@ #define creat creat_safer #if GNULIB_OPENAT_SAFER -# include "openat.h" /* FIXME - should be sufficient. */ # undef openat # define openat openat_safer #endif diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h index 5c63afd59..6c88b476f 100644 --- a/lib/fcntl.in.h +++ b/lib/fcntl.in.h @@ -44,6 +44,9 @@ #define _GL_FCNTL_H +/* The definition of GL_LINK_WARNING is copied here. */ + + /* Declare overridden functions. */ #ifdef __cplusplus @@ -58,6 +61,20 @@ extern int open (const char *filename, int flags, ...); # endif #endif +#if @GNULIB_OPENAT@ +# if !@HAVE_OPENAT@ +# undef openat +# define openat rpl_openat +int openat (int fd, char const *file, int flags, /* mode_t mode */ ...); +# endif +#elif defined GNULIB_POSIXCHECK +# undef openat +# define openat(f,u,g) \ + (GL_LINK_WARNING ("openat is not portable - " \ + "use gnulib module openat for portability"), \ + openat) +#endif + #ifdef __cplusplus } #endif @@ -148,6 +165,33 @@ extern int open (const char *filename, int flags, ...); # define O_TEXT 0 #endif +/* Fix up the AT_* macros. */ + +/* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive. Its + value exceeds INT_MAX, so its use as an int doesn't conform to the + C standard, and GCC and Sun C complain in some cases. If the bug + is present, undef AT_FDCWD here, so it can be redefined below. */ +#if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553 +# undef AT_FDCWD +#endif + +/* Use the same bit pattern as Solaris 9, but with the proper + signedness. The bit pattern is important, in case this actually is + Solaris with the above workaround. */ +#ifndef AT_FDCWD +# define AT_FDCWD (-3041965) +#endif + +/* Use the same values as Solaris 9. This shouldn't matter, but + there's no real reason to differ. */ +#ifndef AT_SYMLINK_NOFOLLOW +# define AT_SYMLINK_NOFOLLOW 4096 +#endif + +#ifndef AT_REMOVEDIR +# define AT_REMOVEDIR 1 +#endif + #endif /* _GL_FCNTL_H */ #endif /* _GL_FCNTL_H */ diff --git a/lib/fstatat.c b/lib/fstatat.c index 8b6291225..2bf547e51 100644 --- a/lib/fstatat.c +++ b/lib/fstatat.c @@ -1,6 +1,6 @@ /* Work around an fstatat bug on Solaris 9. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,12 +19,13 @@ #include -#define COMPILING_FSTATAT 1 -#include "openat.h" +#include #include #include +#undef fstatat + /* fstatat should always follow symbolic links that end in /, but on Solaris 9 it doesn't if AT_SYMLINK_NOFOLLOW is specified. This is the same problem that lstat.c addresses, so solve it in a similar diff --git a/lib/mkdirat.c b/lib/mkdirat.c index 6b6278b11..d4b3317a2 100644 --- a/lib/mkdirat.c +++ b/lib/mkdirat.c @@ -1,5 +1,5 @@ /* fd-relative mkdir - Copyright (C) 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,13 +18,12 @@ #include -#include "openat.h" - #include #include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ -#include "save-cwd.h" +#include "openat.h" #include "openat-priv.h" +#include "save-cwd.h" /* Solaris 10 has no function like this. Create a subdirectory, FILE, with mode MODE, in the directory diff --git a/lib/openat-safer.c b/lib/openat-safer.c index f6977fd2b..58d9a5e5f 100644 --- a/lib/openat-safer.c +++ b/lib/openat-safer.c @@ -22,7 +22,6 @@ #include "fcntl-safer.h" #include -#include "openat.h" /* FIXME - should be sufficient. */ #include #include "unistd-safer.h" diff --git a/lib/openat.h b/lib/openat.h index df52691ff..1d8596fd8 100644 --- a/lib/openat.h +++ b/lib/openat.h @@ -37,42 +37,10 @@ # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) #endif -/* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive. Its - value exceeds INT_MAX, so its use as an int doesn't conform to the - C standard, and GCC and Sun C complain in some cases. If the bug - is present, undef AT_FDCWD here, so it can be redefined below. */ -#if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553 -# undef AT_FDCWD -#endif - -/* Use the same bit pattern as Solaris 9, but with the proper - signedness. The bit pattern is important, in case this actually is - Solaris with the above workaround. */ -#ifndef AT_FDCWD -# define AT_FDCWD (-3041965) -#endif - -/* Use the same values as Solaris 9. This shouldn't matter, but - there's no real reason to differ. */ -#ifndef AT_SYMLINK_NOFOLLOW -# define AT_SYMLINK_NOFOLLOW 4096 -# define AT_REMOVEDIR 1 -#endif +#if !HAVE_OPENAT -#ifdef __OPENAT_PREFIX - -# undef openat -# define __OPENAT_CONCAT(x, y) x ## y -# define __OPENAT_XCONCAT(x, y) __OPENAT_CONCAT (x, y) -# define __OPENAT_ID(y) __OPENAT_XCONCAT (__OPENAT_PREFIX, y) -# define openat __OPENAT_ID (openat) -int openat (int fd, char const *file, int flags, /* mode_t mode */ ...); int openat_permissive (int fd, char const *file, int flags, mode_t mode, int *cwd_errno); -# define fstatat __OPENAT_ID (fstatat) -int fstatat (int fd, char const *file, struct stat *st, int flag); -# define unlinkat __OPENAT_ID (unlinkat) -int unlinkat (int fd, char const *file, int flag); bool openat_needs_fchdir (void); #else @@ -83,19 +51,8 @@ bool openat_needs_fchdir (void); #endif -#if HAVE_OPENAT && ! LSTAT_FOLLOWS_SLASHED_SYMLINK -int rpl_fstatat (int fd, char const *file, struct stat *st, int flag); -# if !COMPILING_FSTATAT -# undef fstatat -# define fstatat rpl_fstatat -# endif -#endif - -int mkdirat (int fd, char const *file, mode_t mode); void openat_restore_fail (int) ATTRIBUTE_NORETURN; void openat_save_fail (int) ATTRIBUTE_NORETURN; -int fchmodat (int fd, char const *file, mode_t mode, int flag); -int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag); /* Using these function names makes application code slightly more readable than it would be with diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h index b0341681f..2d89beb22 100644 --- a/lib/sys_stat.in.h +++ b/lib/sys_stat.in.h @@ -302,6 +302,41 @@ extern int rpl_lstat (const char *name, struct stat *buf); lstat (p, b)) #endif +#if @GNULIB_OPENAT@ +# if @REPLACE_FSTATAT@ +# undef fstatat +# define fstatat rpl_fstatat +# endif +# if !@HAVE_FSTATAT@ || @REPLACE_FSTATAT@ +int fstatat (int fd, char const *name, struct stat *st, int flags); +# endif + +# if !@HAVE_FCHMODAT@ +int fchmodat (int fd, char const *file, mode_t mode, int flag); +# endif + +# if !@HAVE_MKDIRAT@ +int mkdirat (int fd, char const *file, mode_t mode); +#endif + +#elif defined GNULIB_POSIXCHECK +# undef fchmodat +# define fchmodat(d,n,m,f) \ + (GL_LINK_WARNING ("fchmodat is not portable - " \ + "use gnulib module openat for portability"), \ + fchmodat (d, n, m, f)) +# undef fstatat +# define fstatat(d,n,s,f) \ + (GL_LINK_WARNING ("fstatat is not portable - " \ + "use gnulib module openat for portability"), \ + fstatat (d, n, s, f)) +# undef mkdirat +# define mkdirat(d,n,m) \ + (GL_LINK_WARNING ("mkdirat is not portable - " \ + "use gnulib module openat for portability"), \ + mkdirat (d, n, m)) +#endif /* @GNULIB_OPENAT@ */ + #if @REPLACE_FCHDIR@ # define fstat rpl_fstat extern int fstat (int fd, struct stat *buf); diff --git a/lib/unistd.in.h b/lib/unistd.in.h index fe645b79c..e6db70ba5 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -138,6 +138,31 @@ extern int chown (const char *file, uid_t uid, gid_t gid); #endif +#if @GNULIB_OPENAT@ +# if @REPLACE_FCHOWNAT@ +# undef fchownat +# define fchownat rpl_fchownat +# endif +# if !@HAVE_FCHOWNAT@ || @REPLACE_FCHOWNAT@ +int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag); +# endif +# if !@HAVE_UNLINKAT@ +int unlinkat (int fd, char const *file, int flag); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fchownat +# define fchownat(d,n,o,g,f) \ + (GL_LINK_WARNING ("fchownat is not portable - " \ + "use gnulib module openat for portability"), \ + fchownat (d, n, o, g, f)) +# undef unlinkat +# define unlinkat(d,n,f) \ + (GL_LINK_WARNING ("unlinkat is not portable - " \ + "use gnulib module openat for portability"), \ + unlinkat (d, n, f)) +#endif /* @GNULIB_OPENAT@ */ + + #if @GNULIB_CLOSE@ # if @REPLACE_CLOSE@ /* Automatically included by modules that need a replacement for close. */ diff --git a/m4/fcntl_h.m4 b/m4/fcntl_h.m4 index 1ae0b15a9..fdea01fb3 100644 --- a/m4/fcntl_h.m4 +++ b/m4/fcntl_h.m4 @@ -1,3 +1,4 @@ +# serial 2 # Configure fcntl.h. dnl Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation @@ -90,6 +91,7 @@ AC_DEFUN([gl_FCNTL_MODULE_INDICATOR], AC_DEFUN([gl_FCNTL_H_DEFAULTS], [ + AC_REQUIRE([gl_OPENAT_DEFAULTS]) dnl for GNULIB_OPENAT GNULIB_OPEN=0; AC_SUBST([GNULIB_OPEN]) dnl Assume proper GNU behavior unless another module says otherwise. REPLACE_OPEN=0; AC_SUBST([REPLACE_OPEN]) diff --git a/m4/openat.m4 b/m4/openat.m4 index c8403a15f..51f38d065 100644 --- a/m4/openat.m4 +++ b/m4/openat.m4 @@ -1,4 +1,4 @@ -# serial 19 +# serial 20 # See if we need to use our replacement for Solaris' openat et al functions. dnl Copyright (C) 2004-2009 Free Software Foundation, Inc. @@ -17,13 +17,24 @@ AC_DEFUN([gl_FUNC_OPENAT], AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK]) case $ac_cv_func_openat+$ac_cv_func_lstat_dereferences_slashed_symlink in yes+yes) ;; - yes+*) AC_LIBOBJ([fstatat]);; + yes+*) + AC_LIBOBJ([fstatat]) + REPLACE_FSTATAT=1 + ;; *) - AC_DEFINE([__OPENAT_PREFIX], [[rpl_]], - [Define to rpl_ if the openat replacement function should be used.]) + HAVE_OPENAT=0 + HAVE_UNLINKAT=0 # No known system with unlinkat but not openat + HAVE_FSTATAT=0 # No known system with fstatat but not openat gl_PREREQ_OPENAT;; esac + if test $ac_cv_func_fchmodat != yes; then + HAVE_FCHMODAT=0 + fi + if test $ac_cv_func_mkdirat != yes; then + HAVE_MKDIRAT=0 + fi gl_FUNC_FCHOWNAT + GNULIB_OPENAT=1 ]) # gl_FUNC_FCHOWNAT_DEREF_BUG([ACTION-IF-BUGGY[, ACTION-IF-NOT_BUGGY]]) @@ -68,19 +79,11 @@ main () # Also use the replacement function if fchownat is simply not available. AC_DEFUN([gl_FUNC_FCHOWNAT], [ - # Assume we'll use the replacement function. - # The only case in which we won't is when we have fchownat, and it works. - use_replacement_fchownat=yes - - AC_CHECK_FUNC([fchownat], [have_fchownat=yes], [have_fchownat=no]) - if test $have_fchownat = yes; then - gl_FUNC_FCHOWNAT_DEREF_BUG([], [use_replacement_fchownat=no]) - fi - - if test $use_replacement_fchownat = yes; then + AC_CHECK_FUNC([fchownat], + [gl_FUNC_FCHOWNAT_DEREF_BUG([REPLACE_FCHOWNAT=1])], + [HAVE_FCHOWNAT=0]) + if test $HAVE_FCHOWNAT = 0 || test $REPLACE_FCHOWNAT = 1; then AC_LIBOBJ([fchownat]) - AC_DEFINE([fchownat], [rpl_fchownat], - [Define to rpl_fchownat if the replacement function should be used.]) fi ]) @@ -89,3 +92,17 @@ AC_DEFUN([gl_PREREQ_OPENAT], AC_REQUIRE([gl_PROMOTED_TYPE_MODE_T]) : ]) + +AC_DEFUN([gl_OPENAT_DEFAULTS], +[ + GNULIB_OPENAT=0; AC_SUBST([GNULIB_OPENAT]) + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_FCHMODAT=1; AC_SUBST([HAVE_FCHMODAT]) + HAVE_FCHOWNAT=1; AC_SUBST([HAVE_FCHOWNAT]) + HAVE_FSTATAT=1; AC_SUBST([HAVE_FSTATAT]) + HAVE_MKDIRAT=1; AC_SUBST([HAVE_MKDIRAT]) + HAVE_OPENAT=1; AC_SUBST([HAVE_OPENAT]) + HAVE_UNLINKAT=1; AC_SUBST([HAVE_UNLINKAT]) + REPLACE_FCHOWNAT=0; AC_SUBST([REPLACE_FCHOWNAT]) + REPLACE_FSTATAT=0; AC_SUBST([REPLACE_FSTATAT]) +]) diff --git a/m4/sys_stat_h.m4 b/m4/sys_stat_h.m4 index 5113e5538..634a33fc6 100644 --- a/m4/sys_stat_h.m4 +++ b/m4/sys_stat_h.m4 @@ -1,4 +1,4 @@ -# sys_stat_h.m4 serial 11 -*- Autoconf -*- +# sys_stat_h.m4 serial 12 -*- Autoconf -*- dnl Copyright (C) 2006-2009 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -28,8 +28,6 @@ AC_DEFUN([gl_HEADER_SYS_STAT_H], AC_REQUIRE([AC_HEADER_STAT]) gl_CHECK_NEXT_HEADERS([sys/stat.h]) - SYS_STAT_H='sys/stat.h' - AC_SUBST([SYS_STAT_H]) dnl Define types that are supposed to be defined in or dnl . @@ -51,6 +49,7 @@ AC_DEFUN([gl_SYS_STAT_MODULE_INDICATOR], AC_DEFUN([gl_SYS_STAT_H_DEFAULTS], [ AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) dnl for REPLACE_FCHDIR + AC_REQUIRE([gl_OPENAT_DEFAULTS]) dnl for GNULIB_OPENAT GNULIB_LCHMOD=0; AC_SUBST([GNULIB_LCHMOD]) GNULIB_LSTAT=0; AC_SUBST([GNULIB_LSTAT]) dnl Assume proper GNU behavior unless another module says otherwise. diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4 index 53fc330be..c8e93da19 100644 --- a/m4/unistd_h.m4 +++ b/m4/unistd_h.m4 @@ -1,4 +1,4 @@ -# unistd_h.m4 serial 21 +# unistd_h.m4 serial 22 dnl Copyright (C) 2006-2009 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -32,6 +32,7 @@ AC_DEFUN([gl_UNISTD_MODULE_INDICATOR], AC_DEFUN([gl_UNISTD_H_DEFAULTS], [ + AC_REQUIRE([gl_OPENAT_DEFAULTS]) dnl for GNULIB_OPENAT GNULIB_CHOWN=0; AC_SUBST([GNULIB_CHOWN]) GNULIB_CLOSE=0; AC_SUBST([GNULIB_CLOSE]) GNULIB_DUP2=0; AC_SUBST([GNULIB_DUP2]) diff --git a/modules/fcntl-h b/modules/fcntl-h index 8e2af03e6..d86f57206 100644 --- a/modules/fcntl-h +++ b/modules/fcntl-h @@ -4,9 +4,11 @@ Like , but with non-working flags defined to 0. Files: lib/fcntl.in.h m4/fcntl_h.m4 +m4/openat.m4 Depends-on: include_next +link-warning unistd extensions @@ -25,7 +27,10 @@ fcntl.h: fcntl.in.h -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_FCNTL_H''@|$(NEXT_FCNTL_H)|g' \ -e 's|@''GNULIB_OPEN''@|$(GNULIB_OPEN)|g' \ + -e 's|@''GNULIB_OPENAT''@|$(GNULIB_OPENAT)|g' \ -e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \ + -e 's|@''HAVE_OPENAT''@|$(HAVE_OPENAT)|g' \ + -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/fcntl.in.h; \ } > $@-t && \ mv $@-t $@ diff --git a/modules/openat b/modules/openat index 3ea5b4d7c..e1dda710f 100644 --- a/modules/openat +++ b/modules/openat @@ -19,6 +19,7 @@ dirname errno extensions fchdir +fcntl-h fdopendir gettext-h intprops @@ -29,13 +30,19 @@ rmdir same-inode save-cwd stdbool +sys_stat +unistd configure.ac: gl_FUNC_OPENAT +gl_MODULE_INDICATOR([openat]) Makefile.am: Include: + + + "openat.h" License: diff --git a/modules/sys_stat b/modules/sys_stat index 40f1c1880..bad77be84 100644 --- a/modules/sys_stat +++ b/modules/sys_stat @@ -4,6 +4,7 @@ A for systems with missing declarations. Files: lib/sys_stat.in.h m4/sys_stat_h.m4 +m4/openat.m4 m4/unistd_h.m4 Depends-on: @@ -15,7 +16,7 @@ gl_HEADER_SYS_STAT_H AC_PROG_MKDIR_P Makefile.am: -BUILT_SOURCES += $(SYS_STAT_H) +BUILT_SOURCES += sys/stat.h # We need the following in order to create when the system # has one that is incomplete. @@ -28,11 +29,16 @@ sys/stat.h: sys_stat.in.h -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \ -e 's|@''GNULIB_LCHMOD''@|$(GNULIB_LCHMOD)|g' \ -e 's|@''GNULIB_LSTAT''@|$(GNULIB_LSTAT)|g' \ + -e 's|@''GNULIB_OPENAT''@|$(GNULIB_OPENAT)|g' \ + -e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \ + -e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \ -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \ -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \ + -e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \ -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \ -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \ -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \ + -e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/sys_stat.in.h; \ } > $@-t && \ diff --git a/modules/unistd b/modules/unistd index 66fc1a32a..4c5add7db 100644 --- a/modules/unistd +++ b/modules/unistd @@ -4,6 +4,7 @@ A GNU-like . Files: m4/unistd_h.m4 lib/unistd.in.h +m4/openat.m4 Depends-on: include_next @@ -44,6 +45,7 @@ unistd.h: unistd.in.h -e 's|@''GNULIB_LCHOWN''@|$(GNULIB_LCHOWN)|g' \ -e 's|@''GNULIB_LINK''@|$(GNULIB_LINK)|g' \ -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \ + -e 's|@''GNULIB_OPENAT''@|$(GNULIB_OPENAT)|g' \ -e 's|@''GNULIB_PIPE2''@|$(GNULIB_PIPE2)|g' \ -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \ -e 's|@''GNULIB_SLEEP''@|$(GNULIB_SLEEP)|g' \ @@ -53,6 +55,7 @@ unistd.h: unistd.in.h -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \ -e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \ -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \ + -e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \ -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \ -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \ -e 's|@''HAVE_GETDOMAINNAME''@|$(HAVE_GETDOMAINNAME)|g' \ @@ -64,6 +67,7 @@ unistd.h: unistd.in.h -e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \ -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \ -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \ + -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \ -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \ -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \ -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \ @@ -72,6 +76,7 @@ unistd.h: unistd.in.h -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \ -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \ -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \ + -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \ -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \ -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \ -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \ -- 2.11.0