Description of Problem: 'ls' gives a misleading errormessage if the current directory contains a broken symlink. Version-Release number of selected component (if applicable): fileutils-4.1.9-12 vanilla linux 2.4.19 How Reproducible: 100% Steps to Reproduce: 1. mkdir /tmp/ftest && cd /tmp/ftest 2. ls --color=tty ## or just 'ls' which is its alias 3. ln -s foo bar 4. ls --color=tty Actual Results: $ ls --color=tty $ ln -s foo bar $ ls --color=tty ls: .: No such file or directory bar $ Expected Results: no error-message
I don't see this. Can you see what 'strace' says is going wrong?
strace tells: ---- ... open(".", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 3 fstat64(3, {st_mode=S_IFDIR|0775, st_size=0, ...}) = 0 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 brk(0x805f000) = 0x805f000 getdents64(0x3, 0x805dc70, 0x1000, 0x805dc40) = 72 lstat64("bar", {st_mode=S_IFLNK|0777, st_size=3, ...}) = 0 readlink("bar", "foo", 128) = 3 stat64("foo", 0xbffff460) = -1 ENOENT (No such file or directory) getdents64(0x3, 0x805dc70, 0x1000, 0x805dc40) = 0 close(3) = 0 write(1, "\33[00m", 5) = 5 write(2, "ls: ", 4ls: ) = 4 write(2, ".", 1.) = 1 write(2, ": No such file or directory", 27: No such file or directory) = 27 write(2, "\n", 1 ----
Fix is | type = next->d_type; | #endif | total_blocks += gobble_file (next->d_name, type, 0, name); |+ errno = 0; | } | | close_error = CLOSEDIR (reading); in src/ls.c:2110 Alternatively, you can do the more obviously | clear_files (); | |- errno = 0; |- while ((next = readdir (reading)) != NULL) |+ while ((next = (errno=0, readdir (reading))) != NULL) | if (file_interesting (next)) | { | enum filetype type = unknown;
This will fix bug #76738 too
Fixed package is 4.1.9-13, which will show up in rawhide shortly.