Re: [RFC][PATCH] printk: Add option to append kernel version to the dict

From: Calvin Owens
Date: Mon May 16 2016 - 18:04:16 EST


On Sunday 05/15 at 15:36 +0900, Sergey Senozhatsky wrote:
> Hello,
>
> On (05/13/16 13:58), Calvin Owens wrote:
> [..]
> > +#if defined(CONFIG_PRINTK_APPEND_UNAME)
> > +static ssize_t msg_print_ext_uname(char *buf, size_t size)
> > +{
> > + return scnprintf(buf, size, " UNAME=%s\n", init_utsname()->release);
> > +}
> > +#else
> > +static ssize_t msg_print_ext_uname(char *buf, size_t size)
> > +{
> > + return 0;
> > +}
> > +#endif
> > +
> > /* /dev/kmsg - userspace message inject/listen interface */
> > struct devkmsg_user {
> > u64 seq;
> > @@ -2305,6 +2317,8 @@ skip:
> > sizeof(ext_text) - ext_len,
> > log_dict(msg), msg->dict_len,
> > log_text(msg), msg->text_len);
> > + ext_len += msg_print_ext_uname(ext_text + ext_len,
> > + sizeof(ext_text) - ext_len);
> > }
>
> what if there is no place left for init_utsname() after
> msg_print_ext_header() + msg_print_ext_body()?

It ends up being truncated, like either of the preceeding calls would.

> do you need init_utsname in every message? or just in WARN/ERR ones?

I need it added to anything which netconsole actually emits: so I could
filter based on loglevel here if you like.

Thanks,
Calvin

>
> -ss