diff options
author | Eric Andersen <andersen@codepoet.org> | 1999-12-05 23:24:55 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 1999-12-05 23:24:55 +0000 |
commit | 0ecb54a0f3fece5e42f089036f059973bed8d87e (patch) | |
tree | e25c3d29c9c92fed488e03459b2aee558b1a8d25 /sysklogd | |
parent | 14ec6cf3c224d53219b2713b0040dfa03314d5b3 (diff) | |
download | busybox-w32-0ecb54a0f3fece5e42f089036f059973bed8d87e.tar.gz busybox-w32-0ecb54a0f3fece5e42f089036f059973bed8d87e.tar.bz2 busybox-w32-0ecb54a0f3fece5e42f089036f059973bed8d87e.zip |
Stuf
Diffstat (limited to 'sysklogd')
-rw-r--r-- | sysklogd/syslogd.c | 31 |
1 files changed, 6 insertions, 25 deletions
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index e3f45b62a..1f3e31225 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c | |||
@@ -57,13 +57,13 @@ static char LocalHostName[32]; | |||
57 | 57 | ||
58 | static const char syslogd_usage[] = | 58 | static const char syslogd_usage[] = |
59 | "syslogd [OPTION]...\n\n" | 59 | "syslogd [OPTION]...\n\n" |
60 | "Linux system logging utility.\n\n" | 60 | "Linux system and kernel (provides klogd) logging utility.\n" |
61 | "Note that this version of syslogd/klogd ignores /etc/syslog.conf.\n\n" | ||
61 | "Options:\n" | 62 | "Options:\n" |
62 | "\t-m\tChange the mark timestamp interval. default=20min. 0=off\n" | 63 | "\t-m\tChange the mark timestamp interval. default=20min. 0=off\n" |
63 | "\t-n\tDo not fork into the background (for when run by init)\n" | 64 | "\t-n\tDo not fork into the background (for when run by init)\n" |
64 | "\t-O\tSpecify an alternate log file. default=/var/log/messages\n"; | 65 | "\t-O\tSpecify an alternate log file. default=/var/log/messages\n"; |
65 | 66 | ||
66 | static int kmsg; | ||
67 | 67 | ||
68 | /* try to open up the specified device */ | 68 | /* try to open up the specified device */ |
69 | static int device_open(char *device, int mode) | 69 | static int device_open(char *device, int mode) |
@@ -253,10 +253,9 @@ static void doSyslogd(void) | |||
253 | 253 | ||
254 | static void klogd_signal(int sig) | 254 | static void klogd_signal(int sig) |
255 | { | 255 | { |
256 | //ksyslog(7, NULL, 0); | 256 | ksyslog(7, NULL, 0); |
257 | //ksyslog(0, 0, 0); | 257 | ksyslog(0, 0, 0); |
258 | logMessage(LOG_SYSLOG|LOG_INFO, "Kernel log daemon exiting."); | 258 | logMessage(LOG_SYSLOG|LOG_INFO, "Kernel log daemon exiting."); |
259 | close( kmsg); | ||
260 | exit( TRUE); | 259 | exit( TRUE); |
261 | } | 260 | } |
262 | 261 | ||
@@ -264,7 +263,6 @@ static void klogd_signal(int sig) | |||
264 | static void doKlogd(void) | 263 | static void doKlogd(void) |
265 | { | 264 | { |
266 | int priority=LOG_INFO; | 265 | int priority=LOG_INFO; |
267 | struct stat sb; | ||
268 | char log_buffer[4096]; | 266 | char log_buffer[4096]; |
269 | char *logp; | 267 | char *logp; |
270 | 268 | ||
@@ -277,26 +275,10 @@ static void doKlogd(void) | |||
277 | "BusyBox v" BB_VER " (" BB_BT ")"); | 275 | "BusyBox v" BB_VER " (" BB_BT ")"); |
278 | 276 | ||
279 | ksyslog(1, NULL, 0); | 277 | ksyslog(1, NULL, 0); |
280 | if ( ((stat(_PATH_KLOG, &sb) < 0) && (errno == ENOENT)) || | 278 | |
281 | ( (kmsg = open(_PATH_KLOG, O_RDONLY)) < 0 ) ) { | ||
282 | char message[80]; | ||
283 | snprintf(message, 79, "klogd: Cannot open %s, " \ | ||
284 | "%d - %s.\n", _PATH_KLOG, errno, strerror(errno)); | ||
285 | logMessage(LOG_SYSLOG|LOG_ERR, message); | ||
286 | klogd_signal(0); | ||
287 | } | ||
288 | while (1) { | 279 | while (1) { |
280 | /* Use kernel syscalls */ | ||
289 | memset(log_buffer, '\0', sizeof(log_buffer)); | 281 | memset(log_buffer, '\0', sizeof(log_buffer)); |
290 | if ( read(kmsg, log_buffer, sizeof(log_buffer)-1) < 0 ) { | ||
291 | char message[80]; | ||
292 | if ( errno == EINTR ) | ||
293 | continue; | ||
294 | snprintf(message, 79, "klogd: Cannot read proc file system: %d - %s.\n", | ||
295 | errno, strerror(errno)); | ||
296 | logMessage(LOG_SYSLOG|LOG_ERR, message); | ||
297 | klogd_signal(0); | ||
298 | } | ||
299 | #if 0 | ||
300 | if ( ksyslog(2, log_buffer, sizeof(log_buffer)) < 0 ) { | 282 | if ( ksyslog(2, log_buffer, sizeof(log_buffer)) < 0 ) { |
301 | char message[80]; | 283 | char message[80]; |
302 | if ( errno == EINTR ) | 284 | if ( errno == EINTR ) |
@@ -306,7 +288,6 @@ static void doKlogd(void) | |||
306 | logMessage(LOG_SYSLOG|LOG_ERR, message); | 288 | logMessage(LOG_SYSLOG|LOG_ERR, message); |
307 | exit(1); | 289 | exit(1); |
308 | } | 290 | } |
309 | #endif | ||
310 | logp=log_buffer; | 291 | logp=log_buffer; |
311 | if ( *log_buffer == '<' ) | 292 | if ( *log_buffer == '<' ) |
312 | { | 293 | { |