bug-coreutils
[Top][All Lists]
Advanced

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

Re: [PATCH] Add new option --in-place


From: Pádraig Brady
Subject: Re: [PATCH] Add new option --in-place
Date: Thu, 25 Mar 2010 11:30:45 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3

On 24/03/10 12:15, Pádraig Brady wrote:
> Also I noticed that `mv -b ./file.tmp ./file` is not atomic
> because the renames are done like: rename(file,bak); rename(tmp,file);

I summarized the issues involved with replacing files and it was surprisingly 
popular:
http://www.reddit.com/r/programming/comments/bhnab/replacing_a_file_on_unix_is_hard/

It was indirectly suggested there to use hardlinks for atomic backups,
which I've amended the attached script to do.  Other changes include
falling back to cp -a if --attributes-only is not supported, and
correctly removing all temp files.

I wonder should `mv -b` (and sed -i) use the ln method to
try to be atomic and then fall back to the double rename?
I'll look into it at some stage.

cheers,
Pádraig.

Attachment: rp
Description: Text document


reply via email to

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