Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 627812 - sys-apps/coreutils mv behavior with hard links to same file
Summary: sys-apps/coreutils mv behavior with hard links to same file
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-14 04:14 UTC by Xuefer
Modified: 2017-08-14 04:44 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Xuefer 2017-08-14 04:14:38 UTC
$ rm -f a b
$ touch a
$ ln a b
$ mv a b
mv: 'a' and 'b' are the same file

expected: mv is expected to overwrite b using a, which mean in this case, unlink a, rename a to b
Comment 1 Mike Gilbert gentoo-dev 2017-08-14 04:44:07 UTC
POSIX says this behavior is correct.

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/mv.html

"The specification ensures that mv a a will not alter the contents of file a, and allows the implementation to issue an error that a file cannot be moved onto itself. Likewise, when a and b are hard links to the same file, mv a b will not alter b, but if a diagnostic is not issued, then it is unspecified whether a is left untouched (as it would be by the rename() function) or unlinked (reducing the link count of b)."