ls doesn't call fstatat?

Eric Blake eblake@redhat.com
Fri Sep 10 17:27:00 GMT 2010


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.

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org



More information about the Cygwin-developers mailing list