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
@@ -80,6 +80,8 @@ static inline __init bool xbc_node_is_array(struct xbc_node *node)
|
||||
*
|
||||
* Test the @node is a leaf key node which is a key node and has a value node
|
||||
* or no child. Returns true if it is a leaf node, or false if not.
|
||||
* Note that the leaf node can have subkey nodes in addition to the
|
||||
* value node.
|
||||
*/
|
||||
static inline __init bool xbc_node_is_leaf(struct xbc_node *node)
|
||||
{
|
||||
@@ -129,6 +131,23 @@ static inline struct xbc_node * __init xbc_find_node(const char *key)
|
||||
return xbc_node_find_child(NULL, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* xbc_node_get_subkey() - Return the first subkey node if exists
|
||||
* @node: Parent node
|
||||
*
|
||||
* Return the first subkey node of the @node. If the @node has no child
|
||||
* or only value node, this will return NULL.
|
||||
*/
|
||||
static inline struct xbc_node * __init xbc_node_get_subkey(struct xbc_node *node)
|
||||
{
|
||||
struct xbc_node *child = xbc_node_get_child(node);
|
||||
|
||||
if (child && xbc_node_is_value(child))
|
||||
return xbc_node_get_next(child);
|
||||
else
|
||||
return child;
|
||||
}
|
||||
|
||||
/**
|
||||
* xbc_array_for_each_value() - Iterate value nodes on an array
|
||||
* @anode: An XBC arraied value node
|
||||
@@ -149,11 +168,24 @@ static inline struct xbc_node * __init xbc_find_node(const char *key)
|
||||
* @child: Iterated XBC node.
|
||||
*
|
||||
* Iterate child nodes of @parent. Each child nodes are stored to @child.
|
||||
* The @child can be mixture of a value node and subkey nodes.
|
||||
*/
|
||||
#define xbc_node_for_each_child(parent, child) \
|
||||
for (child = xbc_node_get_child(parent); child != NULL ; \
|
||||
child = xbc_node_get_next(child))
|
||||
|
||||
/**
|
||||
* xbc_node_for_each_subkey() - Iterate child subkey nodes
|
||||
* @parent: An XBC node.
|
||||
* @child: Iterated XBC node.
|
||||
*
|
||||
* Iterate subkey nodes of @parent. Each child nodes are stored to @child.
|
||||
* The @child is only the subkey node.
|
||||
*/
|
||||
#define xbc_node_for_each_subkey(parent, child) \
|
||||
for (child = xbc_node_get_subkey(parent); child != NULL ; \
|
||||
child = xbc_node_get_next(child))
|
||||
|
||||
/**
|
||||
* xbc_node_for_each_array_value() - Iterate array entries of geven key
|
||||
* @node: An XBC node.
|
||||
|
||||
Reference in New Issue
Block a user