mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/
synced 2026-04-17 22:23:45 -04:00
bootconfig: Support mixing a value and subkeys under a key
Support mixing a value and subkeys under a key. Since kernel cmdline
options will support "aaa.bbb=value1 aaa.bbb.ccc=value2", it is
better that the bootconfig supports such configuration too.
Note that this does not change syntax itself but just accepts
mixed value and subkeys e.g.
key = value1
key.subkey = value2
But this is not accepted;
key {
value1
subkey = value2
}
That will make value1 as a subkey.
Also, the order of the value node under a key is fixed. If there
are a value and subkeys, the value is always the first child node
of the key. Thus if user specifies subkeys first, e.g.
key.subkey = value1
key = value2
In the program (and /proc/bootconfig), it will be shown as below
key = value2
key.subkey = value1
Link: https://lkml.kernel.org/r/162262194685.264090.7738574774030567419.stgit@devnote2
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
This commit is contained in:
committed by
Steven Rostedt (VMware)
parent
ca24306d83
commit
e5efaeb8a8
@@ -35,30 +35,55 @@ static int xbc_show_value(struct xbc_node *node, bool semicolon)
|
||||
|
||||
static void xbc_show_compact_tree(void)
|
||||
{
|
||||
struct xbc_node *node, *cnode;
|
||||
struct xbc_node *node, *cnode = NULL, *vnode;
|
||||
int depth = 0, i;
|
||||
|
||||
node = xbc_root_node();
|
||||
while (node && xbc_node_is_key(node)) {
|
||||
for (i = 0; i < depth; i++)
|
||||
printf("\t");
|
||||
cnode = xbc_node_get_child(node);
|
||||
if (!cnode)
|
||||
cnode = xbc_node_get_child(node);
|
||||
while (cnode && xbc_node_is_key(cnode) && !cnode->next) {
|
||||
vnode = xbc_node_get_child(cnode);
|
||||
/*
|
||||
* If @cnode has value and subkeys, this
|
||||
* should show it as below.
|
||||
*
|
||||
* key(@node) {
|
||||
* key(@cnode) = value;
|
||||
* key(@cnode) {
|
||||
* subkeys;
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
if (vnode && xbc_node_is_value(vnode) && vnode->next)
|
||||
break;
|
||||
printf("%s.", xbc_node_get_data(node));
|
||||
node = cnode;
|
||||
cnode = xbc_node_get_child(node);
|
||||
cnode = vnode;
|
||||
}
|
||||
if (cnode && xbc_node_is_key(cnode)) {
|
||||
printf("%s {\n", xbc_node_get_data(node));
|
||||
depth++;
|
||||
node = cnode;
|
||||
cnode = NULL;
|
||||
continue;
|
||||
} else if (cnode && xbc_node_is_value(cnode)) {
|
||||
printf("%s = ", xbc_node_get_data(node));
|
||||
xbc_show_value(cnode, true);
|
||||
/*
|
||||
* If @node has value and subkeys, continue
|
||||
* looping on subkeys with same node.
|
||||
*/
|
||||
if (cnode->next) {
|
||||
cnode = xbc_node_get_next(cnode);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
printf("%s;\n", xbc_node_get_data(node));
|
||||
}
|
||||
cnode = NULL;
|
||||
|
||||
if (node->next) {
|
||||
node = xbc_node_get_next(node);
|
||||
@@ -70,10 +95,12 @@ static void xbc_show_compact_tree(void)
|
||||
return;
|
||||
if (!xbc_node_get_child(node)->next)
|
||||
continue;
|
||||
depth--;
|
||||
for (i = 0; i < depth; i++)
|
||||
printf("\t");
|
||||
printf("}\n");
|
||||
if (depth) {
|
||||
depth--;
|
||||
for (i = 0; i < depth; i++)
|
||||
printf("\t");
|
||||
printf("}\n");
|
||||
}
|
||||
}
|
||||
node = xbc_node_get_next(node);
|
||||
}
|
||||
@@ -86,8 +113,10 @@ static void xbc_show_list(void)
|
||||
const char *val;
|
||||
|
||||
xbc_for_each_key_value(leaf, val) {
|
||||
if (xbc_node_compose_key(leaf, key, XBC_KEYLEN_MAX) < 0)
|
||||
if (xbc_node_compose_key(leaf, key, XBC_KEYLEN_MAX) < 0) {
|
||||
fprintf(stderr, "Failed to compose key %d\n", ret);
|
||||
break;
|
||||
}
|
||||
printf("%s = ", key);
|
||||
if (!val || val[0] == '\0') {
|
||||
printf("\"\"\n");
|
||||
|
||||
Reference in New Issue
Block a user