information on identifying hard links to a file

Jamie Lokier jamie at shareable.org
Thu Feb 9 19:02:17 GMT 2006


Wayne Davison wrote:
> On Thu, Feb 09, 2006 at 03:04:17PM +0100, Paul Slootman wrote:
> > compare inode and device number. When those are the same, the two files
> > must be hardlinked.
> 
> Also, rsync only considers files that have a link count larger than 1
> (see stat()'s st_nlink) since this allows it to ignore the vast majority
> of files that have only one link into a filesystem.

That's a fine rule and a lot of programs use it.

It's also a very important rule: without it, every backup I do using
rsync would run out of memory.  I already have one directory in my
home directory which has so many hard links that it cannot be copied
(with -H) at the same time as the rest of my home directory, due to
running out of memory if I try.

So it's unfortunate that Linux bind mounts break the rule.  They
create multiple paths to files, including different names for the same
files, which can still have a link count of 1.

-- Jamie


More information about the rsync mailing list