Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 76735 - [ls] Bad errormessages on broken symlinks
Summary: [ls] Bad errormessages on broken symlinks
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Raw Hide
Classification: Retired
Component: fileutils
Version: 1.0
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Tim Waugh
QA Contact: Mike McLean
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-10-25 16:46 UTC by Enrico Scholz
Modified: 2007-04-18 16:47 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2002-11-07 17:15:38 UTC


Attachments (Terms of Use)

Description Enrico Scholz 2002-10-25 16:46:54 UTC
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

Comment 1 Tim Waugh 2002-11-07 16:18:47 UTC
I don't see this.  Can you see what 'strace' says is going wrong?

Comment 2 Enrico Scholz 2002-11-07 16:33:38 UTC
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
----

Comment 3 Enrico Scholz 2002-11-07 17:08:25 UTC
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;



Comment 4 Enrico Scholz 2002-11-07 17:10:29 UTC
This will fix bug #76738 too

Comment 5 Tim Waugh 2002-11-07 17:21:45 UTC
Fixed package is 4.1.9-13, which will show up in rawhide shortly.


Note You need to log in before you can comment on or make changes to this bug.