Skip to content

Commit

Permalink
kmsg: add the facility number to the syslog prefix
Browse files Browse the repository at this point in the history
After the recent split of facility and level into separate variables,
we miss the facility value (always 0 for kernel-originated messages)
in the syslog prefix.

On Tue, Jul 3, 2012 at 12:45 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> Static checkers complain about the impossible condition here.
>
> In 084681d ('printk: flush continuation lines immediately to
> console'), we changed msg->level from being a u16 to being an unsigned
> 3 bit bitfield.

Cc: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Kay Sievers <kay@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Kay Sievers authored and Greg Kroah-Hartman committed Jul 6, 2012
1 parent e3f5a5f commit 43a73a5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions kernel/printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -818,15 +818,18 @@ static size_t print_time(u64 ts, char *buf)
static size_t print_prefix(const struct log *msg, bool syslog, char *buf)
{
size_t len = 0;
unsigned int prefix = (msg->facility << 3) | msg->level;

if (syslog) {
if (buf) {
len += sprintf(buf, "<%u>", msg->level);
len += sprintf(buf, "<%u>", prefix);
} else {
len += 3;
if (msg->level > 9)
len++;
if (msg->level > 99)
if (prefix > 999)
len += 3;
else if (prefix > 99)
len += 2;
else if (prefix > 9)
len++;
}
}
Expand Down

0 comments on commit 43a73a5

Please sign in to comment.