summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--doc/posix-functions/rename.texi10
-rw-r--r--doc/posix-functions/renameat.texi10
-rw-r--r--tests/test-rename.h8
4 files changed, 38 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index b07825ff93..3d87c9013f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2017-08-15 Paul Eggert <eggert@cs.ucla.edu>
+
+ rename: document+test NetBSD rename
+ Test failure reported by Bruno Haible in:
+ http://lists.gnu.org/archive/html/bug-gnulib/2017-08/msg00104.html
+ This is an area where NetBSD is better-behaved than POSIX,
+ so allow the NetBSD behavior in tests.
+ * doc/posix-functions/rename.texi:
+ * doc/posix-functions/renameat.texi: Document NetBSD behavior.
+ * tests/test-rename.h (test_rename): Allow NetBSD behavior.
+
2017-08-15 Bruno Haible <bruno@clisp.org>
renameat: Ensure declaration in <stdio.h> on NetBSD.
diff --git a/doc/posix-functions/rename.texi b/doc/posix-functions/rename.texi
index 1e806562ff..b024b96c1b 100644
--- a/doc/posix-functions/rename.texi
+++ b/doc/posix-functions/rename.texi
@@ -60,6 +60,16 @@ is counter-intuitive, so on some systems, @code{rename} fails with
@code{ENOTDIR} if either argument is a symlink with a trailing slash:
glibc, OpenBSD, Cygwin 1.7.
@item
+POSIX requires that @code{renameat} do nothing and return 0 if the
+source and destination are hard links to the same file. This behavior
+is counterintuitive, and on some systems @code{renameat} is a no-op in
+this way only if the source and destination identify the same
+directory entry. On these systems, for example, although renaming
+@file{./f} to @file{f} is a no-op, renaming @file{f} to @file{g}
+deletes @file{f} when @file{f} and @file{g} are hard links to the same
+file:
+NetBSD.
+@item
After renaming a non-empty directory over an existing empty directory,
the old directory name is still visible through the @code{stat} function
for 30 seconds after the rename, on NFS file systems, on some platforms:
diff --git a/doc/posix-functions/renameat.texi b/doc/posix-functions/renameat.texi
index ee01b89401..dd971323e7 100644
--- a/doc/posix-functions/renameat.texi
+++ b/doc/posix-functions/renameat.texi
@@ -39,6 +39,16 @@ is counter-intuitive, so on some systems, @code{renameat} fails with
@code{ENOTDIR} if either argument is a symlink with a trailing slash:
glibc, OpenBSD, Cygwin 1.7.
@item
+POSIX requires that @code{renameat} do nothing and return 0 if the
+source and destination are hard links to the same file. This behavior
+is counterintuitive, and on some systems @code{renameat} is a no-op in
+this way only if the source and destination identify the same
+directory entry. On these systems, for example, although renaming
+@file{./f} to @file{f} is a no-op, renaming @file{f} to @file{g}
+deletes @file{f} when @file{f} and @file{g} are hard links to the same
+file:
+NetBSD.
+@item
After renaming a non-empty directory over an existing empty directory,
the old directory name is still visible through the @code{stat} function
for 30 seconds after the rename, on NFS file systems, on some platforms:
diff --git a/tests/test-rename.h b/tests/test-rename.h
index 93a1041db1..010d58d76c 100644
--- a/tests/test-rename.h
+++ b/tests/test-rename.h
@@ -522,7 +522,13 @@ test_rename (int (*func) (char const *, char const *), bool print)
{ /* File onto hard link. */
ASSERT (func (BASE "file", BASE "file2") == 0);
memset (&st, 0, sizeof st);
- ASSERT (stat (BASE "file", &st) == 0);
+ if (stat (BASE "file", &st) != 0)
+ {
+ /* This can happen on NetBSD. */
+ ASSERT (errno == ENOENT);
+ ASSERT (link (BASE "file2", BASE "file") == 0);
+ ASSERT (stat (BASE "file", &st) == 0);
+ }
ASSERT (st.st_size == 2);
memset (&st, 0, sizeof st);
ASSERT (stat (BASE "file2", &st) == 0);