|
|
|
|
|
by mbid
1033 days ago
|
|
The rename system call is not quite atomic. From https://linux.die.net/man/2/rename: > However, when overwriting there will probably be a window in which both oldpath and newpath refer to the file being renamed. A better way to think about rename is that it's given by two atomic operations in sequence: (1) An atomic link call to make the file available under the new name, and then
(2) an atomic remove operation to delete the old name. Thus, it's possible to observe the state after (1) but before (2). |
|
I've wondered ever since I read that what the first bullet there means. It can't be what you're saying here, what you're saying would apply to racing processes as well as crashes?
So then.. what does he mean when he says rename isn't atomic if there's a crash? What's the failure condition / in-between state that can occur if there's a crash?