Rust lacunae
Rust lacunae
Posted Jun 13, 2021 14:14 UTC (Sun) by james (guest, #1325)In reply to: Rust lacunae by zlynx
Parent article: Rewriting the GNU Coreutils in Rust
If anything goes wrong it is nice if mv deletes any temporary copy it had made in the process of moving a file across filesystems.I've no idea if any version of mv actually does this, but I understand it's possible to open an un-named, unlinked temporary file and write to it, then when you've finished create a link to the file (meaning it has a name and isn't temporary any more), fsync as necessary, and then delete the original file. If the program crashes before the file is linked, then Linux will automatically delete it.
Once the file is linked, you've got a full copy where you want it. Deleting that copy is not obviously the right thing. Deleting the original copy is, but the program crashed when it tried to do that.
