Be much more strict about parsing tagged log messages from /dev/klog;

if the line doesn't match ^<%d>, then treat it as a regular kernel
printf line. Previously if a kernel printf message started with "<"
it would be interpreted as a log message, often with LOG_EMERG
level. This was triggered by some printfs in sys/dev/aic7xxx/, and
can also happen with the partial lines that result if syslogd cannot
keep up with the rate of arrival of kernel messages.

Reviewed by:	dwmalone
MFC after:	1 week
This commit is contained in:
Ian Dowse 2004-01-26 00:46:46 +00:00
parent e7245381b9
commit ff96c77dc4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=124992

View File

@ -734,24 +734,34 @@ readklog(void)
* Take a raw input line from /dev/klog, format similar to syslog().
*/
static void
printsys(char *p)
printsys(char *msg)
{
int pri, flags;
char *p;
int flags, isprintf, n, pri;
flags = ISKERNEL | SYNC_FILE | ADDDATE; /* fsync after write */
pri = DEFSPRI;
p = msg;
isprintf = 1;
if (*p == '<') {
pri = 0;
n = 0;
while (isdigit(*++p))
pri = 10 * pri + (*p - '0');
if (*p == '>')
n = 10 * n + (*p - '0');
if (*p == '>') {
++p;
if ((pri & LOG_FACMASK) == LOG_CONSOLE)
flags |= IGN_CONS;
} else {
/* kernel printf's come out on console */
flags |= IGN_CONS;
pri = n;
isprintf = 0;
} else {
/* It wasn't actually a syslog message. */
p = msg;
}
}
/*
* Kernel printf's and LOG_CONSOLE messages have been displayed
* on the console already.
*/
if (isprintf || (pri & LOG_FACMASK) == LOG_CONSOLE)
flags |= IGN_CONS;
if (pri &~ (LOG_FACMASK|LOG_PRIMASK))
pri = DEFSPRI;
logmsg(pri, p, LocalHostName, flags);