Skipping hardlinks in a copy

Paul Slootman paul at debian.org
Thu Mar 8 21:15:01 GMT 2007


On Thu 08 Mar 2007, Sri Ramkrishna wrote:
> 
> I think I probably hard links to directories.  I have observed cpio
> going through a loop continously.  Since I was doing this on an AIX
> JFS filesystem (on an AIX fileserver) it might not have same protections
> that I believe Linux when hitting a circular loop.

If there are hard links to directories (apart from the . and .. links)
then the filesystem is corrupt; it should be impossible to hardlink a
directory to create another entry that points to it.
Linux has no protection against such things beyond ensuring the
filesystem stays sane... just like AIX most certainly should also have.
It's entirely possible that AIX offers some way of hardlinking
directories (it's been over 10 years since I last touched AIX :-) but if
so, there's no real sane way of handling such situations.


> I think this is exactly what's happening.  I think I have a number of
> cycles that are causing the data to go loopy. (pardon the pun)  If
> that's the case, how does one find self referential hard/softlinks?

It sounds like you're confusing hard links with soft (or symbolic)
links, by the way you mention them above.
Cpio, find, rsync, whatever will not by default follow symbolic links
(unless instructed to do so, in which case any problems arising from
that are the user's fault).  As I mentioned above, hardlinks to
directories shouldn't exist. Without hardlinks to directories, you won't
have loops.

> > The command "find . -type l" will only find symlinks.  You can find
> > files that have hard links with "find . ! -type d -links +1 -print".  

> Can I also do use find to create a list of files that are not hardlink

A file that's not hardlinked will have a link count of 1 (which is very
logical if you think about what that link count means...)


Paul Slootman


More information about the rsync mailing list