On 6/1/06, Jim Meyering <[EMAIL PROTECTED]> wrote:

> 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.

After writing that, I remembered that this optimization
has already been done on the trunk.  However, there's no check
for the glibc problem:
[...]
The problem is rare enough that I won't be losing any
sleep over it.  But it would be good to fix it, or at least
add a test case comparing st_ino vs. d_ino for every readable
directory from "." up to "/".  Then (from test failure reports)
we can hope to get an idea of how often the problem arises.

You could stat "/" at startup, and if its inode number is 2 (hint that
we're probably not chrooted), trust d_ino, and don't trust it if d_ino
is not 2 (we're probably chrooted).   The check is only probabilistic,
but it might help.  It shouldn't be fooled by fsirand.

James.


_______________________________________________
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to