Search:

Using Hardlinks

wcp makes heavy use of hardlinks. The server component wcpd creates for each wcp run a new directory for the client data and starts numbering the different versions with "0001". After 10 runs the server will have the directories "0001", "0002", ... to "0010". Each of the version directories holds the complete set of files as they were stored on the client when wcp was run. The server does however only store those files that have changed since the previous run, files that were not changed are inserted by creating a hardlinks to the file in the previous run directory.

Using hardlinks

The difference between a hardlink and a normal file is (very simply) as follows: Usually a directory holds a directory entry record for each file (and subdiretory etc.) it contains. This record holds also the disk location where the file is stored. Now a hardlink in a directory refers to the directory entry record in another directory. That is, the entries in both directories refers exactly to the same file on your disk.

You may be new to the concept of hardlinks. Here are some things to keep in mind.

Hardlinks may not span several disk partitions.
If you start using wcp for backups and you later find that you are running out of disk space you cannot add another disk partition and put it into the wcp server space.

Modifying a hardlinked file modifies all hardlinked copies.
Well, the reason for this is (and I agree that this falsyfies the sentence above), that there are no copies of a hardlinked file, since all hardlinks point to the same file.

Deleting a hardlink does not delete the file.
Only when the last hardlink is deleted and the reference count of the hardlinked file reaches zero, the file itself is removed.

Hardlinks vs. softlinks
Perhaps you know about softlinks which are very common. But you should know that hardlinks are not like softlinks.

  • Softlinks are something completely different than hardlinks. A softlink is a real existing file that holds the path of the real file behind the link. It's possible to remove the real file, with the linkfile pointing to nowhere.

  • Softlinks may point to files on a different partition, hardlinks not.

  • The softlink and the target file are completely different things, especially they are distinguishable.

Not everything can be hardlinked.
Directories can not be hardlinked. Well under newer Linux systems this can be done but wcp does not use this feature (think about accidental recursion).

Not everything is hardlinked.
Directory entries that could be hardlinked, but are not, are special files (FIFOs, block or character special files). It could be done but it doesn't save any disk space.