This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] nftw: fill in stat buf for dangling links [BZ #23501]
- From: Andreas Schwab <schwab at linux-m68k dot org>
- To: DJ Delorie <dj at redhat dot com>
- Cc: Tulio Magno Quites Machado Filho <tuliom at ascii dot art dot br>, libc-alpha at sourceware dot org
- Date: Sat, 22 Jun 2019 09:46:59 +0200
- Subject: Re: [PATCH] nftw: fill in stat buf for dangling links [BZ #23501]
- References: <874l4imukh.fsf@linux.ibm.com> <xn36k2wng1.fsf@greed.delorie.com>
On Jun 21 2019, DJ Delorie <dj@redhat.com> wrote:
> Tulio Magno Quites Machado Filho <tuliom@ascii.art.br> writes:
>>> + if (err < 0)
>>> + {
>>> + /* Stat failed. We have three choices: don't report
>>> + this file, report with invalid data, or report with
>>> + zero'd data. Let's prefer obvious over subtle so
>>> + zero the data here. This should happen extremely
>>> + rarely. */
>>> + memset (&st, 0, sizeof (st));
>>> + }
>>
>> I could not find a description of this behavior in the standard.
>
> The spec doesn't cover it, so I defined it that way. The only
> alternative is to leave the buffer unchanged, which most likely would
> report seemingly correct but invalid results.
>
> The only time this happens is if we can know that a symlink exists in a
> directory, but cannot read its stats. I expect this to be exceedingly
> rare.
If it's ENOENT, you could just skip it.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."