Circular symlink checking?
Scott Blachowicz
scott at grlab.UUCP
Sat Sep 2 03:41:57 AEST 1989
Does anyone have a script to check for circular symbolic links? I had
some lately that I noticed things like /foo/bar/bar -> /foo/bar. I think
they got created by a script I had to go fix some of the symbolic links
on the system (the script probably got a little over ambitious).
I can generate something with the "symlink -> file" stuff in it, but
need to know a good way to check for symbolic links into the same
directory. It seems I only need to check on things if the "file" is a
directory. The simpler case is checking to see if a particular symlink
loops back into its own directory path. That could probably be checked
by getting the device/inode #s for each directory in the "file"s path
and comparing with the device/inode # of the parent directory of the
"symlink". This would take care of this particular mistake, but a more
general solution should check for multiple jump cycles...
/a/b/c/d -> /e/f/g -> /h/i/j -> /a/b
Anybody have anything? (is this the right place for this article?)
Scott Blachowicz
USPS: Graphicus UUCP: ...!hpubvwa!grlab!scott
150 Lake Str S, #206 VoicePh: 206/828-4691
Kirkland, WA 98033 FAX: 206/828-4236
More information about the Comp.unix.questions
mailing list