FL-COW Publisher's description
from Davide Libenzi
The File Link Copy On Write library
The FL-COW library born to solve a problem I had when working with the Linux Kernel archives that I use to replicate using hard links. Replicating archives with hard links is both fast and space saving, and it helped me a lot in speeding up my operations when working on the kernel source.
A recent Arch's mailing list thread that suggested that use of hard links to create archive cached revisions pushed me to write the FL-COW library. What is the problem with hard links when, for example, I'm working with kernel sources? The problem is that I do a:
cp -al linux-2.6-test6 linux-2.6-test6.vm-fix
This command replicate at light speed the vanilla (Linus) archive into an archive I can start hacking on. The problem is that I have to manually remember to break hard links on files I start working on, otherwise even the original copy get modified.
This might break because I forgot doing so and it might also break because other tools might eventually touch file they were not supposed to touch. If it happens that I forget to decouple a file hard link, the next command:
diff -Nru linux-2.6-test6 linux-2.6-test6.vm-fix
will skip all changes done on the file I forgot, because my changes has been applied to the original file also. The library works by intercepting all file open operations happening inside a configured path list, and by decoupling the hard link with a COW if a write operation is requested.
The library is installed using the environment variable LD_PRELOAD and in this way it is able to hook glibc open(2) functions and it is able to perform the COW when necessary. The environment variable FLCOW_PATH control which paths should be subject to COWing. The logic that the library follow to know if a file should be COWed is the following:
Is the file being opened with O_RDWR or O_WRONLY modes?
Is the file inside one of the paths listed inside the FLCOW_PATH environment variable?
Is the file being opened a regular file?
Is the (struct stat)->st_nlink variable greater than one?
If all those answers are yes, the file is COWed by leaving the calling application with a non hard linked version of the file. To setup the library you must start with building it doing a (for example):
If all those steps complete correctly you will have your library installed in /usr/lib/libflcow.so that is ready for use. I use to set the LD_PRELOAD inside my .bashrc file so that I am sure that no tool will screw up my hard-linked archives.
This is the relevant section of my .bashrc file:
System Requirements:No special requirements.
Program Release Status:
Program Install Support: Install and Uninstall