This is the mail archive of the cygwin-developers mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Do we really need correct st_nlink count for directories?


On Thu, 24 Apr 2008, 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.

Would it make sense to use 0 as the link count on directories?  Unless I'm
missing something, every directory has to have at least the '.' link,
which makes 0 an obviously invalid value (that can be used to trigger the
fallback code).
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_	    pechtcha@cs.nyu.edu | igor@watson.ibm.com
ZZZzz /,`.-'`'    -.  ;-;;,_		Igor Peshansky, Ph.D. (name changed!)
     |,4-  ) )-,_. ,\ (  `'-'		old name: Igor Pechtchanski
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"That which is hateful to you, do not do to your neighbor.  That is the whole
Torah; the rest is commentary.  Go and study it." -- Rabbi Hillel


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]