0

This is something I imagine I might have to submit a patch or feature request for, but I'd like to know if it is possible to create a hardlink to a file, that when that hardlink which was not the original file is editted, that it would be copied first before it was actually editted?

Which major filesystem would this apply to?

Thanks.

  • If you have a file with multiple names (hard links), there is no way to tell which one was created first. – Kusalananda Mar 06 '21 at 22:02
  • @Kusalananda What about using extended attributes? Would that apply to one or not the other? – Jannies - They do it for free Mar 06 '21 at 22:04
  • Aren't extended attributes also associated with the inode, not with the name in the directory structure? In that case, a single file has a single set of extended attributes, and possibly several names (hard links). – Kusalananda Mar 06 '21 at 22:19

1 Answers1

1

After you create a hard link to a file, there are just two links to one file. While you may remember which link was first and which was second, the filesystem doesn't.

So it is just possible for an editor to determine whether there is more than one link to a file or not. An editor may or may not preserve the link when it saves the new file.

What you may want is a filesystem that supports cp --reflink. That way you get a space efficient copy, but when you change the copy, your original file is not modified.

RalfFriedl
  • 8,981