Skipping hardlinks in a copy

Sriram Ramkrishna sramkris at ichips.intel.com
Thu Mar 8 21:34:03 GMT 2007


On Thu, Mar 08, 2007 at 10:15:01PM +0100, Paul Slootman wrote:
> 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.

OK, I wasn't aware that you couldn't hardlink a directory to another
directory.

> 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.

OK.  Looks like I just have to deal wtih each cycle I encounter and
break it.  Joy. :-)

> > 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.

I'm at a loss then at what I'm looking at.  Maybe it's following
symlinks and I have not checked the arguments properly.  It might
be that symbolic links are causing the issue, but in that case it
doesn't seem to explain why it's taking days to copy a level 0 copy.
I leaped on the link tree issue, because strace on an rsync was
showing it going through the same progression of directories.
I'm going to have to go back and run it again and see if I can
catch it.

> > > 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...)

Yep, indeed it is.  Thank you for taking the time to answer my question,
much obliged.

sri


More information about the rsync mailing list