From: Bruno Haible <bruno@clisp.org>
Date: Wed, 2 Nov 2011 21:34:51 +0000 (+0100)
Subject: New module 'unlinkat', split off from module 'openat'.
X-Git-Tag: v0.1~1504
X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=84c3f9cf54eaa688c5a1a26925886535079a91de;p=gnulib.git

New module 'unlinkat', split off from module 'openat'.

* m4/unlinkat.m4: New file, extracted from m4/openat.m4.
* m4/openat.m4 (gl_FUNC_OPENAT): Don't set GNULIB_UNLINKAT,
REPLACE_UNLINKAT, HAVE_UNLINKAT. Don't test for unlinkat.
* modules/unlinkat: New file, extracted from modules/openat. Correct
the dependency conditions.
* modules/openat (Files): Remove lib/unlinkat.c.
(Depends-on): Remove rmdir, unlink.
(configure.ac): Remove AC_LIBOBJ of unlinkat.
* modules/unlinkat-tests: New file, extracted from modules/openat-tests.
* modules/openat-tests (Files): Remove tests/test-unlinkat.c,
tests/test-rmdir.h, tests/test-unlink.h.
(Depends-on): Remove unlinkdir.
(Makefile.am): Remove rules for test-unlinkat.
* doc/posix-functions/unlinkat.texi: Mention module 'unlinkat' instead
of module 'openat'.
* NEWS: Mention the change.
* modules/linkat-tests (Depends-on): Add unlinkat.
* modules/mkfifoat-tests (Depends-on): Likewise.
* modules/readlinkat-tests (Depends-on): Likewise.
---

diff --git a/ChangeLog b/ChangeLog
index 4c743d96f7..4c1bde0e58 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2011-11-03  Bruno Haible  <bruno@clisp.org>
+
+	New module 'unlinkat', split off from module 'openat'.
+	* m4/unlinkat.m4: New file, extracted from m4/openat.m4.
+	* m4/openat.m4 (gl_FUNC_OPENAT): Don't set GNULIB_UNLINKAT,
+	REPLACE_UNLINKAT, HAVE_UNLINKAT. Don't test for unlinkat.
+	* modules/unlinkat: New file, extracted from modules/openat. Correct
+	the dependency conditions.
+	* modules/openat (Files): Remove lib/unlinkat.c.
+	(Depends-on): Remove rmdir, unlink.
+	(configure.ac): Remove AC_LIBOBJ of unlinkat.
+	* modules/unlinkat-tests: New file, extracted from modules/openat-tests.
+	* modules/openat-tests (Files): Remove tests/test-unlinkat.c,
+	tests/test-rmdir.h, tests/test-unlink.h.
+	(Depends-on): Remove unlinkdir.
+	(Makefile.am): Remove rules for test-unlinkat.
+	* doc/posix-functions/unlinkat.texi: Mention module 'unlinkat' instead
+	of module 'openat'.
+	* NEWS: Mention the change.
+	* modules/linkat-tests (Depends-on): Add unlinkat.
+	* modules/mkfifoat-tests (Depends-on): Likewise.
+	* modules/readlinkat-tests (Depends-on): Likewise.
+
 2011-11-02  Bruno Haible  <bruno@clisp.org>
 
 	New module 'fchmodat', split off from module 'openat'.
diff --git a/NEWS b/NEWS
index ad6a468bb5..045de1f1d6 100644
--- a/NEWS
+++ b/NEWS
@@ -12,7 +12,11 @@ User visible incompatible changes
 
 Date        Modules         Changes
 
-2011-11-01  openat          This module no longer provides the fchmodat()
+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.
+
+2011-11-02  openat          This module no longer provides the fchmodat()
                             function. If you need this function, you now need
                             to request the 'fchmodat' module.
 
diff --git a/doc/posix-functions/unlinkat.texi b/doc/posix-functions/unlinkat.texi
index 40bc21bc94..6bb943623c 100644
--- a/doc/posix-functions/unlinkat.texi
+++ b/doc/posix-functions/unlinkat.texi
@@ -4,7 +4,7 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/unlinkat.html}
 
-Gnulib module: openat
+Gnulib module: unlinkat
 
 Portability problems fixed by Gnulib:
 @itemize
diff --git a/m4/openat.m4 b/m4/openat.m4
index 5166caf5ef..86e3144771 100644
--- a/m4/openat.m4
+++ b/m4/openat.m4
@@ -1,4 +1,4 @@
-# serial 39
+# serial 40
 # See if we need to use our replacement for Solaris' openat et al functions.
 
 dnl Copyright (C) 2004-2011 Free Software Foundation, Inc.
@@ -17,28 +17,19 @@ AC_DEFUN([gl_FUNC_OPENAT],
   GNULIB_FSTATAT=1
   GNULIB_MKDIRAT=1
 
-  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
-  GNULIB_UNLINKAT=1
-
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
-  AC_CHECK_FUNCS_ONCE([mkdirat openat unlinkat])
+  AC_CHECK_FUNCS_ONCE([mkdirat openat])
   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
   yes+yes)
-    # GNU/Hurd has unlinkat, but it has the same bug as unlink.
-    if test $REPLACE_UNLINK = 1; then
-      REPLACE_UNLINKAT=1
-    fi ;;
+    ;;
   yes+*)
     # Solaris 9 has *at functions, but uniformly mishandles trailing
     # slash in all of them.
     REPLACE_OPENAT=1
-    REPLACE_UNLINKAT=1
     ;;
   *)
     HAVE_OPENAT=0
-    HAVE_UNLINKAT=0 # No known system with unlinkat but not openat
     gl_PREREQ_OPENAT;;
   esac
   if test $ac_cv_func_mkdirat != yes; then
diff --git a/m4/unlinkat.m4 b/m4/unlinkat.m4
new file mode 100644
index 0000000000..724d3cdc6a
--- /dev/null
+++ b/m4/unlinkat.m4
@@ -0,0 +1,30 @@
+# unlinkat.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_UNLINKAT],
+[
+  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+  AC_CHECK_FUNCS_ONCE([unlinkat])
+  AC_REQUIRE([gl_FUNC_UNLINK])
+  AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
+  if test $ac_cv_func_unlinkat = no; then
+    HAVE_UNLINKAT=0
+  else
+    if test $gl_cv_func_lstat_dereferences_slashed_symlink != yes; then
+      # Solaris 9 has *at functions, but uniformly mishandles trailing
+      # slash in all of them.
+      REPLACE_UNLINKAT=1
+    else
+      # GNU/Hurd has unlinkat, but it has the same bug as unlink.
+      if test $REPLACE_UNLINK = 1; then
+        REPLACE_UNLINKAT=1
+      fi
+    fi
+  fi
+])
diff --git a/modules/linkat-tests b/modules/linkat-tests
index a65a3824f4..92cb43f82e 100644
--- a/modules/linkat-tests
+++ b/modules/linkat-tests
@@ -10,6 +10,7 @@ areadlink-with-size
 filenamecat-lgpl
 getcwd-lgpl
 same-inode
+unlinkat
 
 configure.ac:
 
diff --git a/modules/mkfifoat-tests b/modules/mkfifoat-tests
index 8be33df05d..b50bbf5767 100644
--- a/modules/mkfifoat-tests
+++ b/modules/mkfifoat-tests
@@ -7,6 +7,7 @@ tests/macros.h
 Depends-on:
 ignore-value
 symlink
+unlinkat
 
 configure.ac:
 
diff --git a/modules/openat b/modules/openat
index a25e83d59f..167fa92147 100644
--- a/modules/openat
+++ b/modules/openat
@@ -9,7 +9,6 @@ lib/openat.c
 lib/openat.h
 lib/openat-priv.h
 lib/openat-proc.c
-lib/unlinkat.c
 m4/openat.m4
 m4/mode_t.m4
 
@@ -28,12 +27,10 @@ lstat
 mkdir           [test $HAVE_MKDIRAT = 0]
 open
 openat-die
-rmdir           [test $REPLACE_UNLINKAT = 1]
 save-cwd
 stdbool
 sys_stat
 unistd
-unlink          [test $REPLACE_UNLINKAT = 1]
 
 configure.ac:
 gl_FUNC_OPENAT
@@ -47,9 +44,6 @@ fi
 if test $HAVE_OPENAT = 0 || test $REPLACE_OPENAT = 1; then
   AC_LIBOBJ([openat])
 fi
-if test $ac_cv_func_unlinkat = no || test $REPLACE_UNLINKAT = 1; then
-  AC_LIBOBJ([unlinkat])
-fi
 
 Makefile.am:
 
diff --git a/modules/openat-tests b/modules/openat-tests
index 80000333dd..bdefca3f83 100644
--- a/modules/openat-tests
+++ b/modules/openat-tests
@@ -1,13 +1,10 @@
 Files:
 tests/test-lstat.h
 tests/test-mkdir.h
-tests/test-rmdir.h
 tests/test-stat.h
-tests/test-unlink.h
 tests/test-fstatat.c
 tests/test-mkdirat.c
 tests/test-openat.c
-tests/test-unlinkat.c
 tests/signature.h
 tests/macros.h
 
@@ -16,16 +13,14 @@ getcwd-lgpl
 ignore-value
 progname
 symlink
-unlinkdir
 
 configure.ac:
 
 Makefile.am:
 TESTS += \
-  test-fstatat test-mkdirat test-openat test-unlinkat
+  test-fstatat test-mkdirat test-openat
 check_PROGRAMS += \
-  test-fstatat test-mkdirat test-openat test-unlinkat
+  test-fstatat test-mkdirat test-openat
 test_fstatat_LDADD = $(LDADD) @LIBINTL@
 test_mkdirat_LDADD = $(LDADD) @LIBINTL@
 test_openat_LDADD = $(LDADD) @LIBINTL@
-test_unlinkat_LDADD = $(LDADD) @LIBINTL@
diff --git a/modules/readlinkat-tests b/modules/readlinkat-tests
index de23df8dde..6c57fdfd46 100644
--- a/modules/readlinkat-tests
+++ b/modules/readlinkat-tests
@@ -7,6 +7,7 @@ tests/macros.h
 Depends-on:
 ignore-value
 symlinkat
+unlinkat
 
 configure.ac:
 
diff --git a/modules/unlinkat b/modules/unlinkat
new file mode 100644
index 0000000000..b01d91e3da
--- /dev/null
+++ b/modules/unlinkat
@@ -0,0 +1,43 @@
+Description:
+unlinkat() function: Remove a file at a directory.
+
+Files:
+lib/unlinkat.c
+lib/at-func.c
+lib/openat.h
+lib/openat-priv.h
+m4/unlinkat.m4
+
+Depends-on:
+dirent
+dosname
+errno
+extensions
+fchdir
+fcntl-h
+openat
+openat-die
+rmdir           [test $HAVE_UNLINKAT = 0]
+save-cwd
+stdbool
+sys_stat
+unistd
+unlink          [test $HAVE_UNLINKAT = 0]
+
+configure.ac:
+gl_FUNC_UNLINKAT
+if test $HAVE_UNLINKAT = 0 || test $REPLACE_UNLINKAT = 1; then
+  AC_LIBOBJ([unlinkat])
+fi
+gl_UNISTD_MODULE_INDICATOR([unlinkat])
+
+Makefile.am:
+
+Include:
+<unistd.h>
+
+License:
+GPL
+
+Maintainer:
+Jim Meyering, Eric Blake
diff --git a/modules/unlinkat-tests b/modules/unlinkat-tests
new file mode 100644
index 0000000000..266ead7536
--- /dev/null
+++ b/modules/unlinkat-tests
@@ -0,0 +1,19 @@
+Files:
+tests/test-unlinkat.c
+tests/test-rmdir.h
+tests/test-unlink.h
+tests/signature.h
+tests/macros.h
+
+Depends-on:
+ignore-value
+progname
+symlink
+unlinkdir
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-unlinkat
+check_PROGRAMS += test-unlinkat
+test_unlinkat_LDADD = $(LDADD) @LIBINTL@