]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(do_link): Allow creation of a hard link to a dangling
authorJim Meyering <jim@meyering.net>
Sun, 31 Jan 1999 18:41:36 +0000 (18:41 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 31 Jan 1999 18:41:36 +0000 (18:41 +0000)
symlink.  Reported by Alexey Solovyov:

src/ln.c

index 093b9e6f43b0e90648f917df9cbcf8994f072393..e60cc6e74e79eea4fd55ef2aa24075db9a0e6fc0 100644 (file)
--- a/src/ln.c
+++ b/src/ln.c
@@ -174,8 +174,14 @@ do_link (const char *source, const char *dest)
     {
       if (stat (source, &source_stats) != 0)
        {
-         error (0, errno, "%s", source);
-         return 1;
+         /* This still could be a legitimate request:
+            if SOURCE is a dangling symlink.  */
+         if (errno != ENOENT
+             || lstat (source, &source_stats) != 0)
+           {
+             error (0, errno, "%s", source);
+             return 1;
+           }
        }
       if (!hard_dir_link && S_ISDIR (source_stats.st_mode))
        {