summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorGlenn L McGrath2003-01-20 23:50:59 +0000
committerGlenn L McGrath2003-01-20 23:50:59 +0000
commit2e51a14d57c3a2e6e2189d2a4c39f09023e4c524 (patch)
tree0853a379684502123b8f744c5f3d81634c5f114c /libbb
parentaad465efb7db4a86166149ed1ea251347ea2a606 (diff)
downloadbusybox-2e51a14d57c3a2e6e2189d2a4c39f09023e4c524.zip
busybox-2e51a14d57c3a2e6e2189d2a4c39f09023e4c524.tar.gz
New test mode that allows run_parts to fail silently if the directory
is not found. Patch from Bastian Blank
Diffstat (limited to 'libbb')
-rw-r--r--libbb/run_parts.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/libbb/run_parts.c b/libbb/run_parts.c
index 5fae805..7829a84 100644
--- a/libbb/run_parts.c
+++ b/libbb/run_parts.c
@@ -43,8 +43,10 @@ static int valid_name(const struct dirent *d)
return 1;
}
-/* run_parts */
-/* Find the parts to run & call run_part() */
+/* test mode = 1 is the same as offical run_parts
+ * test_mode = 2 means to fail siliently on missing directories
+ */
+
extern int run_parts(char **args, const unsigned char test_mode)
{
struct dirent **namelist = 0;
@@ -64,6 +66,9 @@ extern int run_parts(char **args, const unsigned char test_mode)
entries = scandir(arg0, &namelist, valid_name, alphasort);
if (entries == -1) {
+ if (test_mode & 2) {
+ return(2);
+ }
perror_msg_and_die("failed to open directory %s", arg0);
}
@@ -75,8 +80,8 @@ extern int run_parts(char **args, const unsigned char test_mode)
perror_msg_and_die("failed to stat component %s", filename);
}
if (S_ISREG(st.st_mode) && !access(filename, X_OK)) {
- if (test_mode) {
- puts("%s", filename);
+ if (test_mode & 1) {
+ puts(filename);
} else {
/* exec_errno is common vfork variable */
volatile int exec_errno = 0;