[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gnulib] Re: getcwd fixes for bugs in glibc, Solaris, OpenBSD, ...
From: |
Jim Meyering |
Subject: |
[bug-gnulib] Re: getcwd fixes for bugs in glibc, Solaris, OpenBSD, ... |
Date: |
Sun, 28 Nov 2004 22:22:19 +0100 |
Jim Meyering <address@hidden> wrote:
> Paul Eggert <address@hidden> wrote:
> ...
>> As a result of this patch, getcwd is limited only by available memory
>> on hosts like Solaris that support AT_FDCWD. Maybe we should alter
>> coreutils/src/pwd.c to not use the "robust getcwd" algorithm on hosts
>> with AT_FDCWD, since it's useless code on those hosts?
...
> Maybe we should see this as an opportunity to write a robust wrapper
> around chdir itself: if it fails because of ENAMETOOLONG, then have it
> resort to retrying with shorter portions of the long name.
I've implemented such a chdir function.
The situation with it is a little different than with getcwd.
Sometimes, we know that there is no risk of chdir failing with
ENAMETOOLONG, (e.g. getcwd.c, pwd.c, remove.c, etc.).
What's the performance difference?
on a linux-2.6.9 tmpfs file system, with a directory named /t/z/z/z/...z
with 200,000 z's, I ran coreutils pwd from that directory.
The difference was about .2 seconds:
1.50s with the unnecessary robust chdir wrapper
1.28s with no chdir wrapper
It's easy to pick and choose which *applications* use the replacement.
Those that want the robust chdir should just include "chdir.h".
The problem is when there's a mix of uses, some where we know
the chdir argument is always a relative single component, or
otherwise valid, while restore_cwd may well need the robust version
if save_cwd was run from a deep working directory where open "." failed.
Anyhow, for now, I've implemented it to do a replacement,
defining rpl_chdir. If a problem arises, we can give it
a different name.
save-cwd.c is the only client that uses this, so far.
- [bug-gnulib] getcwd fixes for bugs in glibc, Solaris, OpenBSD, ..., Paul Eggert, 2004/11/25
- [bug-gnulib] Re: getcwd fixes for bugs in glibc, Solaris, OpenBSD, ..., Jim Meyering, 2004/11/25
- [bug-gnulib] Re: getcwd fixes for bugs in glibc, Solaris, OpenBSD, ..., Jim Meyering, 2004/11/26
- [bug-gnulib] Re: getcwd fixes for bugs in glibc, Solaris, OpenBSD, ..., Paul Eggert, 2004/11/26
- [bug-gnulib] Re: getcwd fixes for bugs in glibc, Solaris, OpenBSD, ...,
Jim Meyering <=
- [bug-gnulib] Re: getcwd fixes for bugs in glibc, Solaris, OpenBSD, ..., Paul Eggert, 2004/11/28
- Re: [bug-gnulib] Re: getcwd fixes for bugs in glibc, Solaris, OpenBSD, ..., Jim Meyering, 2004/11/29
- [bug-gnulib] Re: getcwd fixes for bugs in glibc, Solaris, OpenBSD, ..., Jim Meyering, 2004/11/26
- [bug-gnulib] Re: getcwd fixes for bugs in glibc, Solaris, OpenBSD, ..., Jim Meyering, 2004/11/28
- [bug-gnulib] Re: getcwd fixes for bugs in glibc, Solaris, OpenBSD, ..., Paul Eggert, 2004/11/28
- Re: [bug-gnulib] Re: getcwd fixes for bugs in glibc, Solaris, OpenBSD, ..., Jim Meyering, 2004/11/29