I do not know what is the historical reason for program "diff" to follow
a symbolic link during the recursive diff (-r), but it seems not to be a
proper  implementation.

If both compared directories contains a sym-link, which point to
a same file or directory, it obviously no need to compare it (not them).

If both compared directories contains a sym-link, which point to
a duplicated file or directory, and files or directories are duplicated in
the same tree level, these files or directories will be compared any way
during the recursive diff. So there is no need to follow the sym-link to
compare them (just waste time by doing so).

The only case that I can see that diff may follow the sym-link in recursive comparison is if the symlink is pointing to a duplicated directory/file in very different locations, which may probably rarely be created. If this is probably the only case "diff -r" needs to follow the sym-link, an option -L or something similar
in other commands, such as ls, should be add for such purpose.

Otherwise, diff -r can be loop forever on large file systems if there is some
symlinks point forth and back between some directories, users may create
them for easy to traversal around file systems.
Then the process of "diff -r" a backup file system and a live file system will
take a day to finish till maximum symlink number is reached, and many
redundant diff information is created. See simple example below.

So, we need to either disable recursive diff to follow the symlink, or
we need a switch (option) to enable following symlink feature in recursive
comparison of diff when a user real needs it.

Any comment?

   -Jin

------------- example of looping on recursive diff ------------------------

% create a simple test structure
% dir -R test # show tree structure, in real case a and b will be a large tree
total 8
drwxr-xr-x  3 jin  wheel  512 Aug 14 20:25 a/
drwxr-xr-x  2 jin  wheel  512 Aug 14 20:32 b/
-rw-r--r--  1 jin   wheel     4 Aug 14 20:23 x
-rw-r--r--  1 jin   wheel     4 Aug 14 20:25 y

test/a:
total 2
drwxr-xr-x  2 jin  wheel  512 Aug 14 20:25 a1/
lrwxr-xr-x  1 jin  wheel    4 Aug 14 20:25 x@ -> ../x

test/a/a1:
total 0
lrwxr-xr-x  1 jin  wheel  10 Aug 14 20:24 a1@ -> ../../b/a1

test/b:
total 0
lrwxr-xr-x  1 jin  wheel  4 Aug 14 20:32 a1@ -> ../a
lrwxr-xr-x  1 jin  wheel  4 Aug 14 20:25 x@ -> ../y

% mkdir test1
% cd test
%   tar -cf - . | ( cd ../test1 ; tar -xf - )
% cd .. ; diff -r test test1
diff: test/a/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1: Too many levels of symbolic links diff: test1/a/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1: Too many levels of symbolic links diff: test/a/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/x: Too many levels of symbolic links diff: test1/a/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/x: Too many levels of symbolic links diff: test/b/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1: Too many levels of symbolic links diff: test1/b/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1/a1: Too many levels of symbolic links

_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to