Commit 4e4694d8 authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Steven Rostedt (VMware)

bootconfig: Prohibit re-defining value on same key

Currently, bootconfig adds a new value on the existing key to the tail of an
array. But this looks a bit confusing because an admin can easily rewrite
the original value in the same config file.

This rejects the following value re-definition.

  key = value1
  ...
  key = value2

You should rewrite value1 to value2 in this case.

Link: http://lkml.kernel.org/r/158227282199.12842.10110929876059658601.stgit@devnote2Suggested-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
[ Fixed spelling of arraies to arrays ]
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent 88b91371
...@@ -62,7 +62,16 @@ Or more shorter, written as following:: ...@@ -62,7 +62,16 @@ Or more shorter, written as following::
In both styles, same key words are automatically merged when parsing it In both styles, same key words are automatically merged when parsing it
at boot time. So you can append similar trees or key-values. at boot time. So you can append similar trees or key-values.
Note that a sub-key and a value can not co-exist under a parent key. Same-key Values
---------------
It is prohibited that two or more values or arrays share a same-key.
For example,::
foo = bar, baz
foo = qux # !ERROR! we can not re-define same key
Also, a sub-key and a value can not co-exist under a parent key.
For example, following config is NOT allowed.:: For example, following config is NOT allowed.::
foo = value1 foo = value1
......
...@@ -581,7 +581,7 @@ static int __init __xbc_parse_keys(char *k) ...@@ -581,7 +581,7 @@ static int __init __xbc_parse_keys(char *k)
static int __init xbc_parse_kv(char **k, char *v) static int __init xbc_parse_kv(char **k, char *v)
{ {
struct xbc_node *prev_parent = last_parent; struct xbc_node *prev_parent = last_parent;
struct xbc_node *node, *child; struct xbc_node *child;
char *next; char *next;
int c, ret; int c, ret;
...@@ -590,15 +590,18 @@ static int __init xbc_parse_kv(char **k, char *v) ...@@ -590,15 +590,18 @@ static int __init xbc_parse_kv(char **k, char *v)
return ret; return ret;
child = xbc_node_get_child(last_parent); child = xbc_node_get_child(last_parent);
if (child && xbc_node_is_key(child)) if (child) {
if (xbc_node_is_key(child))
return xbc_parse_error("Value is mixed with subkey", v); return xbc_parse_error("Value is mixed with subkey", v);
else
return xbc_parse_error("Value is redefined", v);
}
c = __xbc_parse_value(&v, &next); c = __xbc_parse_value(&v, &next);
if (c < 0) if (c < 0)
return c; return c;
node = xbc_add_sibling(v, XBC_VALUE); if (!xbc_add_sibling(v, XBC_VALUE))
if (!node)
return -ENOMEM; return -ENOMEM;
if (c == ',') { /* Array */ if (c == ',') { /* Array */
......
# Same key value is not allowed
key {
foo = value
bar = value2
}
key.foo = value
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment