openat: declare in POSIX headers
authorEric Blake <ebb9@byu.net>
Wed, 2 Sep 2009 23:14:26 +0000 (17:14 -0600)
committerEric Blake <ebb9@byu.net>
Fri, 4 Sep 2009 03:20:42 +0000 (21:20 -0600)
* 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 <ebb9@byu.net>
21 files changed:
ChangeLog
NEWS
doc/posix-headers/fcntl.texi
lib/fchmodat.c
lib/fchownat.c
lib/fcntl--.h
lib/fcntl.in.h
lib/fstatat.c
lib/mkdirat.c
lib/openat-safer.c
lib/openat.h
lib/sys_stat.in.h
lib/unistd.in.h
m4/fcntl_h.m4
m4/openat.m4
m4/sys_stat_h.m4
m4/unistd_h.m4
modules/fcntl-h
modules/openat
modules/sys_stat
modules/unistd

index 4eeb067..a73cad1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,38 @@
+2009-09-03  Eric Blake  <ebb9@byu.net>
+
+       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  <ebb9@byu.net>
 
        errno: use consistently
diff --git a/NEWS b/NEWS
index 6a364a5..4cd0278 100644 (file)
--- 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 <fcntl.h>; for
+                            fchmodat, fstatat, and mkdirat, include
+                            <sys/stat.h>; for fchownat and unlinkat,
+                            include <unistd.h>.  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.
 
index 6e770a3..020586c 100644 (file)
@@ -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
index 935bdcb..23eee64 100644 (file)
@@ -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
 
 #include <config.h>
 
-#include "openat.h"
+#include <sys/stat.h>
+
 #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
index a1d5e60..c217b52 100644 (file)
@@ -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
 
 #include <config.h>
 
-#include "openat.h"
-
 #include <unistd.h>
 
 #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
index 9e311ce..588b69a 100644 (file)
@@ -27,7 +27,6 @@
 #define creat creat_safer
 
 #if GNULIB_OPENAT_SAFER
-# include "openat.h" /* FIXME - <fcntl.h> should be sufficient.  */
 # undef openat
 # define openat openat_safer
 #endif
index 5c63afd..6c88b47 100644 (file)
@@ -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 */
index 8b62912..2bf547e 100644 (file)
@@ -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
 
 #include <config.h>
 
-#define COMPILING_FSTATAT 1
-#include "openat.h"
+#include <sys/stat.h>
 
 #include <errno.h>
 #include <string.h>
 
+#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
index 6b6278b..d4b3317 100644 (file)
@@ -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
 
 #include <config.h>
 
-#include "openat.h"
-
 #include <unistd.h>
 
 #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
index f6977fd..58d9a5e 100644 (file)
@@ -22,7 +22,6 @@
 #include "fcntl-safer.h"
 
 #include <fcntl.h>
-#include "openat.h" /* FIXME - <fcntl.h> should be sufficient.  */
 #include <stdarg.h>
 #include "unistd-safer.h"
 
index df52691..1d8596f 100644 (file)
 # 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
index b034168..2d89beb 100644 (file)
@@ -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);
index fe645b7..e6db70b 100644 (file)
@@ -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.  */
index 1ae0b15..fdea01f 100644 (file)
@@ -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])
index c8403a1..51f38d0 100644 (file)
@@ -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])
+])
index 5113e55..634a33f 100644 (file)
@@ -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 <sys/types.h> or
   dnl <sys/stat.h>.
@@ -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.
index 53fc330..c8e93da 100644 (file)
@@ -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])
index 8e2af03..d86f572 100644 (file)
@@ -4,9 +4,11 @@ Like <fcntl.h>, 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 $@
index 3ea5b4d..e1dda71 100644 (file)
@@ -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:
+<fcntl.h>
+<sys/stat.h>
+<unistd.h>
 "openat.h"
 
 License:
index 40f1c18..bad77be 100644 (file)
@@ -4,6 +4,7 @@ A <sys/stat.h> 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 <sys/stat.h> 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 && \
index 66fc1a3..4c5add7 100644 (file)
@@ -4,6 +4,7 @@ A GNU-like <unistd.h>.
 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' \