IETF-SSH archive

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

Re: sftp rename not good.



* Damien Miller <djm%mindrot.org@localhost> [030513 16:15] wrote:
> 
> No, there is always at least one link to the file during the usual
> sequence of events:
> 
> if (!exists(new))
> 	link(old, new)
> 	unlink(old)
> 
> Unless you are using some idiot filesystem that writes out directory
> changes asynchronously (not mentioning any names...)

What you have there is atomicity, not durability.

You must fsync(2) either "dirname(new)" or possibly "new" after the
link(2) for that to be safe, otherwise you are relying on the
filesystem's implementation.

Only rename(2) has the semantics you actually want without the need
for fsync(2).

-Alfred



Home | Main Index | Thread Index | Old Index