bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: coreutils-6.1: needs 'ls' patch (bug #15043)


From: Eric Blake
Subject: Re: coreutils-6.1: needs 'ls' patch (bug #15043)
Date: Sat, 02 Sep 2006 06:44:50 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.5) Gecko/20060719 Thunderbird/1.5.0.5 Mnenhy/0.7.4.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to mwoehlke on 8/31/2006 10:18 AM:
>> Look more closely at the code.  The reason linux was failing was because
>> it was not doing enough work, because the d_type shortcut let it skip a
>> stat where one was needed.  Platforms that did not have the bug are not
>> doing extra work, because they have already done the stat (not having a
>> d_type shortcut to rely on).  So #ifdef'ing on linux is not the right
>> approach, and Jim's patch was appropriate.
> 
> Ok, so if I am understanding correctly, you are saying that on
> not-Linux, one of the other conditions in the 'if' will always cause the
> block to be evaluated?

The bug in coloring directories according to their mode bits is that you
need to know the mode bits.  The only way to get mode bits is to call
[l]stat.  On newer Linux, and any other OS that provides d_type in
readdir, the bug was that we were not calling stat because "readdir's
d_type tells us it is a directory, we know what to color it".  On other
platforms, like cygwin, that do not provide d_type, we had already called
stat to figure out whether the file is a directory, so we already had the
mode bits.  The bug, then, was that Linux exposed a flaw in our
optimization logic, but the same flaw is present on any other system with
d_type - namely, if we know that a readdir entry is a directory, we STILL
need a stat when coloring directories according to mode bits.  Ultimately,
the correct behavior is that for ALL platforms, coloring directories
requires a stat at some point or another, and it was not a Linux-specific
bug (it just so happened that Linux was the only platform you tested that
had d_type and thus showed the bug).  Conditionalizing your fix on
__linux__ would have been wrong, had some other platform come up to speed
and implemented a reliable d_type.

- --
Life is short - so eat dessert first!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFE+XzC84KuGfSFAYARAq1qAJ98J4JRLbDDBju8jBpsHfIEzssg8wCgqNnI
RV+0X1oSsywsmNIxVWmUktM=
=l+ID
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]