On Thu, Jul 26, 2018 at 06:39:30PM -0700, Kevin J. McCarthy wrote:
> My question is about the merit of performing the lstat double-check.
> Does mutt need to be doing this?  Does this work around some strange bug
> with certain filesystems or NFS?

I can't immediately think of a way that NFS is likely to cause
(additional) problems here...  I think the likely reason to do this is
to attempt to prevent a race where the source file is replaced at the
same time as the rename happens (creating a separate file) in which
case you should not unlink.  The trouble is, if that's the purpose,
there's still a race between the stat and the unlink...

> Would another possibility be to skip the lstat double check, or to fail
> without setting EEXIST if the lstat check doesn't match?

You could fail, but you need to set errno to *something*... I'm not
sure what would be appropriate.  Another option is to do the lstat of
both, but save the original stat from the source, and then stat BOTH.
If the second stat of the source and the stat of the target match, OR
the first and second stat of the source match, unlink.  Either way
though, you still have a race.

> Thanks for any advice on this.

Hope that helps.


-- 
Derek D. Martin    http://www.pizzashack.org/   GPG Key ID: 0xDFBEAD02
-=-=-=-=-
This message is posted from an invalid address.  Replying to it will result in
undeliverable mail due to spam prevention.  Sorry for the inconvenience.

Attachment: pgpZ6C8qw1HnQ.pgp
Description: PGP signature

Reply via email to