[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug w/ gawk stat extension
From: |
Jim Meyering |
Subject: |
Re: Bug w/ gawk stat extension |
Date: |
Wed, 22 Jun 2005 20:45:28 +0200 |
Glenn Zazulia <address@hidden> wrote:
> On Jun 21, Andrew J. Schorr wrote:
>> On Mon, Jun 20, 2005 at 03:10:22PM -0600, Glenn Zazulia wrote:
>>> Great! I thought I'd also send another slight fix in the same
> ... and ...
> On Tue, Jun 21, 2005 at 03:34:21PM +0200, Andreas Schwab replied:
>> If you want to retrieve the full link text you have to read at least
>> st_size bytes from the link.
>
> ... and then Andy replied with a sample patch implementing the st_size bytes
> improvement.
>
> This is a nice improvement except that now there is a slight (though
> unlikely) race condition where this new code would return an omitted
IMHO, the best way to read a link name is to call readlink in a loop.
If you roll your own, beware that st_size is sometimes not at all
related to the length of the link name.
For a mature implementation, see the gnulib xreadlink.c module,
or lib/xreadlink.c in the GNU coreutils package.
http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/gnulib/gnulib/lib/xreadlink.c?rev=1.19