diff options
author | Jim Meyering <jim@meyering.net> | 1999-01-18 02:41:13 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1999-01-18 02:41:13 +0000 |
commit | e11c197cc2d66fe171483b8e1eb818098d3bfe81 (patch) | |
tree | c6ba651fae934eed8fe4978316877683a6fad8fa /src | |
parent | 5967a93b4fa118383e93cff94f9880a2eba21bce (diff) | |
download | coreutils-e11c197cc2d66fe171483b8e1eb818098d3bfe81.tar.xz |
(do_link): Try to remove DEST even after renaming it.
This fixes a bug reported by Jamie Lokier.
Diffstat (limited to 'src')
-rw-r--r-- | src/ln.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -283,7 +283,12 @@ do_link (const char *source, const char *dest) dest_backup = NULL; } } - else if (unlink (dest) && errno != ENOENT) + + /* Try to unlink DEST even if we may have renamed it. In some unusual + cases (when DEST and DEST_BACKUP are hard-links that refer to the + same file), rename succeeds and DEST remains. If we didn't remove + DEST in that case, the subsequent LINKFUNC call would fail. */ + if (unlink (dest) && errno != ENOENT) { error (0, errno, _("cannot remove `%s'"), dest); return 1; |