ls doesn't call fstatat?

Corinna Vinschen corinna-cygwin@cygwin.com
Fri Sep 10 17:19:00 GMT 2010


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);

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?

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.


Corinna



More information about the Cygwin-developers mailing list