[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ls -L should say just what file doesn't exist
From: |
Jim Meyering |
Subject: |
Re: ls -L should say just what file doesn't exist |
Date: |
Thu, 17 Nov 2005 21:57:42 +0100 |
Dan Jacobson <address@hidden> wrote:
> # ls -l ksyms.8.gz
> lrwxrwxrwx 1 root root 19 2005-08-14 02:36 ksyms.8.gz -> ksyms.modutils.8.gz
> # ls -L ksyms.8.gz
> ls: ksyms.8.gz: No such file or directory
>
> Shouldn't that message be more like the following's?:
>
> # ls ksyms.modutils.8.gz
> ls: ksyms.modutils.8.gz: No such file or directory
That would be an improvement.
When you use ls's -L option, that makes it use stat(2) rather
than lstat(2). To give the better diagnostic, ls would have
to treat ENOENT specially when invoked with -L: it would perform
an additional lstat on the offending file, and if that succeeds,
it'd read the symlink, lstat the referent, and if it too is a symlink,
lstat its referent, etc., until something (lstat or readlink) fails,
or lstat finds a non-symlink. Watch out for cycles!
That sounds like a significant chunk of new code, just for an
improved diagnostic, but I think it'd be worthwhile.
Anyone interested in the coding exercise?