New test mode that allows run_parts to fail silently if the directory
is not found. Patch from Bastian Blank
diff --git a/include/libbb.h b/include/libbb.h
index a827ba6..d67bf07 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -86,11 +86,11 @@
 extern void show_usage(void) __attribute__ ((noreturn));
 extern void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
 extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
-extern void perror_msg(const char *s, ...);
-extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn));
+extern void perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
+extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
 extern void vherror_msg(const char *s, va_list p);
-extern void herror_msg(const char *s, ...);
-extern void herror_msg_and_die(const char *s, ...) __attribute__ ((noreturn));
+extern void herror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
+extern void herror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
 
 /* These two are used internally -- you shouldn't need to use them */
 extern void verror_msg(const char *s, va_list p);
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 @@
 	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 @@
 	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 @@
 			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;
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index be09ea6..f33dbc4 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -1010,7 +1010,7 @@
 
 	buf = xmalloc(xstrlen(opt) + 19);
 	sprintf(buf, "/etc/network/if-%s.d", opt);
-	run_parts(&buf, 0);
+	run_parts(&buf, 2);
 	free(buf);
 	return (1);
 }