2 ms·
Standard use case for hardlinks is replacing a file atomically while creating a backup. The steps you do are: 1. create, write, close/sync "file.new" 2. hard
by eqvinox 5y ago
Standard use case for hardlinks is replacing a file atomically while creating a backup. The steps you do are:
1. create, write, close/sync "file.new"
2. hardlink "file" to "file.old" and sync again
3. rename "file.new" to "file"
4. sync to finish
With these steps, regardless of where you are interrupted, you always have a "functioning" copy of the file. This is quite important for tools writing configuration files or state to disk, but also just your plain old office suite preventing total loss of your PhD thesis.
(Yes it's not perfect, sync()ing correctly is hard [you need to sync the files and the directory!], and hard filesystem damage/kernel panics can always break things.)