]> Savannah Git Hosting - gnulib.git/commitdiff
rename: document+test NetBSD rename
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 15 Aug 2017 22:53:50 +0000 (15:53 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 15 Aug 2017 22:54:16 +0000 (15:54 -0700)
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.

ChangeLog
doc/posix-functions/rename.texi
doc/posix-functions/renameat.texi
tests/test-rename.h

index b07825ff938c7dd10fbaddfdfdf037fcef9eefb2..3d87c9013fe8eece07141ea14330ec0c6a343331 100644 (file)
--- 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.
index 1e806562ffac7000b9d2076e81f442f75f58e666..b024b96c1b1b4fbda0b160b1e30eed7529e5972c 100644 (file)
@@ -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:
index ee01b89401bf98af7deedec1aee20b84f2f4912d..dd971323e75482aeca96940b2003edbee2db7e64 100644 (file)
@@ -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:
index 93a1041db1023d1e4a23c16583141c1397204cfe..010d58d76c3ac8ab8a6b24b559b79556934c0d19 100644 (file)
@@ -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);