From d4c7114bce116aefe28c899f5d0e7dcc39feb103 Mon Sep 17 00:00:00 2001 From: Pádraig Brady
Date: Tue, 29 Sep 2009 15:43:01 +0100 Subject: ls: always print "?" for allocated size of a dereferenced dangling symlink Previously for `ls -Ls` (but not `ls -Lsl`), we referenced the st_blocks returned from the previous failed stat() call. This undefined value was seen to be 0 for dangling symlinks at least. * src/ls.c (print_file_name_and_frills, length_of_file_name_and_frills): Don't use st_blocks if the previous stat() failed * tests/ls/dangle: Add a test case * NEWS: Mention the fix, and roll up related items into a single entry. --- tests/ls/dangle | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/ls/dangle b/tests/ls/dangle index 6abad9213..687d3dfba 100755 --- a/tests/ls/dangle +++ b/tests/ls/dangle @@ -28,7 +28,8 @@ mkdir -p dir/sub || framework_failure ln -s dir slink-to-dir || framework_failure mkdir d || framework_failure ln -s no-such d/dangle || framework_failure -echo '? dangle' > subdir_exp || framework_failure +printf '? dangle\n' > subdir_Li_exp || framework_failure +printf 'total 0\n? dangle\n' > subdir_Ls_exp || framework_failure fail=0 @@ -56,6 +57,11 @@ compare out exp || fail=1 # Ensure that ls -Li prints "?" as the inode of a dangling symlink. rm -f out ls -Li d > out 2>/dev/null && fail=1 -compare out subdir_exp || fail=1 +compare out subdir_Li_exp || fail=1 + +# Ensure that ls -Ls prints "?" as the allocation of a dangling symlink. +rm -f out +ls -Ls d > out 2>/dev/null && fail=1 +compare out subdir_Ls_exp || fail=1 Exit $fail -- cgit v1.2.3-70-g09d2