Mercurial > illumos > illumos-gate
changeset 12577:98b7657d1987
6470471 find should work even if a parent directory is read-protected
author | Rich Burridge <rich.burridge@oracle.com> |
---|---|
date | Mon, 07 Jun 2010 13:43:38 -0700 |
parents | ab8aacaead3f |
children | f9062c43c8bc |
files | usr/src/cmd/find/find.c |
diffstat | 1 files changed, 14 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/find/find.c Mon Jun 07 14:10:14 2010 -0400 +++ b/usr/src/cmd/find/find.c Mon Jun 07 13:43:38 2010 -0700 @@ -341,10 +341,20 @@ * error related to this */ if ((cwdpath = getcwd(NULL, PATH_MAX)) == NULL) { - (void) fprintf(stderr, - gettext("%s : cannot get the current working " - "directory\n"), cmdname); - exit(1); + if ((errno == EACCES) && (walkflags & FTW_CHDIR)) { + /* + * A directory above cwd is inaccessible, + * so don't do chdir(2)s. Slower, but at least + * it works. + */ + walkflags &= ~FTW_CHDIR; + free(cwdpath); + } else { + (void) fprintf(stderr, + gettext("%s : cannot get the current " + "working directory\n"), cmdname); + exit(1); + } } else free(cwdpath);