Atomic rename
Atomic rename is a filesystem namespace operation whose successful replacement of an existing destination changes the file reached through that pathname without exposing an intermediate missing destination to concurrent lookups.
For Linux rename(), source and destination must be on the same mounted filesystem; even separate mount points of one filesystem produce EXDEV. Existing descriptors retain their original file references, and other hard links are unaffected. Both pathnames may temporarily refer to the source, so the guarantee is not a two-path snapshot. Success establishes visibility, not crash durability: the file-data and directory-persistence requirements must be handled separately.
Relations
- related
- directory-fsync, open-file-description, inode, hard-link, unlink, crash-consistency
Advantages
- Publishes a replacement without first removing the destination name.
Limitations
- Does not redirect already-open descriptors or update other hard links.
- Does not by itself make replacement data or directory entries crash-persistent.
- On NFS, a reported rename failure can follow successful server execution; NFSv4.1 replay guarantees depend on session and reply-cache recovery.