This is not always true on NFS for various reasons too stupid to go into. There are precious few things so stupid that someone has not committed them to an NFS server somewhere, but the retry semantics in the protocol make it generally awkward and it's possible for two mkdirs to both succeed or both fail but in both cases for the directory to exist. See http://www.mail-archive.com/freebsd-hackers@freebsd.org/msg2... and http://stackoverflow.com/questions/185451/quick-and-dirty-wa... . The only things NFS guarantees is that symlink, rename, and open with the O_EXCL flag (and that only in v3), will be atomic.
Comments
This is not always true on NFS for various reasons too stupid to go into. There are precious few things so stupid that someone has not committed them to an NFS server somewhere, but the retry semantics in the protocol make it generally awkward and it's possible for two mkdirs to both succeed or both fail but in both cases for the directory to exist. See http://www.mail-archive.com/freebsd-hackers@freebsd.org/msg2... and http://stackoverflow.com/questions/185451/quick-and-dirty-wa... . The only things NFS guarantees is that symlink, rename, and open with the O_EXCL flag (and that only in v3), will be atomic.