aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2003-01-20 23:50:59 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2003-01-20 23:50:59 +0000
commit2e51a14d57c3a2e6e2189d2a4c39f09023e4c524 (patch)
tree0853a379684502123b8f744c5f3d81634c5f114c
parentaad465efb7db4a86166149ed1ea251347ea2a606 (diff)
downloadbusybox-w32-2e51a14d57c3a2e6e2189d2a4c39f09023e4c524.tar.gz
busybox-w32-2e51a14d57c3a2e6e2189d2a4c39f09023e4c524.tar.bz2
busybox-w32-2e51a14d57c3a2e6e2189d2a4c39f09023e4c524.zip
New test mode that allows run_parts to fail silently if the directory
is not found. Patch from Bastian Blank
-rw-r--r--include/libbb.h8
-rw-r--r--libbb/run_parts.c13
-rw-r--r--networking/ifupdown.c2
3 files changed, 14 insertions, 9 deletions
diff --git a/include/libbb.h b/include/libbb.h
index a827ba612..d67bf07ec 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -86,11 +86,11 @@ char *strtok_r(char *s, const char *delim, char **ptrptr);
86extern void show_usage(void) __attribute__ ((noreturn)); 86extern void show_usage(void) __attribute__ ((noreturn));
87extern void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); 87extern void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
88extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))); 88extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
89extern void perror_msg(const char *s, ...); 89extern void perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
90extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn)); 90extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
91extern void vherror_msg(const char *s, va_list p); 91extern void vherror_msg(const char *s, va_list p);
92extern void herror_msg(const char *s, ...); 92extern void herror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
93extern void herror_msg_and_die(const char *s, ...) __attribute__ ((noreturn)); 93extern void herror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
94 94
95/* These two are used internally -- you shouldn't need to use them */ 95/* These two are used internally -- you shouldn't need to use them */
96extern void verror_msg(const char *s, va_list p); 96extern void verror_msg(const char *s, va_list p);
diff --git a/libbb/run_parts.c b/libbb/run_parts.c
index 5fae80592..7829a84ba 100644
--- a/libbb/run_parts.c
+++ b/libbb/run_parts.c
@@ -43,8 +43,10 @@ static int valid_name(const struct dirent *d)
43 return 1; 43 return 1;
44} 44}
45 45
46/* run_parts */ 46/* test mode = 1 is the same as offical run_parts
47/* Find the parts to run & call run_part() */ 47 * test_mode = 2 means to fail siliently on missing directories
48 */
49
48extern int run_parts(char **args, const unsigned char test_mode) 50extern int run_parts(char **args, const unsigned char test_mode)
49{ 51{
50 struct dirent **namelist = 0; 52 struct dirent **namelist = 0;
@@ -64,6 +66,9 @@ extern int run_parts(char **args, const unsigned char test_mode)
64 entries = scandir(arg0, &namelist, valid_name, alphasort); 66 entries = scandir(arg0, &namelist, valid_name, alphasort);
65 67
66 if (entries == -1) { 68 if (entries == -1) {
69 if (test_mode & 2) {
70 return(2);
71 }
67 perror_msg_and_die("failed to open directory %s", arg0); 72 perror_msg_and_die("failed to open directory %s", arg0);
68 } 73 }
69 74
@@ -75,8 +80,8 @@ extern int run_parts(char **args, const unsigned char test_mode)
75 perror_msg_and_die("failed to stat component %s", filename); 80 perror_msg_and_die("failed to stat component %s", filename);
76 } 81 }
77 if (S_ISREG(st.st_mode) && !access(filename, X_OK)) { 82 if (S_ISREG(st.st_mode) && !access(filename, X_OK)) {
78 if (test_mode) { 83 if (test_mode & 1) {
79 puts("%s", filename); 84 puts(filename);
80 } else { 85 } else {
81 /* exec_errno is common vfork variable */ 86 /* exec_errno is common vfork variable */
82 volatile int exec_errno = 0; 87 volatile int exec_errno = 0;
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index be09ea6e7..f33dbc43c 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -1010,7 +1010,7 @@ static int execute_all(interface_defn_t *ifd, execfn *exec, const char *opt)
1010 1010
1011 buf = xmalloc(xstrlen(opt) + 19); 1011 buf = xmalloc(xstrlen(opt) + 19);
1012 sprintf(buf, "/etc/network/if-%s.d", opt); 1012 sprintf(buf, "/etc/network/if-%s.d", opt);
1013 run_parts(&buf, 0); 1013 run_parts(&buf, 2);
1014 free(buf); 1014 free(buf);
1015 return (1); 1015 return (1);
1016} 1016}