bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#6960: mv refuses to move a symlink over a hard link to the same file


From: Paul Eggert
Subject: bug#6960: mv refuses to move a symlink over a hard link to the same file
Date: Mon, 30 Jan 2012 09:46:24 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111222 Thunderbird/9.0

On 01/30/2012 03:41 AM, Jim Meyering wrote:
>   /* At this point, it is normally an error (data loss) to move a symlink
>      onto its referent, but in at least one narrow case, it is not:
>      In move mode, when
>      1) src is a symlink,
>      2) dest is not a symlink,
>      3) dest has a link count of 2 or more and
>      4) dest and the referent of src are not the same entry,
>      then it's ok, since while we'll lose one of those hard links,
>      src will still point to a remaining link.
>      Note that technically, condition #4 obviates condition #2, but we
>      retain the 1 < st_nlink condition because that means fewer invocations
>      of the more expensive #4.

The last 3 lines are confusing.
Don't you mean "condition #3" and not "condition #2"?
The last 2 lines talk about condition 3, not condition 2.

Come to think of it, why is condition 2 needed at all?
Can't we eliminate it, both in the commentary and in the code?
If a symlink has a link count greater than 1, then overwriting
it won't lose the link; in that sense it's just like a regular
file with a link count greater than 1.  So why are symlinks
special there?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]