From: Jim Meyering Date: Sun, 31 Jan 1999 18:41:36 +0000 (+0000) Subject: (do_link): Allow creation of a hard link to a dangling X-Git-Tag: TEXTUTILS-1_22h~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4872440d7a09f770322b9691dc8313833f37d330;p=thirdparty%2Fcoreutils.git (do_link): Allow creation of a hard link to a dangling symlink. Reported by Alexey Solovyov: --- diff --git a/src/ln.c b/src/ln.c index 093b9e6f43..e60cc6e74e 100644 --- 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)) {