Re: getcwd fixes for bugs in glibc, Solaris, OpenBSD, ...
From:
Jim Meyering
Subject:
Re: getcwd fixes for bugs in glibc, Solaris, OpenBSD, ...
Date:
Fri, 26 Nov 2004 09:14:26 +0100
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?
Thanks again for the nice patch.
However, having getcwd return directory names not restricted
by PATH_MAX may cause undesirable changes in behavior.
For example, save-cwd.c resorts to using getcwd (via xgetcwd) in some
cases. Before this change, if the working directory name was too long,
save_cwd's xgetcwd call would fail, and the save_cwd caller would
learn right away about the problem. Now, the caller won't find out
until it tries to return to that long-named directory and fails due to
restore_cwd's attempted chdir.
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.