[Dovecot] Avoiding Hardlinks (was: Something other than dotlock for uidlist locking?)

Ben Schumacher me at benschumacher.com
Thu Aug 10 01:29:10 EEST 2006


On 8/9/06, James Berry <james at jberry.us> wrote:
> Hmm looks to me like rename() would give the same level of atomicity
> as link?
>
> So instead of doing link/unlink, we could just do rename()?

This is not entirely true. The point of the link/unlink pairing is to
ensure that the target file doesn't exist. There exists a race
condition that the link/unlink pairing will protect against: link will
not overwrite an existing file, rename will. The work around would be
to do something hackish along the lines of creating a dotfile for the
target of the rename before doing the actual rename... it's ugly, but
I think it's probably the safest cross networked filesystems way of
ensuring that the target file isn't being written at exactly the same
time you're trying to do your rename.

Cheers.
Ben


More information about the dovecot mailing list