bug-coreutils
[Top][All Lists]
Advanced

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

bug#29961: [PATCH] mv -n: do not overwrite the destination


From: Pádraig Brady
Subject: bug#29961: [PATCH] mv -n: do not overwrite the destination
Date: Sat, 6 Jan 2018 10:06:04 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

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.






reply via email to

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