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

ChangeLog
lib/unlink.c
modules/unlink

index d0d03f92ae1332fd663925a115495fbc854d1401..6fcc5d6eae60960105295b9aaf455b00289093c8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-08-14  Bruno Haible  <bruno@clisp.org>
+
+       unlink: Use issymlink.
+       * lib/unlink.c (rpl_unlink): Use issymlink instead of readlink.
+       * modules/unlink (Depends-on): Remove readlink. Add issymlink.
+
 2025-08-14  Bruno Haible  <bruno@clisp.org>
 
        renameatu: Use issymlinkat.
index 6459e22e0b5a6a18729a8c289c0a65efbb98127d..9963ddf2928ae9745792cbc065e41b0d5b5ae1f5 100644 (file)
@@ -72,9 +72,7 @@ rpl_unlink (char const *name)
           memcpy (short_name, name, len);
           while (len && ISSLASH (short_name[len - 1]))
             short_name[--len] = '\0';
-          char linkbuf[1];
-          if (len && ! (readlink (short_name, linkbuf, 1) < 0
-                        && errno == EINVAL))
+          if (len && issymlink (short_name) != 0)
             {
               free (short_name);
               errno = EPERM;
index 43c4f8440b5e5b5a95464ac642609cc5f27f61be..76f5cba79a4458b2cee7646151a8e3249319f516 100644 (file)
@@ -8,9 +8,9 @@ m4/unlink.m4
 Depends-on:
 unistd-h
 filename        [test $REPLACE_UNLINK = 1]
+issymlink       [test $REPLACE_UNLINK = 1]
 lstat           [test $REPLACE_UNLINK = 1]
 malloc-posix    [test $REPLACE_UNLINK = 1]
-readlink        [test $REPLACE_UNLINK = 1]
 
 configure.ac:
 gl_FUNC_UNLINK