problems with hardlinks
This is for tracking various problems with hardlinks.
Common filesystem system operations can break hardlinks
A common way to atomically modify a file is to make changes to a copy, then moving the copy to replace the original. This breaks hard links. The copy has a separate inode number and moving it only replaces the targeted path, not both.
You can easily replicate this behavior as follows:
echo 'foo' >foo.txt
echo 'bar' >bar.txt
ln foo.txt hardlink.txt
echo 'The hardlink works' >hardlink.txt
cat foo.txt hardlink.txt
# The hardlink works
# The hardlink works
Then doing:
echo 'Replacement' >replacement.txt
mv replacement.txt hardlink.txt
cat foo.txt hardlink.txt
# The hardlink works
# Replacement