]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
renameatu: Use issymlinkat.
authorBruno Haible <bruno@clisp.org>
Thu, 14 Aug 2025 20:23:29 +0000 (22:23 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 14 Aug 2025 22:23:35 +0000 (00:23 +0200)
* lib/renameatu.c (renameatu): Use issymlinkat instead of readlinkat.
* modules/renameatu (Depends-on): Remove readlinkat. Add issymlinkat.

ChangeLog
lib/renameatu.c
modules/renameatu

index 6c6875f353df49a33de5925ddb17c551e1b4982d..d0d03f92ae1332fd663925a115495fbc854d1401 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-08-14  Bruno Haible  <bruno@clisp.org>
+
+       renameatu: Use issymlinkat.
+       * lib/renameatu.c (renameatu): Use issymlinkat instead of readlinkat.
+       * modules/renameatu (Depends-on): Remove readlinkat. Add issymlinkat.
+
 2025-08-14  Bruno Haible  <bruno@clisp.org>
 
        rename: Use issymlink.
index 725e031abce8890744f0cd97eed67f4032dbf5e5..64a7f5285a9bd1df40c450c2e04243be0cd1e7c6 100644 (file)
@@ -204,17 +204,14 @@ renameatu (int fd1, char const *src, int fd2, char const *dst,
           goto out;
         }
       strip_trailing_slashes (src_temp);
-      char linkbuf[1];
-      if (readlinkat (fd1, src_temp, linkbuf, sizeof linkbuf) < 0)
+      int ret = issymlinkat (fd1, src_temp);
+      if (ret > 0)
+        goto out;
+      if (ret < 0)
         {
-          if (errno != EINVAL)
-            {
-              rename_errno = errno;
-              goto out;
-            }
+          rename_errno = errno;
+          goto out;
         }
-      else
-        goto out;
     }
   if (dst_slash)
     {
@@ -225,17 +222,14 @@ renameatu (int fd1, char const *src, int fd2, char const *dst,
           goto out;
         }
       strip_trailing_slashes (dst_temp);
-      char linkbuf[1];
-      if (readlinkat (fd2, dst_temp, linkbuf, sizeof linkbuf) < 0)
+      int ret = issymlinkat (fd2, dst_temp);
+      if (ret > 0)
+        goto out;
+      if (ret < 0 && errno != ENOENT)
         {
-          if (errno != ENOENT && errno != EINVAL)
-            {
-              rename_errno = errno;
-              goto out;
-            }
+          rename_errno = errno;
+          goto out;
         }
-      else
-        goto out;
     }
 # endif /* RENAME_TRAILING_SLASH_SOURCE_BUG */
 
index 2947159adbe4594272b8e0b9221ccbec90594df8..f4f12acd133bad216fe10f11dd22ac520d0a8524 100644 (file)
@@ -14,7 +14,7 @@ fcntl-h
 filenamecat-lgpl [test $HAVE_RENAMEAT = 0 || test $REPLACE_RENAMEAT = 1]
 openat-h         [test $HAVE_RENAMEAT = 0 || test $REPLACE_RENAMEAT = 1]
 fstatat          [test $REPLACE_RENAMEAT = 1]
-readlinkat       [test $REPLACE_RENAMEAT = 1]
+issymlinkat      [test $REPLACE_RENAMEAT = 1]
 bool             [test $REPLACE_RENAMEAT = 1]
 at-internal      [test $HAVE_RENAMEAT = 0]
 filename         [test $HAVE_RENAMEAT = 0]