From 36edf7bad2ab76720a0bf6519074d23d4b8823a7 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 28 Sep 2009 20:24:41 +0200 Subject: ls: print "?", not "0" as inode of dereferenced dangling symlink ls prints inode numbers two ways: for long (-l) listings, and for short ones, e.g., ls -li and ls -i. The code to print long listings properly printed "?" when the inode was unknown, but the code for handling short listings would print 0 instead. Factor out the formatting code into a new function so ls prints the right string ("?") from both places: * NEWS (Bug fixes): Mention it. * src/ls.c (format_inode): New function. (print_long_format): Use it here. (print_file_name_and_frills): Use it here, too. * tests/ls/dangle: Exercise this fix. Reported by Yang Ren in http://bugzilla.redhat.com/525400 --- tests/ls/dangle | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/ls/dangle') diff --git a/tests/ls/dangle b/tests/ls/dangle index b2f8539b8..6abad9213 100755 --- a/tests/ls/dangle +++ b/tests/ls/dangle @@ -26,6 +26,9 @@ fi ln -s no-such-file dangle || framework_failure 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 fail=0 @@ -50,4 +53,9 @@ EOF 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 + Exit $fail -- cgit v1.2.3-70-g09d2