symbolic link cycling

2004-05-27 Thread Boucher, Eric
Hi everyone,

Is it possible to know which folders are pointing to each other in a cycle
manner by doing a find or some other command? I have a backup utility (in
windows thru samba) which seems to backup redundant files, probably due to
some symbolic links pointing to each other in cycle. Maybe a shell script
can do the job? I searched on the internet without good results. I hope that
my question is clear. Thanks,

Eric
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: symbolic link cycling

2004-05-27 Thread Matthew Seaman
On Thu, May 27, 2004 at 07:12:02AM -0400, Boucher, Eric wrote:

 Is it possible to know which folders are pointing to each other in a cycle
 manner by doing a find or some other command? I have a backup utility (in
 windows thru samba) which seems to backup redundant files, probably due to
 some symbolic links pointing to each other in cycle. Maybe a shell script
 can do the job? I searched on the internet without good results. I hope that
 my question is clear. Thanks,

The usual solution to this sort of problem is to make your backup
script not chase symlinks at all.  You can't create directory loops
using hard links[1], and usually you would want your backup system to
reproduce the symlinks rather than replacing the link with whatever it
points at.  Most commands you might use to make backups will default
to not following symlinks -- tar(1), find(1)+cpio(1), dump(1),
rsync(1) all work that way be default.  cp(1) defaults to that
behaviour if given the '-R' flag (copy filesystems recursively).

Probably the best way to detect a symlink loop would be to record the
inode number of any directory visited, and then test if the current
directory had been visited before.  Note: you can't do this with
ordinary files, as it's perfectly legitimate for the same file to have
many hard links and so appear in the filesystem in multiple places.

Cheers,

Matthew

[1] Unless you have root access to the filesystem, and know quite a
lot about its internals.

-- 
Dr Matthew J Seaman MA, D.Phil.   26 The Paddocks
  Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey Marlow
Tel: +44 1628 476614  Bucks., SL7 1TH UK


pgpOnNR5fcs33.pgp
Description: PGP signature