Re: [PATCH v6 08/22] bootconfig: init: Allow admin to use bootconfig for init command line

From: Masami Hiramatsu
Date: Mon Aug 03 2020 - 11:03:56 EST


On Sat, 1 Aug 2020 22:33:18 -0400
Arvind Sankar <nivedita@xxxxxxxxxxxx> wrote:

> On Fri, Feb 07, 2020 at 02:46:03PM -0500, Steven Rostedt wrote:
> >
> > diff --git a/init/main.c b/init/main.c
> > index 491f1cdb3105..113c8244e5f0 100644
> > --- a/init/main.c
> > +++ b/init/main.c
> > @@ -142,6 +142,15 @@ static char *extra_command_line;
> > /* Extra init arguments */
> > static char *extra_init_args;
> >
> > +#ifdef CONFIG_BOOT_CONFIG
> > +/* Is bootconfig on command line? */
> > +static bool bootconfig_found;
> > +static bool initargs_found;
> > +#else
> > +# define bootconfig_found false
> > +# define initargs_found false
> > +#endif
> > +
> > static char *execute_command;
> > static char *ramdisk_execute_command;
> >
> > @@ -336,17 +345,32 @@ u32 boot_config_checksum(unsigned char *p, u32 size)
> > return ret;
> > }
> >
> > +static int __init bootconfig_params(char *param, char *val,
> > + const char *unused, void *arg)
> > +{
> > + if (strcmp(param, "bootconfig") == 0) {
> > + bootconfig_found = true;
> > + } else if (strcmp(param, "--") == 0) {
> > + initargs_found = true;
> > + }
> > + return 0;
> > +}
> > +
>
> I came across this as I was poking around some of the command line
> parsing. AFAICT, initargs_found will never be set to true here, because
> parse_args handles "--" itself by immediately returning: it doesn't
> invoke the callback for it. So you'd instead have to check the return of
> parse_args("bootconfig"...) to detect the initargs_found case.

Oops, good catch!
Does this fixes the problem?