diff options
author | Mark Whitley <markw@lineo.com> | 2001-03-08 16:54:44 +0000 |
---|---|---|
committer | Mark Whitley <markw@lineo.com> | 2001-03-08 16:54:44 +0000 |
commit | e2c44fc966d30ba719dcf3bc65c60f275ee7d8a4 (patch) | |
tree | a4e9865bb5337eca8d1d446411505bc1c8234525 | |
parent | 5de909873a6a46286105c087c8c339a0f7259782 (diff) | |
download | busybox-w32-e2c44fc966d30ba719dcf3bc65c60f275ee7d8a4.tar.gz busybox-w32-e2c44fc966d30ba719dcf3bc65c60f275ee7d8a4.tar.bz2 busybox-w32-e2c44fc966d30ba719dcf3bc65c60f275ee7d8a4.zip |
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.c | 27 |
1 files changed, 11 insertions, 16 deletions
@@ -703,14 +703,15 @@ int recursive_action(const char *fileName, | |||
703 | perror_msg("%s", fileName); | 703 | perror_msg("%s", fileName); |
704 | return FALSE; | 704 | return FALSE; |
705 | } | 705 | } |
706 | status = TRUE; | ||
706 | while ((next = readdir(dir)) != NULL) { | 707 | while ((next = readdir(dir)) != NULL) { |
707 | char nextFile[BUFSIZ + 1]; | 708 | char nextFile[PATH_MAX]; |
708 | 709 | ||
709 | if ((strcmp(next->d_name, "..") == 0) | 710 | if ((strcmp(next->d_name, "..") == 0) |
710 | || (strcmp(next->d_name, ".") == 0)) { | 711 | || (strcmp(next->d_name, ".") == 0)) { |
711 | continue; | 712 | continue; |
712 | } | 713 | } |
713 | if (strlen(fileName) + strlen(next->d_name) + 1 > BUFSIZ) { | 714 | if (strlen(fileName) + strlen(next->d_name) + 1 > PATH_MAX) { |
714 | error_msg(name_too_long); | 715 | error_msg(name_too_long); |
715 | return FALSE; | 716 | return FALSE; |
716 | } | 717 | } |
@@ -719,26 +720,20 @@ int recursive_action(const char *fileName, | |||
719 | sprintf(nextFile, "%s%s", fileName, next->d_name); | 720 | sprintf(nextFile, "%s%s", fileName, next->d_name); |
720 | else | 721 | else |
721 | sprintf(nextFile, "%s/%s", fileName, next->d_name); | 722 | sprintf(nextFile, "%s/%s", fileName, next->d_name); |
722 | status = | 723 | if (recursive_action(nextFile, TRUE, followLinks, depthFirst, |
723 | recursive_action(nextFile, TRUE, followLinks, depthFirst, | 724 | fileAction, dirAction, userData) == FALSE) { |
724 | fileAction, dirAction, userData); | 725 | status = FALSE; |
725 | if (status == FALSE) { | ||
726 | closedir(dir); | ||
727 | return FALSE; | ||
728 | } | 726 | } |
729 | } | 727 | } |
730 | status = closedir(dir); | 728 | closedir(dir); |
731 | if (status < 0) { | ||
732 | perror_msg("%s", fileName); | ||
733 | return FALSE; | ||
734 | } | ||
735 | if (dirAction != NULL && depthFirst == TRUE) { | 729 | if (dirAction != NULL && depthFirst == TRUE) { |
736 | status = dirAction(fileName, &statbuf, userData); | 730 | if (dirAction(fileName, &statbuf, userData) == FALSE) { |
737 | if (status == FALSE) { | ||
738 | perror_msg("%s", fileName); | 731 | perror_msg("%s", fileName); |
739 | return FALSE; | 732 | return FALSE; |
740 | } | 733 | } |
741 | } | 734 | } |
735 | if (status == FALSE) | ||
736 | return FALSE; | ||
742 | } else { | 737 | } else { |
743 | if (fileAction == NULL) | 738 | if (fileAction == NULL) |
744 | return TRUE; | 739 | return TRUE; |