mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 12:11:40 +00:00
bootconfig: Print array as multiple commands for legacy command line
Print arraied values as multiple same options for legacy kernel command line. With this rule, if the "kernel.*" and "init.*" array entries in bootconfig are printed out as multiple same options, e.g. kernel { console = "ttyS0,115200" console += "tty0" } will be correctly converted to console="ttyS0,115200" console="tty0" in the kernel command line. Link: http://lkml.kernel.org/r/158220118213.26565.8163300497009463916.stgit@devnote2 Reported-by: Borislav Petkov <bp@alien8.de> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
This commit is contained in:
parent
a24d286f36
commit
88b913718d
26
init/main.c
26
init/main.c
@ -268,7 +268,6 @@ static int __init xbc_snprint_cmdline(char *buf, size_t size,
|
||||
{
|
||||
struct xbc_node *knode, *vnode;
|
||||
char *end = buf + size;
|
||||
char c = '\"';
|
||||
const char *val;
|
||||
int ret;
|
||||
|
||||
@ -279,25 +278,20 @@ static int __init xbc_snprint_cmdline(char *buf, size_t size,
|
||||
return ret;
|
||||
|
||||
vnode = xbc_node_get_child(knode);
|
||||
ret = snprintf(buf, rest(buf, end), "%s%c", xbc_namebuf,
|
||||
vnode ? '=' : ' ');
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
buf += ret;
|
||||
if (!vnode)
|
||||
continue;
|
||||
|
||||
c = '\"';
|
||||
xbc_array_for_each_value(vnode, val) {
|
||||
ret = snprintf(buf, rest(buf, end), "%c%s", c, val);
|
||||
if (!vnode) {
|
||||
ret = snprintf(buf, rest(buf, end), "%s ", xbc_namebuf);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
buf += ret;
|
||||
continue;
|
||||
}
|
||||
xbc_array_for_each_value(vnode, val) {
|
||||
ret = snprintf(buf, rest(buf, end), "%s=\"%s\" ",
|
||||
xbc_namebuf, val);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
buf += ret;
|
||||
c = ',';
|
||||
}
|
||||
if (rest(buf, end) > 2)
|
||||
strcpy(buf, "\" ");
|
||||
buf += 2;
|
||||
}
|
||||
|
||||
return buf - (end - size);
|
||||
|
Loading…
Reference in New Issue
Block a user