}
run_test 17f "symlinks: long and very long symlink name ========================"
+# str_repeat(S, N) generate a string that is string S repeated N times
+str_repeat() {
+ local s=$1
+ local n=$2
+ local ret=''
+ while [ $((n -= 1)) -ge 0 ]; do
+ ret=$ret$s
+ done
+ echo $ret
+}
+
+# Long symlinks and LU-2241
test_17g() {
- mkdir -p $DIR/$tdir
- LONGSYMLINK="$(dd if=/dev/zero bs=4095 count=1 | tr '\0' 'x')"
- ln -s $LONGSYMLINK $DIR/$tdir/$tfile
- ls -l $DIR/$tdir
+ mkdir -p $DIR/$tdir
+ local TESTS="59 60 61 4094 4095"
+
+ for i in $TESTS; do
+ local SYMNAME=$(str_repeat 'x' $i)
+ ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
+ readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
+ done
}
-run_test 17g "symlinks: really long symlink name ==============================="
+run_test 17g "symlinks: really long symlink name and inode boundaries"
test_17h() { #bug 17378
remote_mds_nodsh && skip "remote MDS with nodsh" && return
cd $DIR/$tdir || error "Changing to $DIR/$tdir"
cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
- # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
- local i=0
+ # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
+ # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
+ local i=0
while i=`expr $i + 1`; do
mkdir -p $i || error "Creating dir $i"
cd $i || error "Changing to $i"
done
i=`expr $i - 1`
echo "The symlink depth = $i"
- [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 ] || error "Invalid symlink depth"
+ [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
+ error "Invalid symlink depth"
+
+ # Test recursive symlink
+ ln -s symlink_self symlink_self
+ $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
+ echo "open symlink_self returns $ret"
+ [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
}
run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="