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: ls doesn't call fstatat?


On Sep 10 11:27, Eric Blake wrote:
> On 09/10/2010 11:18 AM, Corinna Vinschen wrote:
> >Hi Eric,
> >
> >I'm wondering a bit about this.  I had expected that `ls -l' would use
> >fstatat if it is available, roughly like this:
> >
> >   dir = opendir();
> >   while (ent = readdir(dir))
> >     fstatat (dirfd(dir), ent->d_name,&statbuf, AT_SYMLINK_NOFOLLOW);
> 
> Eventually it will, but that patch has not yet hit upstream
> coreutils. rm, chmod, and du have been converted, but cp, mv, and ls
> still need some work.
> 
> >but while debugging I found that it uses stat/lstat.  Is there any
> >good reason for this, like, say, it's just not supported in ls?
> 
> The same good reason as always for open source - lack of volunteer efforts!
> 
> >I'm asking since the combination of readdir/fstatat would allow to reuse
> >information from the last readdir call in fstatat since the file
> >descriptor given to fstatat would be kind of a free gift.  It's much
> >harder to do the same with readdir/lstat.
> 
> Hmm - certainly more incentive to try and get this upstream into
> coreutils then, isn't it.

Right.  Note that I have no code yet.  It's just one idea I'm
contemplating for another speedup of the `ls -l' scenario.  If the dir
handle given to fstatat is identical to the dir handle used in the last
readdir call, and if the filename is identical to the filename returned
by the last readdir, too, there's a good chance that this is within the
same loop.  OTOH, this is a fragile idea, probably.  Something like this
code

  while (ent = readdir(dir))
    collect_files ();
  alpha_sort_files ();
  fstatat_files ();

would not have any advantage of this idea.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat


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