[BusyBox-cvs] busybox/sysklogd klogd.c,1.11,1.12

Glenn McGrath bug1 at busybox.net
Sun Dec 1 11:32:02 UTC 2002


Update of /var/cvs/busybox/sysklogd
In directory winder:/tmp/cvs-serv30388/sysklogd

Modified Files:
	klogd.c 
Log Message:
add the -c option, modified version of a patch from Bastian Blank


Index: klogd.c
===================================================================
RCS file: /var/cvs/busybox/sysklogd/klogd.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- klogd.c	18 Sep 2002 14:23:06 -0000	1.11
+++ klogd.c	1 Dec 2002 11:31:58 -0000	1.12
@@ -59,8 +59,8 @@
 	exit(TRUE);
 }
 
-static void doKlogd(void) __attribute__ ((noreturn));
-static void doKlogd(void)
+static void doKlogd(const char console_log_level) __attribute__ ((noreturn));
+static void doKlogd(const char console_log_level)
 {
 	int priority = LOG_INFO;
 	char log_buffer[4096];
@@ -76,6 +76,10 @@
 	/* "Open the log. Currently a NOP." */
 	klogctl(1, NULL, 0);
 
+	/* Set level of kernel console messaging.. */
+	if (console_log_level)
+		klogctl(8, NULL, console_log_level);
+
 	syslog_msg(LOG_SYSLOG, LOG_NOTICE, "klogd started: " BB_BANNER);
 
 	while (1) {
@@ -125,10 +129,23 @@
 	/* no options, no getopt */
 	int opt;
 	int doFork = TRUE;
+	unsigned char console_log_level = 7;
 
 	/* do normal option parsing */
-	while ((opt = getopt(argc, argv, "n")) > 0) {
+	while ((opt = getopt(argc, argv, "c:n")) > 0) {
 		switch (opt) {
+		case 'c':
+			if ((optarg == NULL) || (optarg[1] != '\0')) {
+				show_usage();
+			}
+			/* Valid levels are between 1 and 8 */
+			console_log_level = *optarg - '1';
+			if (console_log_level > 7) {
+				show_usage();
+			}
+			console_log_level++;
+			
+			break;
 		case 'n':
 			doFork = FALSE;
 			break;
@@ -145,7 +162,7 @@
 		error_msg_and_die("daemon not supported");
 #endif
 	}
-	doKlogd();
+	doKlogd(console_log_level);
 
 	return EXIT_SUCCESS;
 }




More information about the busybox-cvs mailing list