New module 'fchmodat', split off from module 'openat'.
authorBruno Haible <bruno@clisp.org>
Wed, 2 Nov 2011 09:07:20 +0000 (10:07 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 2 Nov 2011 09:07:20 +0000 (10:07 +0100)
* lib/openat.h (chmodat, lchmodat): Enable only if GNULIB_FCHMODAT is
defined.
* m4/fchmodat.m4: New file, extracted from m4/openat.m4.
* m4/openat.m4 (gl_FUNC_OPENAT): Don't set GNULIB_FCHMODAT. Don't test
for fchmodat, lchmod. Don't set HAVE_FCHMODAT.
* modules/fchmodat: New file, extracted from modules/openat.
* modules/openat (Files): Remove lib/fchmodat.c.
(configure.ac): Remove AC_LIBOBJ of fchmodat.
* modules/fchmodat-tests: New file, extracted from modules/openat-tests.
* modules/openat-tests (Files): Remove tests/test-fchmodat.c.
(Makefile.am): Remove rules for test-fchmodat.
* doc/posix-functions/fchmodat.texi: Mention module 'fchmodat' instead
of module 'openat'.
* NEWS: Mention the change.

ChangeLog
NEWS
doc/posix-functions/fchmodat.texi
lib/openat.h
m4/fchmodat.m4 [new file with mode: 0644]
m4/openat.m4
modules/fchmodat [new file with mode: 0644]
modules/fchmodat-tests [new file with mode: 0644]
modules/openat
modules/openat-tests

index bdd74c6..4c743d9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2011-11-02  Bruno Haible  <bruno@clisp.org>
+
+       New module 'fchmodat', split off from module 'openat'.
+       * lib/openat.h (chmodat, lchmodat): Enable only if GNULIB_FCHMODAT is
+       defined.
+       * m4/fchmodat.m4: New file, extracted from m4/openat.m4.
+       * m4/openat.m4 (gl_FUNC_OPENAT): Don't set GNULIB_FCHMODAT. Don't test
+       for fchmodat, lchmod. Don't set HAVE_FCHMODAT.
+       * modules/fchmodat: New file, extracted from modules/openat.
+       * modules/openat (Files): Remove lib/fchmodat.c.
+       (configure.ac): Remove AC_LIBOBJ of fchmodat.
+       * modules/fchmodat-tests: New file, extracted from modules/openat-tests.
+       * modules/openat-tests (Files): Remove tests/test-fchmodat.c.
+       (Makefile.am): Remove rules for test-fchmodat.
+       * doc/posix-functions/fchmodat.texi: Mention module 'fchmodat' instead
+       of module 'openat'.
+       * NEWS: Mention the change.
+
 2011-11-02  Jim Meyering  <meyering@redhat.com>
 
        putenv: indent #definition of "environ" to placate cppi
diff --git a/NEWS b/NEWS
index 477c61c..ad6a468 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,10 @@ User visible incompatible changes
 
 Date        Modules         Changes
 
+2011-11-01  openat          This module no longer provides the fchmodat()
+                            function. If you need this function, you now need
+                            to request the 'fchmodat' module.
+
 2011-11-01  alignof         This module no longer provides the alignof() macro.
                             Use either alignof_slot() or alignof_type() instead.
 
index 2ec42d7..f15f675 100644 (file)
@@ -4,7 +4,7 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/fchmodat.html}
 
-Gnulib module: openat
+Gnulib module: fchmodat
 
 Portability problems fixed by Gnulib:
 @itemize
index 6c4e06f..fcae664 100644 (file)
@@ -64,6 +64,8 @@ lchownat (int fd, char const *file, uid_t owner, gid_t group)
 
 #endif
 
+#if GNULIB_FCHMODAT
+
 static inline int
 chmodat (int fd, char const *file, mode_t mode)
 {
@@ -76,6 +78,8 @@ lchmodat (int fd, char const *file, mode_t mode)
   return fchmodat (fd, file, mode, AT_SYMLINK_NOFOLLOW);
 }
 
+#endif
+
 static inline int
 statat (int fd, char const *name, struct stat *st)
 {
diff --git a/m4/fchmodat.m4 b/m4/fchmodat.m4
new file mode 100644 (file)
index 0000000..76d4a72
--- /dev/null
@@ -0,0 +1,17 @@
+# fchmodat.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.
+
+AC_DEFUN([gl_FUNC_FCHMODAT],
+[
+  AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
+  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+  AC_CHECK_FUNCS_ONCE([fchmodat lchmod])
+  if test $ac_cv_func_fchmodat != yes; then
+    HAVE_FCHMODAT=0
+  fi
+])
index 1886d0b..5166caf 100644 (file)
@@ -1,4 +1,4 @@
-# serial 38
+# serial 39
 # 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_FCHMODAT=1
   GNULIB_FSTATAT=1
   GNULIB_MKDIRAT=1
 
@@ -22,7 +21,7 @@ AC_DEFUN([gl_FUNC_OPENAT],
   GNULIB_UNLINKAT=1
 
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
-  AC_CHECK_FUNCS_ONCE([fchmodat lchmod mkdirat openat unlinkat])
+  AC_CHECK_FUNCS_ONCE([mkdirat openat unlinkat])
   AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
   AC_REQUIRE([gl_FUNC_UNLINK])
   case $ac_cv_func_openat+$gl_cv_func_lstat_dereferences_slashed_symlink in
@@ -42,9 +41,6 @@ AC_DEFUN([gl_FUNC_OPENAT],
     HAVE_UNLINKAT=0 # No known system with unlinkat 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
diff --git a/modules/fchmodat b/modules/fchmodat
new file mode 100644 (file)
index 0000000..92d061a
--- /dev/null
@@ -0,0 +1,42 @@
+Description:
+fchmodat() function: Change access permissions of a file at a directory.
+
+Files:
+lib/fchmodat.c
+lib/at-func.c
+lib/openat.h
+lib/openat-priv.h
+m4/fchmodat.m4
+
+Depends-on:
+dirent
+dosname
+errno
+extensions
+fchdir
+fcntl-h
+openat
+save-cwd
+stdbool
+sys_stat
+unistd
+
+configure.ac:
+gl_FUNC_FCHMODAT
+if test $HAVE_FCHMODAT = 0; then
+  AC_LIBOBJ([fchmodat])
+fi
+AC_REQUIRE([AC_C_INLINE]) dnl because 'inline' is used in lib/openat.h
+gl_MODULE_INDICATOR([fchmodat]) dnl for lib/openat.h
+gl_SYS_STAT_MODULE_INDICATOR([fchmodat])
+
+Makefile.am:
+
+Include:
+<sys/stat.h>
+
+License:
+GPL
+
+Maintainer:
+Jim Meyering, Eric Blake
diff --git a/modules/fchmodat-tests b/modules/fchmodat-tests
new file mode 100644 (file)
index 0000000..a240129
--- /dev/null
@@ -0,0 +1,13 @@
+Files:
+tests/test-fchmodat.c
+tests/signature.h
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-fchmodat
+check_PROGRAMS += test-fchmodat
+test_fchmodat_LDADD = $(LDADD) @LIBINTL@
index aaf2818..a25e83d 100644 (file)
@@ -3,7 +3,6 @@ Open a file at a directory.
 
 Files:
 lib/at-func.c
-lib/fchmodat.c
 lib/fstatat.c
 lib/mkdirat.c
 lib/openat.c
@@ -39,9 +38,6 @@ unlink          [test $REPLACE_UNLINKAT = 1]
 configure.ac:
 gl_FUNC_OPENAT
 AC_LIBOBJ([openat-proc])
-if test $HAVE_FCHMODAT = 0; then
-  AC_LIBOBJ([fchmodat])
-fi
 if test $ac_cv_func_fstatat = no || test $REPLACE_FSTATAT = 1; then
   AC_LIBOBJ([fstatat])
 fi
index 461f1d4..8000033 100644 (file)
@@ -8,7 +8,6 @@ tests/test-fstatat.c
 tests/test-mkdirat.c
 tests/test-openat.c
 tests/test-unlinkat.c
-tests/test-fchmodat.c
 tests/signature.h
 tests/macros.h
 
@@ -23,10 +22,9 @@ configure.ac:
 
 Makefile.am:
 TESTS += \
-  test-fchmodat test-fstatat test-mkdirat test-openat test-unlinkat
+  test-fstatat test-mkdirat test-openat test-unlinkat
 check_PROGRAMS += \
-  test-fchmodat test-fstatat test-mkdirat test-openat test-unlinkat
-test_fchmodat_LDADD = $(LDADD) @LIBINTL@
+  test-fstatat test-mkdirat test-openat test-unlinkat
 test_fstatat_LDADD = $(LDADD) @LIBINTL@
 test_mkdirat_LDADD = $(LDADD) @LIBINTL@
 test_openat_LDADD = $(LDADD) @LIBINTL@