[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200521150817.GA502432@rani.riverdale.lan>
Date: Thu, 21 May 2020 11:08:17 -0400
From: Arvind Sankar <nivedita@...m.mit.edu>
To: Petr Mladek <pmladek@...e.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
Joe Perches <joe@...ches.com>,
Chenggang Wang <wangchenggang@...o.com>,
linux-kernel@...r.kernel.org, Steven Rostedt <rostedt@...dmis.org>
Subject: Re: [RFC PATCH 2/2] init: Allow multi-line output of kernel command
line
On Thu, May 21, 2020 at 02:31:17PM +0200, Petr Mladek wrote:
> On Wed 2020-05-20 21:40:07, Andrew Morton wrote:
> > On Thu, 21 May 2020 13:36:28 +0900 Sergey Senozhatsky <sergey.senozhatsky@...il.com> wrote:
> >
> > > On (20/05/20 18:00), Andrew Morton wrote:
> > > [..]
> > > > I'm wondering if we shold add a kernel puts() (putsk()? yuk) which can
> > > > puts() a string of any length.
> > > >
> > > > I'm counting around 150 instances of printk("%s", ...) and pr_foo("%s",
> > > > ...) which could perhaps be converted, thus saving an argument.
> > >
> > > Can you point me at some examples?
> > >
> >
> > ./arch/powerpc/kernel/udbg.c: printk("%s", s);
> > ./arch/powerpc/xmon/nonstdio.c: printk("%s", xmon_outbuf);
> > ./arch/um/os-Linux/drivers/ethertap_user.c: printk("%s", output);
> > ./arch/um/os-Linux/drivers/ethertap_user.c: printk("%s", output);
> > ./arch/um/os-Linux/drivers/tuntap_user.c: printk("%s", out
> >
> > etc.
> >
> > My point is, if we created a length-unlimited puts() function for printing the
> > kernel command line, it could be reused in such places, resulting in a
> > smaller kernel.
>
> Interesting idea. Well, such a generic function would need to be safe
> and do not modify the original string. We would need to implement
> printk() variant that would support strigs limited by size instead
> of the trailing '\0'. I am not sure if it is worth it.
>
> Best Regards,
> Petr
You don't need a printk variant for strings -- you'd only need one if
you wanted formatted output of unlimited length. Using printk("%.*s",
chunk_size, str) should print at most chunk_size characters from str.
The puts could then just be a loop around that.
Something like:
do {
printed = printk("%.*s", chunk_size, str);
str += printed;
} while (printed >= chunk_size);
Powered by blists - more mailing lists