]> Savannah Git Hosting - gnulib.git/commitdiff
renameatu: Work around a GNU/Hurd bug.
authorCollin Funk <collin.funk1@gmail.com>
Sun, 19 Jan 2025 05:06:49 +0000 (21:06 -0800)
committerBruno Haible <bruno@clisp.org>
Sun, 2 Feb 2025 09:36:43 +0000 (10:36 +0100)
* m4/renameat.m4 (gl_FUNC_RENAMEAT): Check if renameat2 handles trailing
slashes.
* doc/glibc-functions/renameat2.texi: Mention the GNU/Hurd bug.

ChangeLog
doc/glibc-functions/renameat2.texi
m4/renameat.m4

index c11ad91e2bbe4e2d1763792351ffc551aafb2fd7..26cc55b97d068718fdfdbecedf055580a2e9396a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2025-01-18  Collin Funk  <collin.funk1@gmail.com>
+
+       renameatu: Work around a GNU/Hurd bug.
+       * m4/renameat.m4 (gl_FUNC_RENAMEAT): Check if renameat2 handles trailing
+       slashes.
+       * doc/glibc-functions/renameat2.texi: Mention the GNU/Hurd bug.
+
 2025-01-17  Paul Eggert  <eggert@cs.ucla.edu>
 
        alignasof: port to IBM XL C V16.1
index d3f8c4e8a347e7a888c8554e954267738a76dd6d..5f281ee0a38592f3d1ed7c2a8a6c9847c7927027 100644 (file)
@@ -19,6 +19,12 @@ glibc 2.27, macOS 14, FreeBSD 14.0, NetBSD 10.0, OpenBSD 7.5, Minix 3.1.8, AIX 7
 This function succeeds when the @code{RENAME_NOREPLACE} flag is specified
 and the source and destination are the same file, on some platforms:
 Cygwin 3.4.6.
+@item
+@code{renameat2 (AT_FDCWD, "file", AT_FDCWD, "new/" ...)} succeeds
+instead of failing and setting @code{errno} to @code{ENOTDIR}, on some
+platforms:
+@c https://sourceware.org/bugzilla/show_bug.cgi?id=32570
+GNU/Hurd.
 @end itemize
 
 @mindex renameatu
index f967ae15932ea9c9736250fd12467e58dcf0009a..129e7fe067ae49df5acc53bd1478664a35382243 100644 (file)
@@ -1,5 +1,5 @@
 # renameat.m4
-# serial 5
+# serial 6
 dnl Copyright (C) 2009-2025 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -29,17 +29,25 @@ AC_DEFUN([gl_FUNC_RENAMEAT],
   if test $ac_cv_func_renameat2 = yes; then
     AC_CACHE_CHECK([whether renameat2 works],
       [gl_cv_func_renameat2_works],
-      [AC_RUN_IFELSE(
+      [rm -rf conftest.a conftest.b
+       touch conftest.a
+       AC_RUN_IFELSE(
          [AC_LANG_SOURCE([[
+            #include <unistd.h>
             #include <fcntl.h>
             #include <stdio.h>
             int main ()
             {
+              int result = 0;
               /* This test fails on Cygwin 3.4.6.  */
               if (renameat2 (AT_FDCWD, "conftest.c", AT_FDCWD, "conftest.c",
                              RENAME_NOREPLACE) == 0)
-                return 1;
-              return 0;
+                result |= 1;
+              /* This test fails on GNU/Hurd.  */
+              if (renameat2 (AT_FDCWD, "conftest.a", AT_FDCWD, "conftest.b/", 0)
+                  == 0)
+                result |= 2;
+              return result;
             }
          ]])],
          [gl_cv_func_renameat2_works=yes],
@@ -47,12 +55,15 @@ AC_DEFUN([gl_FUNC_RENAMEAT],
          [case "$host_os" in
                      # Guess yes on Linux.
             linux*)  gl_cv_func_renameat2_works="guessing yes" ;;
+                     # Guess no on GNU/Hurd.
+            gnu*)    gl_cv_func_renameat2_works="guessing no" ;;
                      # Guess no on Cygwin.
             cygwin*) gl_cv_func_renameat2_works="guessing no" ;;
                      # If we don't know, obey --enable-cross-guesses.
             *)       gl_cv_func_renameat2_works="$gl_cross_guess_normal" ;;
           esac
          ])
+       rm -rf conftest.a conftest.b
       ])
     case "$gl_cv_func_renameat2_works" in
       *yes)