79533718

Date: 2025-03-25 12:50:23
Score: 1
Natty:
Report link

Yes, its atomically in the sense that the file accessed via the new filename at any time is as consistent as any of the two files is.

If the old file is open for reading, the old data will be obtained as long as its file descriptor is not closed. And writing will change the old file and never the new file. Unless there is another open file descriptor or a hard link to the old file, the contents is finally lost once the file descriptor is closed.

In other words, reading via the new filename is always ok; but to avoid data loss, the old file must be write locked before the rename.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: Rainer Glaschick