NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/43751: ls -L returns wrong exit code
The following reply was made to PR bin/43751; it has been noted by GNATS.
From: "Valeriy E. Ushakov" <uwe%stderr.spb.ru@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc:
Subject: Re: bin/43751: ls -L returns wrong exit code
Date: Fri, 13 Aug 2010 06:42:36 +0400
On Thu, Aug 12, 2010 at 18:17:29 -0700, john heasley wrote:
> Thu, Aug 12, 2010 at 08:50:04PM +0000, Valeriy E. Ushakov:
>
> Crap, you are right. my 4.99 test had the FQPN, as you noted.
>
> > Basically, we use -L only to select FTS_LOGICAL instead of
> > FTS_PHYSICAL. printing code doesn't know whether -L was specified.
> > For links with non-existent targets fts_children(3) returns the link
> > info (as it would for FTS_PHYSICAL) and printing code just happily
> > prints it.
>
> Does it need to? something like this is a quick fix.
>
> Index: ls.c
> ===================================================================
> RCS file: /cvsroot/src/bin/ls/ls.c,v
> retrieving revision 1.67
> diff -d -u -d -u -r1.67 ls.c
> --- ls.c 8 Jul 2010 20:43:34 -0000 1.67
> +++ ls.c 13 Aug 2010 00:52:59 -0000
> @@ -389,6 +389,7 @@
> static void
> traverse(int argc, char *argv[], int options)
> {
> + char path[MAXPATHLEN + 1];
> FTS *ftsp;
> FTSENT *p, *chp;
> int ch_options, error;
> @@ -442,6 +443,13 @@
> if (!f_recursive && chp != NULL)
> (void)fts_set(ftsp, p, FTS_SKIP);
> break;
> + case FTS_SLNONE:
> + if (options & FTS_LOGICAL) {
> + readlink(p->fts_path, path, sizeof(path) - 1);
> + errno = ENOENT;
> + warn("cannot access %s", path, p->fts_name);
> + rval = EXIT_FAILURE;
> + }
> }
> error = errno;
> (void)fts_close(ftsp);
Shouldn't this check be in display()?
You don't have to readlink(), the error is reported for the link name,
not the target name.
-uwe
Home |
Main Index |
Thread Index |
Old Index