aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Whitley <markw@lineo.com>2001-03-08 16:54:44 +0000
committerMark Whitley <markw@lineo.com>2001-03-08 16:54:44 +0000
commite2c44fc966d30ba719dcf3bc65c60f275ee7d8a4 (patch)
treea4e9865bb5337eca8d1d446411505bc1c8234525
parent5de909873a6a46286105c087c8c339a0f7259782 (diff)
downloadbusybox-e2c44fc966d30ba719dcf3bc65c60f275ee7d8a4.tar.gz
Applied patch from Vladimir to fix bug where find would stop as soon as it hit
a perms error. Closes bug 1124.
-rw-r--r--utility.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/utility.c b/utility.c
index 7c7af1590..140480bdd 100644
--- a/utility.c
+++ b/utility.c
@@ -703,14 +703,15 @@ int recursive_action(const char *fileName,
perror_msg("%s", fileName);
return FALSE;
}
+ status = TRUE;
while ((next = readdir(dir)) != NULL) {
- char nextFile[BUFSIZ + 1];
+ char nextFile[PATH_MAX];
if ((strcmp(next->d_name, "..") == 0)
- || (strcmp(next->d_name, ".") == 0)) {
+ || (strcmp(next->d_name, ".") == 0)) {
continue;
}
- if (strlen(fileName) + strlen(next->d_name) + 1 > BUFSIZ) {
+ if (strlen(fileName) + strlen(next->d_name) + 1 > PATH_MAX) {
error_msg(name_too_long);
return FALSE;
}
@@ -719,26 +720,20 @@ int recursive_action(const char *fileName,
sprintf(nextFile, "%s%s", fileName, next->d_name);
else
sprintf(nextFile, "%s/%s", fileName, next->d_name);
- status =
- recursive_action(nextFile, TRUE, followLinks, depthFirst,
- fileAction, dirAction, userData);
- if (status == FALSE) {
- closedir(dir);
- return FALSE;
+ if (recursive_action(nextFile, TRUE, followLinks, depthFirst,
+ fileAction, dirAction, userData) == FALSE) {
+ status = FALSE;
}
}
- status = closedir(dir);
- if (status < 0) {
- perror_msg("%s", fileName);
- return FALSE;
- }
+ closedir(dir);
if (dirAction != NULL && depthFirst == TRUE) {
- status = dirAction(fileName, &statbuf, userData);
- if (status == FALSE) {
+ if (dirAction(fileName, &statbuf, userData) == FALSE) {
perror_msg("%s", fileName);
return FALSE;
}
}
+ if (status == FALSE)
+ return FALSE;
} else {
if (fileAction == NULL)
return TRUE;