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

ChangeLog
lib/rename.c
modules/rename

index 386c8bd475e99257b5415d568a30c6aa482cadd8..6c6875f353df49a33de5925ddb17c551e1b4982d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-08-14  Bruno Haible  <bruno@clisp.org>
+
+       rename: Use issymlink.
+       * lib/rename.c (rpl_rename): Use issymlink instead of readlink.
+       * modules/rename (Depends-on): Remove readlink. Add issymlink.
+
 2025-08-14  Bruno Haible  <bruno@clisp.org>
 
        fchmodat: Use issymlinkat.
index f4f191d61f9d2fbefa7bb6f35ae8bcb3ef30b1a5..7efd64f992e96d00b00bf82406608186dce05d9e 100644 (file)
@@ -389,10 +389,10 @@ rpl_rename (char const *src, char const *dst)
           goto out;
         }
       strip_trailing_slashes (src_temp);
-      char linkbuf[1];
-      if (0 <= readlink (src_temp, linkbuf, 1))
+      int ret = issymlink (src_temp);
+      if (ret > 0)
         goto out;
-      if (errno != EINVAL)
+      if (ret < 0)
         {
           rename_errno = errno;
           goto out;
@@ -407,10 +407,10 @@ rpl_rename (char const *src, char const *dst)
           goto out;
         }
       strip_trailing_slashes (dst_temp);
-      char linkbuf[1];
-      if (0 <= readlink (dst_temp, linkbuf, 1))
+      int ret = issymlink (dst_temp);
+      if (ret > 0)
         goto out;
-      if (errno != EINVAL && errno != ENOENT)
+      if (ret < 0 && errno != ENOENT)
         {
           rename_errno = errno;
           goto out;
index fbc787d3e57c8e47c7512a7a6e76003d3b37ae8c..0f061fbf25c074d90ccd934a316c0d4c7d8e4cb0 100644 (file)
@@ -11,8 +11,8 @@ canonicalize-lgpl [test $REPLACE_RENAME = 1]
 chdir             [test $REPLACE_RENAME = 1]
 dirname-lgpl      [test $REPLACE_RENAME = 1]
 free-posix        [test $REPLACE_RENAME = 1]
+issymlink         [test $REPLACE_RENAME = 1]
 lstat             [test $REPLACE_RENAME = 1]
-readlink          [test $REPLACE_RENAME = 1]
 rmdir             [test $REPLACE_RENAME = 1]
 same-inode        [test $REPLACE_RENAME = 1]
 stat              [test $REPLACE_RENAME = 1]