+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.
@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:
@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:
{ /* 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);