]> Savannah Git Hosting - gnulib.git/commitdiff
rename: port better to NetBSD
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 16 Aug 2017 15:34:41 +0000 (08:34 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 16 Aug 2017 15:35:19 +0000 (08:35 -0700)
* doc/posix-functions/rename.texi (rename): NetBSD 7
does not have the link-count bug.
* m4/rename.m4 (gl_FUNC_RENAME): Don’t consider NetBSD to be
broken merely because rename ("a", "b") removes "a" when the two
names are hard links to the same file.

ChangeLog
doc/posix-functions/rename.texi
m4/rename.m4

index 259b9992d5289986357a448310f4c44c0689d11a..422d0a3723a17e82c1089b10869afc5be3deb15d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2017-08-16  Paul Eggert  <eggert@cs.ucla.edu>
+
+       rename: port better to NetBSD
+       * doc/posix-functions/rename.texi (rename): NetBSD 7
+       does not have the link-count bug.
+       * m4/rename.m4 (gl_FUNC_RENAME): Don’t consider NetBSD to be
+       broken merely because rename ("a", "b") removes "a" when the two
+       names are hard links to the same file.
+
 2017-08-16  Bruno Haible  <bruno@clisp.org>
 
        iconv_open, uni*: Add support for VPATH builds with OpenBSD 'make'.
index 12c3be4d61e546821defb63cbf9f01fa6d566d9f..97c44a566629c78d99fdc091c898bf8a534e207d 100644 (file)
@@ -28,7 +28,7 @@ Solaris 9.
 @item
 This function incorrectly reduces the link count when comparing two
 spellings of a hard link on some platforms:
-NetBSD 1.6, NetBSD 7.0 without @code{-D_XOPEN_SOURCE=500}, Cygwin 1.5.x.
+NetBSD 1.6, Cygwin 1.5.x.
 @item
 This function will not always replace an existing destination on some
 platforms:
index 9a3730735cd1fbbd9435559e07fde9814b463d60..a702b3eee65c9c35f3edf9d24006ac0099f8cefc 100644 (file)
@@ -1,4 +1,4 @@
-# serial 27
+# serial 28
 
 # Copyright (C) 2001, 2003, 2005-2006, 2009-2017 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
@@ -136,11 +136,12 @@ AC_DEFUN([gl_FUNC_RENAME],
   AC_CACHE_CHECK([whether rename manages hard links correctly],
     [gl_cv_func_rename_link_works],
     [if test $ac_cv_func_link = yes; then
-       rm -rf conftest.f conftest.f1
-       if touch conftest.f && ln conftest.f conftest.f1 &&
+       rm -rf conftest.f conftest.f1 conftest.f2
+       if touch conftest.f conftest.f2 && ln conftest.f conftest.f1 &&
            set x `ls -i conftest.f conftest.f1` && test "$2" = "$4"; then
          AC_RUN_IFELSE(
            [AC_LANG_PROGRAM([[
+#             include <errno.h>
 #             include <stdio.h>
 #             include <stdlib.h>
 #             include <unistd.h>
@@ -150,10 +151,18 @@ AC_DEFUN([gl_FUNC_RENAME],
                   result |= 1;
                 if (unlink ("conftest.f1"))
                   result |= 2;
-                if (rename ("conftest.f", "conftest.f"))
+
+                /* Allow either the POSIX-required behavior, where the
+                   previous rename kept conftest.f, or the (better) NetBSD
+                   behavior, where it removed conftest.f.  */
+                if (rename ("conftest.f", "conftest.f") != 0
+                    && errno != ENOENT)
                   result |= 4;
+
                 if (rename ("conftest.f1", "conftest.f1") == 0)
                   result |= 8;
+                if (rename ("conftest.f2", "conftest.f2") != 0)
+                  result |= 16;
                 return result;
               ]])],
            [gl_cv_func_rename_link_works=yes],
@@ -171,7 +180,7 @@ AC_DEFUN([gl_FUNC_RENAME],
        else
          gl_cv_func_rename_link_works="guessing no"
        fi
-       rm -rf conftest.f conftest.f1
+       rm -rf conftest.f conftest.f1 conftest.f2
      else
        gl_cv_func_rename_link_works=yes
      fi