[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ae3aff79301c130aa15b3fe0ff801804bb019384.camel@perches.com>
Date: Tue, 19 May 2020 21:58:53 -0700
From: Joe Perches <joe@...ches.com>
To: Sergey Senozhatsky <sergey.senozhatsky@...il.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Chenggang Wang <wangchenggang@...o.com>,
linux-kernel@...r.kernel.org, Petr Mladek <pmladek@...e.com>,
Steven Rostedt <rostedt@...dmis.org>
Subject: Re: [RFC PATCH 2/2] init: Allow multi-line output of kernel command
line
On Wed, 2020-05-20 at 13:41 +0900, Sergey Senozhatsky wrote:
> On (20/05/19 12:42), Joe Perches wrote:
> > +static void __init print_cmdline(char *line)
> > +{
> > +#ifdef CONFIG_PRINTK
> > + const char *prefix = "Kernel command line";
> > + size_t len = strlen(line);
> > +
> > + while (len > PRINTK_LOG_LINE_MAX) {
> > + char *pos = line;
> > + char *last_pos = pos + PRINTK_LOG_LINE_MAX - 1;
> > + char saved_char;
> > + /* Find last space char within the maximum line length */
> > + while ((pos = memchr(pos, ' ', len - (pos - line))) &&
> > + (pos - line) < PRINTK_LOG_LINE_MAX - 1) {
>
> Don't you need to also count in the 'prefix' length?
yup.
> > + last_pos = pos;
> > + }
> > + saved_char = line[last_pos - line];
> > + line[last_pos - line] = 0;
> > + pr_notice("%s: %s\n", prefix, line);
> > + prefix = "Kernel command line (continued)";
> > + line[last_pos - line] = saved_char;
> > + len -= pos - line;
> > + line += pos - line;
> > + }
> > +
> > + pr_notice("%s: %s\n", prefix, line);
> > +#endif
> > +}
>
> I like this in general. And I agree that we better handle this
> externally, on the printk() caller side, so that printk() will
> still have sane limits and won't print a 1G string for example.
>
> I wonder if we need to export PRINTK_LOG_LINE_MAX.
I think a #define works well enough.(
> Maybe we can
> use here something rather random and much shorter instead. E.g.
> 256 chars. Hmm. How
min(some_max like 132/256, PRINTK_LOG_LINE_MAX)
would work.
> many crash/monitoring tools can get confused
> by multiple "Kernel command line" prefixes?
I doubt any as it's an init only function.
Powered by blists - more mailing lists