2 # Use du to exercise a corner of fts's FTS_LOGICAL code.
3 # Show that du fails with ELOOP (Too many levels of symbolic links)
4 # when it encounters that condition.
6 # Copyright (C) 2006 Free Software Foundation, Inc.
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 if test "$VERBOSE" = yes; then
28 . $srcdir/../lang-default
31 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
32 trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
33 trap '(exit $?); exit $?' 1 2 13 15
36 mkdir -p $tmp || framework_failure=1
37 cd $tmp || framework_failure=1
39 # Create lots of directories, each containing a single symlink
40 # pointing at the next directory in the list.
42 # This number should be larger than the number of symlinks allowed in
43 # file name resolution, but not too large as a number of entries
44 # in a single directory.
48 mkdir $dir_list || framework_failure=1
51 for i in $dir_list `expr $n + 1`; do
55 ln -s ../$i $i_minus_1/s || framework_failure=1
62 if test $framework_failure = 1; then
63 echo "$0: failure in testing framework" 1>&2
67 # If a system can handle this many symlinks in a file name,
68 # just skip this test.
70 # The following also serves to record in `err' the string
71 # corresponding to strerror (ELOOP). This is necessary because while
72 # Linux/libc gives `Too many levels of symbolic links', Solaris
73 # renders it as `Number of symbolic links encountered during path
74 # name traversal exceeds MAXSYMLINKS'.
76 cat $file > /dev/null 2> err && \
79 $0: Your system appears to be able to handle more than $n symlinks
80 in file name resolution, so skipping this test.
84 too_many=`sed 's/.*: //' err`
88 # With coreutils-5.93 there was no failure.
89 # With coreutils-5.94 we get the desired diagnostic:
90 # du: cannot access `1/s/s/s/.../s': Too many levels of symbolic links
91 du -L 1 > /dev/null 2> out1 && fail=1
92 sed "s, .1/s/s/s/[/s]*',," out1 > out || fail=1
94 echo "du: cannot access: $too_many" > exp || fail=1
97 test $fail = 1 && diff out exp 2> /dev/null
99 (exit $fail); exit $fail