Sat 27 Nov 2004 07:24:18 PM UTC, comment #1:
Summary - I have fixed bugs, but not the one you reported. Please read on to discover what I did and why.
I disagree with your interpretation. My reading of the POSIX standard tis that the find utility is only required to diagnose an infinite loop if it enters a directory forming part of that loop. Hence I don't think the specific example you gave is entirely appropriate. The diagnostic message is presumably intended to warn the user that the output of find may not be as they expect.
However, there are (were) indeed closely related problems with findutils-4.2.8. There are three interesting cases:
1. Infinite cycles involving hard links to directories. These were previously detected and find used to silently avoid visiting any particular directory entry which was a hard link to one of its ancestors (where the ancestor had not already been visited, the loop would be detected later).
The effect of the leaf optimisation is frequently such that find knows that it doesn't need to examine such entries anyway (the deep directory entry does not contribute to the link count of its immediate parent). I have implemented a bugfix in the CVS code, which is to issue a diagnostic when this happens, instead of silently avoiding such cycles.
2. Loops including symbolic links. There were problems diagnosing this since the -L option had failed to imply -noleaf, contrary to what the documentation said. Your bug report led me to check this, and so I have just fixed this in CVS.
3. Symbolic links which cause ELOOP (i.e. your example). I think that in this case findutils-4.2.8 treats these as if they were broken symbolic links. I think that's a reasonable interpretation. The (admittedly non-normative) RATIONALE text states:
"Since the -L option resolves all symbolic links and the -type l primary is true for symbolic links that still exist after symbolic links have been resolved, the command:
find -L . -type l
prints a list of symbolic links reachable from the current directory that do not resolve to accessible files."
Since symlinks pointing to each other do not resolve to accessible files (or directories) I think it is reasonable for "find -L . -type l" to print them. Does your interpretation match this? If not, can you explain why you expect something else?
I attach a compressed tar file which contains a "symbolic link torture test" for "find -L". I also insert below the result of running the development code on it. The second attachment is a hand-crafted ext2 filesystem image which has an infinite loop in it. Please take care when testing with the filesystem image, it may not be kind to your system!
--- symbolic link torture test result ---
$ set -x ; ls -lR /tmp/testdir/symloop ; ./find -L /tmp/testdir/symloop -ls
+ ls -lR /tmp/testdir/symloop
/tmp/testdir/symloop:
total 1
lrwxrwxrwx 1 james users 2 2004-11-27 18:40 a -> ..
lrwxrwxrwx 1 james users 17 2004-11-27 18:42 b -> subdir/mid/bottom
lrwxrwxrwx 1 james users 3 2004-11-27 19:04 boo -> far
lrwxrwxrwx 1 james users 3 2004-11-27 19:04 far -> boo
drwxr-xr-x 3 james users 1024 2004-11-27 18:50 subdir
/tmp/testdir/symloop/subdir:
total 1
drwxr-xr-x 3 james users 1024 2004-11-27 18:50 mid
/tmp/testdir/symloop/subdir/mid:
total 1
drwxr-xr-x 2 james users 1024 2004-11-27 18:49 bottom
/tmp/testdir/symloop/subdir/mid/bottom:
total 1
-rw-r--r-- 1 james users 6 2004-11-27 18:49 deepfile
+ ./find -L /tmp/testdir/symloop -ls
16636 1 drwxr-xr-x 3 james users 1024 Nov 27 19:04 /tmp/testdir/symloop
16635 1 drwxr-xr-x 3 james users 1024 Nov 27 19:06 /tmp/testdir/symloop/a
./find: Filesystem loop detected; `/tmp/testdir/symloop/a/symloop' has the same device number and inode as a directory which is 2 levels higher in the filesystem hierarchy.
16636 1 drwxr-xr-x 3 james users 1024 Nov 27 19:04 /tmp/testdir/symloop/a/symloop
16646 1 -rw-r--r-- 1 james users 311 Nov 27 19:06 /tmp/testdir/symloop/a/symloop.tar.gz
16638 1 drwxr-xr-x 2 james users 1024 Nov 27 18:49 /tmp/testdir/symloop/b
16642 1 -rw-r--r-- 1 james users 6 Nov 27 18:49 /tmp/testdir/symloop/b/deepfile
16639 1 drwxr-xr-x 3 james users 1024 Nov 27 18:50 /tmp/testdir/symloop/subdir
16640 1 drwxr-xr-x 3 james users 1024 Nov 27 18:50 /tmp/testdir/symloop/subdir/mid
16638 1 drwxr-xr-x 2 james users 1024 Nov 27 18:49 /tmp/testdir/symloop/subdir/mid/bottom
16642 1 -rw-r--r-- 1 james users 6 Nov 27 18:49 /tmp/testdir/symloop/subdir/mid/bottom/deepfile
16643 0 lrwxrwxrwx 1 james users 3 Nov 27 19:04 /tmp/testdir/symloop/far -> boo
16644 0 lrwxrwxrwx 1 james users 3 Nov 27 19:04 /tmp/testdir/symloop/boo -> far
|