New module 'fstatat', split off from module 'openat'.
authorBruno Haible <bruno@clisp.org>
Thu, 3 Nov 2011 11:03:53 +0000 (12:03 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 4 Nov 2011 09:55:30 +0000 (10:55 +0100)
* lib/openat.h (statat, lstatat): Enable only if GNULIB_FSTATAT is
defined.
* m4/fstatat.m4: New file. extracted from m4/openat.m4.
* m4/openat.m4 (gl_FUNC_OPENAT): Don't set GNULIB_FSTATAT. Don't invoke
gl_FUNC_FSTATAT.
(gl_FUNC_FSTATAT): Moved to m4/fstatat.m4.
* modules/fstatat: New file, extracted from modules/openat.
* modules/openat (Files): Remove lib/fstatat.c.
(Depends-on): Remove lstat.
(configure.ac): Remove AC_LIBOBJ of fstatat.
* modules/fstatat-tests: New file, extracted from modules/openat-tests.
* modules/openat-tests (Files): Remove tests/test-fstatat.c,
tests/test-lstat.h, tests/test-stat.h.
(Depends-on): Remove getcwd-lgpl.
(Makefile.am): Remove rules for test-fstatat.
* doc/posix-functions/fstatat.texi: Mention module 'fstatat' instead
of module 'openat'.
* NEWS: Mention the change.
* modules/getcwd (Depends-on): Add fstatat.
* modules/linkat (Depends-on): Likewise.
* modules/mkfifoat-tests (Depends-on): Likewise.
* modules/utimensat (Depends-on): Add fstatat. Remove openat.

14 files changed:
ChangeLog
NEWS
doc/posix-functions/fstatat.texi
lib/openat.h
m4/fstatat.m4 [new file with mode: 0644]
m4/openat.m4
modules/fstatat [new file with mode: 0644]
modules/fstatat-tests [new file with mode: 0644]
modules/getcwd
modules/linkat
modules/mkfifoat-tests
modules/openat
modules/openat-tests
modules/utimensat

index 4c1bde0..ecdeedf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2011-11-04  Bruno Haible  <bruno@clisp.org>
+
+       New module 'fstatat', split off from module 'openat'.
+       * lib/openat.h (statat, lstatat): Enable only if GNULIB_FSTATAT is
+       defined.
+       * m4/fstatat.m4: New file. extracted from m4/openat.m4.
+       * m4/openat.m4 (gl_FUNC_OPENAT): Don't set GNULIB_FSTATAT. Don't invoke
+       gl_FUNC_FSTATAT.
+       (gl_FUNC_FSTATAT): Moved to m4/fstatat.m4.
+       * modules/fstatat: New file, extracted from modules/openat.
+       * modules/openat (Files): Remove lib/fstatat.c.
+       (Depends-on): Remove lstat.
+       (configure.ac): Remove AC_LIBOBJ of fstatat.
+       * modules/fstatat-tests: New file, extracted from modules/openat-tests.
+       * modules/openat-tests (Files): Remove tests/test-fstatat.c,
+       tests/test-lstat.h, tests/test-stat.h.
+       (Depends-on): Remove getcwd-lgpl.
+       (Makefile.am): Remove rules for test-fstatat.
+       * doc/posix-functions/fstatat.texi: Mention module 'fstatat' instead
+       of module 'openat'.
+       * NEWS: Mention the change.
+       * modules/getcwd (Depends-on): Add fstatat.
+       * modules/linkat (Depends-on): Likewise.
+       * modules/mkfifoat-tests (Depends-on): Likewise.
+       * modules/utimensat (Depends-on): Add fstatat. Remove openat.
+
 2011-11-03  Bruno Haible  <bruno@clisp.org>
 
        New module 'unlinkat', split off from module 'openat'.
diff --git a/NEWS b/NEWS
index 045de1f..5cc3a6a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,10 @@ User visible incompatible changes
 
 Date        Modules         Changes
 
+2011-11-04  openat          This module no longer provides the fstatat()
+                            function. If you need this function, you now need
+                            to request the 'fstatat' module.
+
 2011-11-03  openat          This module no longer provides the unlinkat()
                             function. If you need this function, you now need
                             to request the 'unlinkat' module.
index 4beb605..fcb2b30 100644 (file)
@@ -4,7 +4,7 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/fstatat.html}
 
-Gnulib module: openat
+Gnulib module: fstatat
 
 Portability problems fixed by Gnulib:
 @itemize
index fcae664..03a513d 100644 (file)
@@ -80,6 +80,8 @@ lchmodat (int fd, char const *file, mode_t mode)
 
 #endif
 
+#if GNULIB_FSTATAT
+
 static inline int
 statat (int fd, char const *name, struct stat *st)
 {
@@ -92,6 +94,8 @@ lstatat (int fd, char const *name, struct stat *st)
   return fstatat (fd, name, st, AT_SYMLINK_NOFOLLOW);
 }
 
+#endif
+
 /* For now, there are no wrappers named laccessat or leuidaccessat,
    since gnulib doesn't support faccessat(,AT_SYMLINK_NOFOLLOW) and
    since access rights on symlinks are of limited utility.  Likewise,
diff --git a/m4/fstatat.m4 b/m4/fstatat.m4
new file mode 100644 (file)
index 0000000..5802537
--- /dev/null
@@ -0,0 +1,51 @@
+# fstatat.m4 serial 1
+dnl Copyright (C) 2004-2011 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+# Written by Jim Meyering.
+
+# If we have the fstatat function, and it has the bug (in AIX 7.1)
+# that it does not fill in st_size correctly, use the replacement function.
+AC_DEFUN([gl_FUNC_FSTATAT],
+[
+  AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
+  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+  AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
+  AC_CHECK_FUNCS_ONCE([fstatat])
+
+  if test $ac_cv_func_fstatat = no; then
+    HAVE_FSTATAT=0
+  else
+    dnl Test for an AIX 7.1 bug; see
+    dnl <http://lists.gnu.org/archive/html/bug-tar/2011-09/msg00015.html>.
+    AC_CACHE_CHECK([whether fstatat (..., 0) works],
+      [gl_cv_func_fstatat_zero_flag],
+      [gl_cv_func_fstatat_zero_flag=no
+       AC_RUN_IFELSE(
+         [AC_LANG_SOURCE(
+            [[
+              #include <fcntl.h>
+              #include <sys/stat.h>
+              int
+              main (void)
+              {
+                struct stat a;
+                return fstatat (AT_FDCWD, ".", &a, 0) != 0;
+              }
+            ]])],
+         [gl_cv_func_fstatat_zero_flag=yes])])
+
+    case $gl_cv_func_fstatat_zero_flag+$gl_cv_func_lstat_dereferences_slashed_symlink in
+    yes+yes) ;;
+    *) REPLACE_FSTATAT=1
+       if test $gl_cv_func_fstatat_zero_flag != yes; then
+         AC_DEFINE([FSTATAT_ZERO_FLAG_BROKEN], [1],
+           [Define to 1 if fstatat (..., 0) does not work,
+            as in AIX 7.1.])
+       fi
+       ;;
+    esac
+  fi
+])
index 86e3144..86a8b62 100644 (file)
@@ -1,4 +1,4 @@
-# serial 40
+# serial 41
 # See if we need to use our replacement for Solaris' openat et al functions.
 
 dnl Copyright (C) 2004-2011 Free Software Foundation, Inc.
@@ -14,7 +14,6 @@ AC_DEFUN([gl_FUNC_OPENAT],
   GNULIB_OPENAT=1
 
   AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
-  GNULIB_FSTATAT=1
   GNULIB_MKDIRAT=1
 
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
@@ -35,56 +34,11 @@ AC_DEFUN([gl_FUNC_OPENAT],
   if test $ac_cv_func_mkdirat != yes; then
     HAVE_MKDIRAT=0
   fi
-  gl_FUNC_FSTATAT
 
   dnl This is tested at least via getcwd.c.
   gl_MODULE_INDICATOR([openat])
 ])
 
-# If we have the fstatat function, and it has the bug (in AIX 7.1)
-# that it does not fill in st_size correctly, use the replacement function.
-AC_DEFUN([gl_FUNC_FSTATAT],
-[
-  AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
-  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
-  AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
-  AC_CHECK_FUNCS_ONCE([fstatat])
-
-  if test $ac_cv_func_fstatat = no; then
-    HAVE_FSTATAT=0
-  else
-    dnl Test for an AIX 7.1 bug; see
-    dnl <http://lists.gnu.org/archive/html/bug-tar/2011-09/msg00015.html>.
-    AC_CACHE_CHECK([whether fstatat (..., 0) works],
-      [gl_cv_func_fstatat_zero_flag],
-      [gl_cv_func_fstatat_zero_flag=no
-       AC_RUN_IFELSE(
-         [AC_LANG_SOURCE(
-            [[
-              #include <fcntl.h>
-              #include <sys/stat.h>
-              int
-              main (void)
-              {
-                struct stat a;
-                return fstatat (AT_FDCWD, ".", &a, 0) != 0;
-              }
-            ]])],
-         [gl_cv_func_fstatat_zero_flag=yes])])
-
-    case $gl_cv_func_fstatat_zero_flag+$gl_cv_func_lstat_dereferences_slashed_symlink in
-    yes+yes) ;;
-    *) REPLACE_FSTATAT=1
-       if test $gl_cv_func_fstatat_zero_flag != yes; then
-         AC_DEFINE([FSTATAT_ZERO_FLAG_BROKEN], [1],
-           [Define to 1 if fstatat (..., 0) does not work,
-            as in AIX 7.1.])
-       fi
-       ;;
-    esac
-  fi
-])
-
 AC_DEFUN([gl_PREREQ_OPENAT],
 [
   AC_REQUIRE([AC_C_INLINE])
diff --git a/modules/fstatat b/modules/fstatat
new file mode 100644 (file)
index 0000000..77e7a9b
--- /dev/null
@@ -0,0 +1,45 @@
+Description:
+fstatat() function: Return information about a file at a directory.
+
+Files:
+lib/fstatat.c
+lib/at-func.c
+lib/openat.h
+lib/openat-priv.h
+m4/fstatat.m4
+
+Depends-on:
+dirent
+dosname
+errno
+extensions
+fchdir
+fcntl-h
+fstat
+lstat
+openat
+openat-die
+save-cwd
+stdbool
+sys_stat
+unistd
+
+configure.ac:
+gl_FUNC_FSTATAT
+if test $HAVE_FSTATAT = 0 || test $REPLACE_FSTATAT = 1; then
+  AC_LIBOBJ([fstatat])
+fi
+AC_REQUIRE([AC_C_INLINE]) dnl because 'inline' is used in lib/openat.h
+gl_MODULE_INDICATOR([fstatat]) dnl for lib/openat.h
+gl_SYS_STAT_MODULE_INDICATOR([fstatat])
+
+Makefile.am:
+
+Include:
+<sys/stat.h>
+
+License:
+GPL
+
+Maintainer:
+Jim Meyering, Eric Blake
diff --git a/modules/fstatat-tests b/modules/fstatat-tests
new file mode 100644 (file)
index 0000000..f33ff11
--- /dev/null
@@ -0,0 +1,19 @@
+Files:
+tests/test-fstatat.c
+tests/test-lstat.h
+tests/test-stat.h
+tests/signature.h
+tests/macros.h
+
+Depends-on:
+getcwd-lgpl
+ignore-value
+progname
+symlink
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-fstatat
+check_PROGRAMS += test-fstatat
+test_fstatat_LDADD = $(LDADD) @LIBINTL@
index aa3fe69..3bd2ba7 100644 (file)
@@ -17,6 +17,7 @@ d-ino           [test $REPLACE_GETCWD = 1]
 memmove         [test $REPLACE_GETCWD = 1]
 openat          [test $REPLACE_GETCWD = 1]
 fstat           [test $REPLACE_GETCWD = 1]
+fstatat         [test $REPLACE_GETCWD = 1]
 opendir         [test $REPLACE_GETCWD = 1]
 closedir        [test $REPLACE_GETCWD = 1]
 stdbool         [test $REPLACE_GETCWD = 1]
index 77f08d0..3902e35 100644 (file)
@@ -17,6 +17,7 @@ errno            [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 fcntl-h          [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 filenamecat-lgpl [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 fstat            [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
+fstatat          [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 getcwd-lgpl      [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 openat           [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 link             [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
index b50bbf5..4c0e23f 100644 (file)
@@ -5,6 +5,7 @@ tests/signature.h
 tests/macros.h
 
 Depends-on:
+fstatat
 ignore-value
 symlink
 unlinkat
index 167fa92..503c121 100644 (file)
@@ -3,7 +3,6 @@ Open a file at a directory.
 
 Files:
 lib/at-func.c
-lib/fstatat.c
 lib/mkdirat.c
 lib/openat.c
 lib/openat.h
@@ -23,7 +22,6 @@ fstat
 gettext-h
 intprops
 largefile
-lstat
 mkdir           [test $HAVE_MKDIRAT = 0]
 open
 openat-die
@@ -35,9 +33,6 @@ unistd
 configure.ac:
 gl_FUNC_OPENAT
 AC_LIBOBJ([openat-proc])
-if test $ac_cv_func_fstatat = no || test $REPLACE_FSTATAT = 1; then
-  AC_LIBOBJ([fstatat])
-fi
 if test $HAVE_MKDIRAT = 0; then
   AC_LIBOBJ([mkdirat])
 fi
index bdefca3..cb38d2e 100644 (file)
@@ -1,15 +1,11 @@
 Files:
-tests/test-lstat.h
 tests/test-mkdir.h
-tests/test-stat.h
-tests/test-fstatat.c
 tests/test-mkdirat.c
 tests/test-openat.c
 tests/signature.h
 tests/macros.h
 
 Depends-on:
-getcwd-lgpl
 ignore-value
 progname
 symlink
@@ -18,9 +14,8 @@ configure.ac:
 
 Makefile.am:
 TESTS += \
-  test-fstatat test-mkdirat test-openat
+  test-mkdirat test-openat
 check_PROGRAMS += \
-  test-fstatat test-mkdirat test-openat
-test_fstatat_LDADD = $(LDADD) @LIBINTL@
+  test-mkdirat test-openat
 test_mkdirat_LDADD = $(LDADD) @LIBINTL@
 test_openat_LDADD = $(LDADD) @LIBINTL@
index a70ca8c..9f3ec7e 100644 (file)
@@ -8,7 +8,7 @@ m4/utimensat.m4
 Depends-on:
 sys_stat
 extensions
-openat          [test $HAVE_UTIMENSAT = 0 || test $REPLACE_UTIMENSAT = 1]
+fstatat         [test $HAVE_UTIMENSAT = 0 || test $REPLACE_UTIMENSAT = 1]
 utimens         [test $HAVE_UTIMENSAT = 0 || test $REPLACE_UTIMENSAT = 1]
 
 configure.ac: