bug-coreutils
[Top][All Lists]
Advanced

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

Re: interrupting `shred -u's renaming: what should it do?


From: Paul Jarc
Subject: Re: interrupting `shred -u's renaming: what should it do?
Date: Thu, 20 May 2004 11:45:34 -0400
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3 (gnu/linux)

address@hidden (Bob Proulx) wrote:
> But if a new file appears by the same original name then there is no
> longer any need to hide it with regards to the previous incarnation
> of the name.  At that point the name can just be removed.

Ok, that makes sense.

> My comment pertained to my thought that if you could rename it and
> fail if the name exists then that means in that case the file could be
> removed.  But if the rename succeeded then things were restored as
> much as possible to a sane state after an interrupt.

You can do that, without clobbering the new file with the original
name, and you don't need full atomicity.
result=link("000000", "original name");
if (result==0 || errno==EEXIST) unlink("000000");
else report_the_error_and_keep_the_temp_file();

link() gives us as much atomicity as we need - checking for the
existence of the original name is atomic with allocating the original
name.  We don't need all that to also be atomic with releasing the
temporary name.


paul




reply via email to

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