Do we really need correct st_nlink count for directories?

Eric Blake ebb9@byu.net
Thu Apr 24 13:29:00 GMT 2008


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.

-- 
Don't work too hard, make some time for fun as well!

Eric Blake             ebb9@byu.net



More information about the Cygwin-developers mailing list