GNU bug report logs - #6960
mv refuses to move a symlink over a hard link to the same file

Previous Next

Package: coreutils;

Reported by: Matt McCutchen <matt <at> mattmccutchen.net>

Date: Tue, 31 Aug 2010 21:27:01 UTC

Severity: normal

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

Full log


Message #49 received at 6960 <at> debbugs.gnu.org (full text, mbox):

From: Anders Kaseorg <andersk <at> MIT.EDU>
To: Eric Blake <eblake <at> redhat.com>
Cc: 6960 <at> debbugs.gnu.org
Subject: Re: bug#6960: mv refuses to move a symlink over a hard link to the
	same file
Date: Wed, 4 Jan 2012 16:06:03 -0500 (EST)
On Wed, 4 Jan 2012, Eric Blake wrote:
> But whether the inability to atomically overwrite a directory with a 
> symlink should carry over to a refusal to atomically overwrite a regular 
> file with a symlink is a different matter.

To be clear, mv is already perfectly happy to atomically overwrite a 
regular file with a symlink (even if that causes data loss), as long as it 
doesn’t detect that the symlink points to the same inode.

The only purpose given for this same-inode check is preventing a 
particular kind of accident, and I claim that this purpose would be better 
served by a same-path check, because the same-inode-but-different-path 
case is useful and can’t allow that kind of accident (and indeed, won’t 
lose data at all).

> Maybe we should fix that, to make mv --backup use link()/rename() rather
> than rename()/rename(), so that there is no window where the target
> doesn't exist.

Perhaps, but that’s not a good solution to _this_ problem, because a 
script that wants to do this kind of atomic replacement would then need to 
go delete the backups (potentially resulting in more data loss).

Anders




This bug report was last modified 13 years and 179 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.