GNU bug report logs - #29961
[PATCH] mv: document the missing atomicity of 'mv -n'

Previous Next

Package: coreutils;

Reported by: Kamil Dudka <kdudka <at> redhat.com>

Date: Wed, 3 Jan 2018 15:03:02 UTC

Severity: normal

Tags: patch

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


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

From: Pádraig Brady <P <at> draigBrady.com>
To: Paul Eggert <eggert <at> cs.ucla.edu>, Kamil Dudka <kdudka <at> redhat.com>
Cc: 29961 <at> debbugs.gnu.org
Subject: Re: bug#29961: [PATCH] mv -n: do not overwrite the destination
Date: Sat, 6 Jan 2018 10:06:04 +0000
On 05/01/18 22:59, Paul Eggert wrote:
> On 01/05/2018 08:19 AM, Kamil Dudka wrote:
> 
>> I am only fixing the case where the destination file is created after the
>> lstat() call.  In that case, the only result is ENOENT, which is harmless.
>>
> 
> Ah, you're right. Sorry, I misread your patch. It should work.
> 
>> On Friday, January 5, 2018 4:29:55 PM CET Pádraig Brady wrote:
>>
>>> Paul's also avoids a stat() in the common case
>>> where the initial renameat2() succeeds.
>> At the cost of _not_ avoiding the renameat2() call in the most common case.
> 
> I expect that the most common case is 'mv A B' where B does not already 
> exist. This is the case that avoids the stat of B.
> 
> Come to think of it, we don't need to stat A either, when the initial 
> renameat2 succeeds. Attached is a revised proposed patchset to do that. 
> The first is the same as before; the second causes 'mv A B' to issue 
> just a renameat2 syscall (with no calls to stat) in the common case 
> where A exists and B does not.

This second patch looks good also.

thanks,
Pádraig.





This bug report was last modified 7 years and 139 days ago.

Previous Next


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