Do we really need correct st_nlink count for directories?

Christopher Faylor cgf-use-the-mailinglist-please@cygwin.com
Thu Apr 24 13:35:00 GMT 2008


On Thu, Apr 24, 2008 at 07:32:01AM -0600, Eric Blake wrote:
> According to Christopher Faylor on 4/24/2008 7:11 AM:
>>> subdir counting on local drives as well?  It doesn't seem to fullfil
>>> any real need anymore, it's just a performance killer.
>> I thought find used it.
>
> find, and some of the coreutils, use it if it is > 1, but only as an 
> optimization (correct applications should never rely on it being > 1, and 
> thus have a non-optimal fallback for when it is 1).  The idea of using 
> st_nlink is to speed up scanning the entire directory (when all you care 
> about is subdirectories, you can stop after the correct number have been 
> seen, rather than continuing on to read the entire directory).  But if it 
> takes an entire directory read to determine a correct st_nlink, in order to 
> avoid an entire directory as an optimization, then it isn't optimal. I'm 
> all for dropping correct st_nlink, and using 1 instead.

Ok, in that case, I vote for nuking it.

cgf



More information about the Cygwin-developers mailing list