how diff between hardlink trees works?

Vaibhav Jain vjoss197 at
Fri Sep 9 14:39:32 EDT 2011

On Fri, Sep 9, 2011 at 11:12 AM, Kai Meyer <kai at> wrote:

> **
> On 09/09/2011 09:05 AM, Vaibhav Jain wrote:
> Hi,
> I am not able to understand how diff between two trees of which one is just
> contains hardlinks to another's files (cp -al )ing
> works.I am asking this question here because I need to build a custom
> kernel for which I need to generate patch. So the
> documentation suggests to create a hardlink copy of the kernel source tree
> using cp -al and then make changes to
> one of the trees and run a diff.I am wondering that if files are hardlinks
> then changes to one copy will affect another in which case
> diff should give no output.
> Also, the patch I created looks a little odd as it contains complete
> modified files instead of just the differences.
> Please help!
> Thanks
> Vaibhav Jain
> _______________________________________________
> Kernelnewbies mailing listKernelnewbies at kernelnewbies.org
>  Make the hard link copy like normal. Then delete the directory that you
> are making changes to (in the hard link directory), then copy the files over
> with out hard links. That way "most" of the kernel tree is hard linked, and
> just the portion you want to work on is a copy. That way the diff will work.
> Otherwise, skip the hard link part all together, and just make a full copy.
> Uses lots of disk space and takes longer to diff.
> -Kai Meyer

Hi Kai,

Thanks for the reply. I need just one more favour.
Could you please look at this document describing the procedure to build
custom fedora kernel. It mentions the step to create hardlink to generate
but doesn't
talk about deleting anything ?I just need to confirm if the article is not
accurate or if there is
any error in my understanding.
Whenever I follow it I get a patch that contains all of the content of the
changed files rather than just the changes.

Here is the relevant portion :
 Copy the Source Tree and Generate a Patch

This step is for applying a patch to the kernel source. If a patch is not
needed, proceed to "Configure Kernel Options".

Copy the source tree to preserve the original tree while making changes to
the copy:

cp -r ~/rpmbuild/BUILD/kernel-2.6.$ver.$fedver/linux-2.6.$ver.$arch
cp -al ~/rpmbuild/BUILD/kernel-2.6.$ver.$fedver.orig

* The second cp command hardlinks the .orig and .new trees to make diff run
faster. Most text editors know how to break the hardlink correctly to avoid

Using vim on FC14, it treated the hard link as a hard link and thus the
above technique failed. It was necessary to repeat the original copy used
for the .orig directory for the .new directory. Note that this uses twice
the space.

Make changes directly to the code in the .new source tree, or copy in a
modified file. This file might come from a developer who has requested a
test, from the upstream kernel sources, or from a different distribution.

After the .new source tree is modified, generate a patch. To generate the
patch, run diff against the entire .new and .orig source trees with the
following command:

cd ~/rpmbuild/BUILD
diff -uNrp kernel-2.6.$ver.$fedver.orig kernel-2.6.$ver.$ >

-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Kernelnewbies mailing list