Messages in this thread Patch in this message | | | From | Joe Perches <> | Subject | [RFC PATCH 2/2] init: Allow multi-line output of kernel command line | Date | Tue, 19 May 2020 12:42:35 -0700 |
| |
ARM may have its longest possible command line larger than the longest possible printk.
If necessary, emit the commend line on multiple lines.
Signed-off-by: Joe Perches <joe@perches.com> ---
compiled, untested
init/main.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/init/main.c b/init/main.c index b63a3c001ac4..b3ebbbc129ae 100644 --- a/init/main.c +++ b/init/main.c @@ -826,6 +826,34 @@ void __init __weak arch_call_rest_init(void) rest_init(); } +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) { + 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 +} + asmlinkage __visible void __init start_kernel(void) { char *command_line; @@ -859,7 +887,8 @@ asmlinkage __visible void __init start_kernel(void) build_all_zonelists(NULL); page_alloc_init(); - pr_notice("Kernel command line: %s\n", saved_command_line); + print_cmdline(saved_command_line); + /* parameters may set static keys */ jump_label_init(); parse_early_param(); -- 2.25.1
| |