From 36adca81f54d9479a440865acd29fc2fbcfbaf1d Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Tue, 22 Jun 2004 10:07:17 +0000 Subject: Patch from Bastian Blank: On Sat, Jun 19, 2004 at 10:57:37PM +0200, Bastian Blank wrote: > The following patch changes klogd to use openlog/syslog themself > instead of calling syslog_msg which always calls the triple > openlog/syslog/closelog. Updated patch: get rid of syslog_msg entirely. Request from Erik Andersen. Bastian --- sysklogd/klogd.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'sysklogd/klogd.c') diff --git a/sysklogd/klogd.c b/sysklogd/klogd.c index 94da61658..9f07d6743 100644 --- a/sysklogd/klogd.c +++ b/sysklogd/klogd.c @@ -47,8 +47,8 @@ static void klogd_signal(int sig) klogctl(7, NULL, 0); klogctl(0, 0, 0); /* logMessage(0, "Kernel log daemon exiting."); */ - syslog_msg(LOG_SYSLOG, LOG_NOTICE, "Kernel log daemon exiting."); - exit(TRUE); + syslog(LOG_NOTICE, "Kernel log daemon exiting."); + exit(EXIT_SUCCESS); } static void doKlogd(const char console_log_level) __attribute__ ((noreturn)); @@ -59,6 +59,8 @@ static void doKlogd(const char console_log_level) int i, n, lastc; char *start; + openlog("kernel", 0, LOG_KERN); + /* Set up sig handlers */ signal(SIGINT, klogd_signal); signal(SIGKILL, klogd_signal); @@ -72,22 +74,17 @@ static void doKlogd(const char console_log_level) if (console_log_level) klogctl(8, NULL, console_log_level); - syslog_msg(LOG_SYSLOG, LOG_NOTICE, "klogd started: " BB_BANNER); + syslog(LOG_NOTICE, "klogd started: " BB_BANNER); while (1) { /* Use kernel syscalls */ memset(log_buffer, '\0', sizeof(log_buffer)); n = klogctl(2, log_buffer, sizeof(log_buffer)); if (n < 0) { - char message[80]; - if (errno == EINTR) continue; - snprintf(message, 79, - "klogd: Error return from sys_sycall: %d - %s.\n", errno, - strerror(errno)); - syslog_msg(LOG_SYSLOG, LOG_ERR, message); - exit(1); + syslog(LOG_ERR, "klogd: Error return from sys_sycall: %d - %s.\n", errno, strerror(errno)); + exit(EXIT_FAILURE); } /* klogctl buffer parsing modelled after code in dmesg.c */ @@ -107,7 +104,7 @@ static void doKlogd(const char console_log_level) } if (log_buffer[i] == '\n') { log_buffer[i] = '\0'; /* zero terminate this message */ - syslog_msg(LOG_KERN, priority, start); + syslog(priority, start); start = &log_buffer[i + 1]; priority = LOG_INFO; } -- cgit v1.2.3