From: Bruno Haible Date: Thu, 14 Aug 2025 20:21:23 +0000 (+0200) Subject: rename: Use issymlink. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3dbfcbf5ed4e857eeb0106a07977d389561791b0;p=thirdparty%2Fgnulib.git rename: Use issymlink. * lib/rename.c (rpl_rename): Use issymlink instead of readlink. * modules/rename (Depends-on): Remove readlink. Add issymlink. --- diff --git a/ChangeLog b/ChangeLog index 386c8bd475..6c6875f353 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2025-08-14 Bruno Haible + + 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 fchmodat: Use issymlinkat. diff --git a/lib/rename.c b/lib/rename.c index f4f191d61f..7efd64f992 100644 --- a/lib/rename.c +++ b/lib/rename.c @@ -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; diff --git a/modules/rename b/modules/rename index fbc787d3e5..0f061fbf25 100644 --- a/modules/rename +++ b/modules/rename @@ -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]