bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug#369822: ls -i stats unnecessarily


From: Jim Meyering
Subject: Re: Bug#369822: ls -i stats unnecessarily
Date: Thu, 01 Jun 2006 22:32:29 +0200

Ian Jackson <address@hidden> wrote:
> Package: coreutils
> Version: 5.2.1-2
>
> -davenant:~> strace -e trace=lstat64 /bin/ls --sort=none -i 
> /export/mirror/Repository/data-md5 2>&1 | head
> lstat64("/export/mirror/Repository/data-md5/063096bcf34e489e5a6c3a7a20214368",
>  {st_mode=S_IFREG|0664, st_size=834, ...}) = 0
> lstat64("/export/mirror/Repository/data-md5/b07ac8b4b6e9918f3e29e7c267f843d3",
>  {st_mode=S_IFREG|0664, st_size=531, ...}) = 0

Thanks for the report.

You're right that in some cases ls could be optimized to avoid the
lstat calls.  However deciding when to do it is not easy.
It is possible
  - when dirent.d_ino is available (this is easy), and
  - when dirent.d_ino is guaranteed to be valid (this is tricky)

The latter is harder because for some files (mount points in a chroot
with a buggy glibc) d_ino is nonzero and wrong.  In those cases, you have
to use lstat to get the true value.  The invalid d_ino problem came up
recently with the report of pwd failing on systems with a losing (and
slightly old) glibc.

If someone else does all the work to make ensure the optimization
is safe, I'd accept a patch.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]