bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

split off module fstatat from module openat


From: Bruno Haible
Subject: split off module fstatat from module openat
Date: Thu, 3 Nov 2011 12:11:33 +0100
User-agent: KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; )

Hi Jim,

The next split-off is 'fstatat'. Here's the proposed patch. Tested on several
platforms.


2011-11-03  Bruno Haible  <address@hidden>

        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.

================================ m4/fstatat.m4 ================================
# 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
])
=============================== modules/fstatat ===============================
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
============================ modules/fstatat-tests ============================
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@
===============================================================================
--- NEWS.orig   Thu Nov  3 12:01:43 2011
+++ NEWS        Wed Nov  2 22:37:13 2011
@@ -12,6 +12,10 @@
 
 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.
--- doc/posix-functions/fstatat.texi.orig       Thu Nov  3 12:01:43 2011
+++ doc/posix-functions/fstatat.texi    Wed Nov  2 22:35:19 2011
@@ -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
--- lib/openat.h.orig   Thu Nov  3 12:01:43 2011
+++ lib/openat.h        Wed Nov  2 22:35:19 2011
@@ -80,6 +80,8 @@
 
 #endif
 
+#if GNULIB_FSTATAT
+
 static inline int
 statat (int fd, char const *name, struct stat *st)
 {
@@ -92,6 +94,8 @@
   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,
--- m4/openat.m4.orig   Thu Nov  3 12:01:43 2011
+++ m4/openat.m4        Wed Nov  2 22:35:51 2011
@@ -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 @@
   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 @@
   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])
--- modules/getcwd.orig Thu Nov  3 12:01:43 2011
+++ modules/getcwd      Wed Nov  2 22:43:18 2011
@@ -17,6 +17,7 @@
 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]
--- modules/linkat.orig Thu Nov  3 12:01:43 2011
+++ modules/linkat      Thu Nov  3 12:00:45 2011
@@ -17,6 +17,7 @@
 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]
--- modules/mkfifoat-tests.orig Thu Nov  3 12:01:43 2011
+++ modules/mkfifoat-tests      Wed Nov  2 22:40:15 2011
@@ -5,6 +5,7 @@
 tests/macros.h
 
 Depends-on:
+fstatat
 ignore-value
 symlink
 unlinkat
--- modules/openat.orig Thu Nov  3 12:01:43 2011
+++ modules/openat      Wed Nov  2 22:35:19 2011
@@ -3,7 +3,6 @@
 
 Files:
 lib/at-func.c
-lib/fstatat.c
 lib/mkdirat.c
 lib/openat.c
 lib/openat.h
@@ -23,7 +22,6 @@
 gettext-h
 intprops
 largefile
-lstat
 mkdir           [test $HAVE_MKDIRAT = 0]
 open
 openat-die
@@ -35,9 +33,6 @@
 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
--- modules/openat-tests.orig   Thu Nov  3 12:01:43 2011
+++ modules/openat-tests        Wed Nov  2 22:36:36 2011
@@ -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 @@
 
 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@
--- modules/utimensat.orig      Thu Nov  3 12:01:43 2011
+++ modules/utimensat   Wed Nov  2 22:48:01 2011
@@ -8,7 +8,7 @@
 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:

-- 
In memoriam Galina Romanova <http://en.wikipedia.org/wiki/Galina_Romanova>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]