LKML Archive on lore.kernel.org help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org> To: Steven Rostedt <rostedt@goodmis.org> Cc: Masami Hiramatsu <mhiramat@kernel.org>, LKML <linux-kernel@vger.kernel.org> Subject: [PATCH 2/3] init/bootconfig: Reorder init parameter from bootconfig and cmdline Date: Thu, 26 Aug 2021 18:12:14 +0900 [thread overview] Message-ID: <162996913426.236535.9040577893259840567.stgit@devnote2> (raw) In-Reply-To: <162996911932.236535.7533708592332223449.stgit@devnote2> Reorder the init parameters from bootconfig and kernel cmdline so that the kernel cmdline always be the last part of the parameters as below. " -- "[bootconfig init params][cmdline init params] This change will help us to prevent that bootconfig init params overwrite the init params which user gives in the command line. Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> --- init/main.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/init/main.c b/init/main.c index d9b0a99bb2dd..b24a18aebed7 100644 --- a/init/main.c +++ b/init/main.c @@ -153,10 +153,10 @@ static char *extra_init_args; #ifdef CONFIG_BOOT_CONFIG /* Is bootconfig on command line? */ static bool bootconfig_found; -static bool initargs_found; +static size_t initargs_offs; #else # define bootconfig_found false -# define initargs_found false +# define initargs_offs 0 #endif static char *execute_command; @@ -422,9 +422,9 @@ static void __init setup_boot_config(void) if (IS_ERR(err) || !bootconfig_found) return; - /* parse_args() stops at '--' and returns an address */ + /* parse_args() stops at the next param of '--' and returns an address */ if (err) - initargs_found = true; + initargs_offs = err - tmp_cmdline; if (!data) { pr_err("'bootconfig' found on command line, but no bootconfig found\n"); @@ -646,16 +646,21 @@ static void __init setup_command_line(char *command_line) * Append supplemental init boot args to saved_command_line * so that user can check what command line options passed * to init. + * The order should always be + * " -- "[bootconfig init-param][cmdline init-param] */ - len = strlen(saved_command_line); - if (initargs_found) { - saved_command_line[len++] = ' '; + if (initargs_offs) { + len = xlen + initargs_offs; + strcpy(saved_command_line + len, extra_init_args); + len += ilen - 4; /* strlen(extra_init_args) */ + strcpy(saved_command_line + len, + boot_command_line + initargs_offs - 1); } else { + len = strlen(saved_command_line); strcpy(saved_command_line + len, " -- "); len += 4; + strcpy(saved_command_line + len, extra_init_args); } - - strcpy(saved_command_line + len, extra_init_args); } }
next prev parent reply other threads:[~2021-08-26 9:12 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-08-26 9:11 [PATCH 0/3] bootconfig: Cleanup and reorder the init parameter from bootconfig Masami Hiramatsu 2021-08-26 9:12 ` [PATCH 1/3] init: bootconfig: Remove all bootconfig data when the init memory is removed Masami Hiramatsu 2021-08-26 14:04 ` kernel test robot 2021-08-26 14:04 ` kernel test robot 2021-08-26 14:27 ` Masami Hiramatsu 2021-08-26 9:12 ` Masami Hiramatsu [this message] 2021-08-26 9:12 ` [PATCH 3/3] docs: bootconfig: Add how to use bootconfig for kernel parameters Masami Hiramatsu
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=162996913426.236535.9040577893259840567.stgit@devnote2 \ --to=mhiramat@kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=rostedt@goodmis.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).