5 ms·
Move in Unix is atomic, which handles a lot of the common use cases for a transactional file system.
by marcell 4y ago
Move in Unix is atomic, which handles a lot of the common use cases for a transactional file system.
- bhawks 4y agoMove _on_ the same filesystem/partition is atomic ;).
- beagle3 4y agoand only on _files_. If you want to atomically replace a whole directory. "move" alone can't do it - though you can compensate with a symbolic link.
- IgorPartola 4y agocreat is as well if you do the magic correctly. Well except if the file system is network mounted. Maybe. And if another process respects what you are doing.
- mook 4y agoIsn't that only specified (for the same filesystem, as mentioned) for Linux? As far as I can tell the only thing POSIX specifies came from ISO C: https://pubs.opengroup.org/onlinepubs/9699919799/functions/rename.html https://pubs.opengroup.org/onlinepubs/9699919799/functions/r... ISO C 9899:2018 (actually the 2017 draft) says in 7.21.4.2.3 that on a failure return the file is available by its original name, but that's a much weaker guarantee as that doesn't say anything about failing to return (e.g. hard system crash)…