aboutsummaryrefslogtreecommitdiff
path: root/sysklogd/klogd.c
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2002-12-01 11:31:58 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2002-12-01 11:31:58 +0000
commite1ad672216ac9622cb478bb9e3cc088d96a0c3e4 (patch)
treec0ace6b2f70117725506d50581ff564cfe1e1c43 /sysklogd/klogd.c
parent6fc6d7fe4fb4945b44389aa34ed1174bc4defd69 (diff)
downloadbusybox-w32-e1ad672216ac9622cb478bb9e3cc088d96a0c3e4.tar.gz
busybox-w32-e1ad672216ac9622cb478bb9e3cc088d96a0c3e4.tar.bz2
busybox-w32-e1ad672216ac9622cb478bb9e3cc088d96a0c3e4.zip
add the -c option, modified version of a patch from Bastian Blank
Diffstat (limited to 'sysklogd/klogd.c')
-rw-r--r--sysklogd/klogd.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/sysklogd/klogd.c b/sysklogd/klogd.c
index f2ab5ea7e..710bd5a31 100644
--- a/sysklogd/klogd.c
+++ b/sysklogd/klogd.c
@@ -59,8 +59,8 @@ static void klogd_signal(int sig)
59 exit(TRUE); 59 exit(TRUE);
60} 60}
61 61
62static void doKlogd(void) __attribute__ ((noreturn)); 62static void doKlogd(const char console_log_level) __attribute__ ((noreturn));
63static void doKlogd(void) 63static void doKlogd(const char console_log_level)
64{ 64{
65 int priority = LOG_INFO; 65 int priority = LOG_INFO;
66 char log_buffer[4096]; 66 char log_buffer[4096];
@@ -76,6 +76,10 @@ static void doKlogd(void)
76 /* "Open the log. Currently a NOP." */ 76 /* "Open the log. Currently a NOP." */
77 klogctl(1, NULL, 0); 77 klogctl(1, NULL, 0);
78 78
79 /* Set level of kernel console messaging.. */
80 if (console_log_level)
81 klogctl(8, NULL, console_log_level);
82
79 syslog_msg(LOG_SYSLOG, LOG_NOTICE, "klogd started: " BB_BANNER); 83 syslog_msg(LOG_SYSLOG, LOG_NOTICE, "klogd started: " BB_BANNER);
80 84
81 while (1) { 85 while (1) {
@@ -125,10 +129,23 @@ extern int klogd_main(int argc, char **argv)
125 /* no options, no getopt */ 129 /* no options, no getopt */
126 int opt; 130 int opt;
127 int doFork = TRUE; 131 int doFork = TRUE;
132 unsigned char console_log_level = 7;
128 133
129 /* do normal option parsing */ 134 /* do normal option parsing */
130 while ((opt = getopt(argc, argv, "n")) > 0) { 135 while ((opt = getopt(argc, argv, "c:n")) > 0) {
131 switch (opt) { 136 switch (opt) {
137 case 'c':
138 if ((optarg == NULL) || (optarg[1] != '\0')) {
139 show_usage();
140 }
141 /* Valid levels are between 1 and 8 */
142 console_log_level = *optarg - '1';
143 if (console_log_level > 7) {
144 show_usage();
145 }
146 console_log_level++;
147
148 break;
132 case 'n': 149 case 'n':
133 doFork = FALSE; 150 doFork = FALSE;
134 break; 151 break;
@@ -145,7 +162,7 @@ extern int klogd_main(int argc, char **argv)
145 error_msg_and_die("daemon not supported"); 162 error_msg_and_die("daemon not supported");
146#endif 163#endif
147 } 164 }
148 doKlogd(); 165 doKlogd(console_log_level);
149 166
150 return EXIT_SUCCESS; 167 return EXIT_SUCCESS;
151} 168}