mirror of
https://github.com/torvalds/linux.git
synced 2026-06-03 12:03:54 +02:00
Bootconfig for v7.0
- Update the bootconfig parser to stop searching for a value when it encounters a newline character. Note that this changes the bootconfig formatting but this should not fall under the don't break user space rule as users of bootconfig is for booting the kernel and not about applications running in the kernel's user space. - Update the tests for bootconfig parser to ensure the good examples to be parsed correctly by comparing the expected results. -----BEGIN PGP SIGNATURE----- iQFPBAABCgA5FiEEh7BulGwFlgAOi5DV2/sHvwUrPxsFAmmPs+sbHG1hc2FtaS5o aXJhbWF0c3VAZ21haWwuY29tAAoJENv7B78FKz8bG60H/1GuYXlEbJrfM2G1moC5 c9HLkNON7xspEDWfT8lHk+T+4l7xj/Oriwl9Kkv/0F/P7NzIYZaSiHoht0TqrL6c /BR3pgHVayp4H/woaDZdo9KDCMFuxW0ukrbUriz/taMJn4+b7krScGoIM4sl1e02 cQVYbJxP9x5oEhgrQEOBUHnYSaEcB7qBclIUCQOl3UV9krTZpKOsLe3tNjcj0JrZ ACmSvP4oGKNIz+IarNmlV0m5enJk/pZLIpovbbrfm1vV4lxDWTCbSF2Q/dmpY43k ZIhjgjSES5bS5PSl7aQJW7j2itCUHDu7kYz+i8ifjqMnEcJkE9PqqsdJAhq1J63i M6w= =t5PQ -----END PGP SIGNATURE----- Merge tag 'bootconfig-v7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace Pull bootconfig updates from Masami Hiramatsu: - Update the bootconfig parser to stop searching for a value when it encounters a newline character - Update the tests for bootconfig parser to ensure the good examples to be parsed correctly by comparing the expected results * tag 'bootconfig-v7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: bootconfig: Check the parsed output of the good examples bootconfig: Terminate value search if it hits a newline
This commit is contained in:
commit
770aaedb46
|
|
@ -20,18 +20,26 @@ Config File Syntax
|
|||
|
||||
The boot config syntax is a simple structured key-value. Each key consists
|
||||
of dot-connected-words, and key and value are connected by ``=``. The value
|
||||
has to be terminated by semi-colon (``;``) or newline (``\n``).
|
||||
For array value, array entries are separated by comma (``,``). ::
|
||||
|
||||
KEY[.WORD[...]] = VALUE[, VALUE2[...]][;]
|
||||
|
||||
Unlike the kernel command line syntax, spaces are OK around the comma and ``=``.
|
||||
string has to be terminated by the following delimiters described below.
|
||||
|
||||
Each key word must contain only alphabets, numbers, dash (``-``) or underscore
|
||||
(``_``). And each value only contains printable characters or spaces except
|
||||
for delimiters such as semi-colon (``;``), new-line (``\n``), comma (``,``),
|
||||
hash (``#``) and closing brace (``}``).
|
||||
|
||||
If the ``=`` is followed by whitespace up to one of these delimiters, the
|
||||
key is assigned an empty value.
|
||||
|
||||
For arrays, the array values are comma (``,``) separated, and comments and
|
||||
line breaks with newline (``\n``) are allowed between array values for
|
||||
readability. Thus the first entry of the array must be on the same line as
|
||||
the key.::
|
||||
|
||||
KEY[.WORD[...]] = VALUE[, VALUE2[...]][;]
|
||||
|
||||
Unlike the kernel command line syntax, white spaces (including tabs) are
|
||||
ignored around the comma and ``=``.
|
||||
|
||||
If you want to use those delimiters in a value, you can use either double-
|
||||
quotes (``"VALUE"``) or single-quotes (``'VALUE'``) to quote it. Note that
|
||||
you can not escape these quotes.
|
||||
|
|
@ -138,8 +146,8 @@ This is parsed as below::
|
|||
foo = value
|
||||
bar = 1, 2, 3
|
||||
|
||||
Note that you can not put a comment between value and delimiter(``,`` or
|
||||
``;``). This means following config has a syntax error ::
|
||||
Note that you can NOT put a comment or a newline between value and delimiter
|
||||
(``,`` or ``;``). This means following config has a syntax error ::
|
||||
|
||||
key = 1 # comment
|
||||
,2
|
||||
|
|
|
|||
|
|
@ -557,17 +557,13 @@ static int __init __xbc_close_brace(char *p)
|
|||
/*
|
||||
* Return delimiter or error, no node added. As same as lib/cmdline.c,
|
||||
* you can use " around spaces, but can't escape " for value.
|
||||
* *@__v must point real value string. (not including spaces before value.)
|
||||
*/
|
||||
static int __init __xbc_parse_value(char **__v, char **__n)
|
||||
{
|
||||
char *p, *v = *__v;
|
||||
int c, quotes = 0;
|
||||
|
||||
v = skip_spaces(v);
|
||||
while (*v == '#') {
|
||||
v = skip_comment(v);
|
||||
v = skip_spaces(v);
|
||||
}
|
||||
if (*v == '"' || *v == '\'') {
|
||||
quotes = *v;
|
||||
v++;
|
||||
|
|
@ -617,6 +613,13 @@ static int __init xbc_parse_array(char **__v)
|
|||
last_parent = xbc_node_get_child(last_parent);
|
||||
|
||||
do {
|
||||
/* Search the next array value beyond comments and empty lines */
|
||||
next = skip_spaces(*__v);
|
||||
while (*next == '#') {
|
||||
next = skip_comment(next);
|
||||
next = skip_spaces(next);
|
||||
}
|
||||
*__v = next;
|
||||
c = __xbc_parse_value(__v, &next);
|
||||
if (c < 0)
|
||||
return c;
|
||||
|
|
@ -701,9 +704,17 @@ static int __init xbc_parse_kv(char **k, char *v, int op)
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
c = __xbc_parse_value(&v, &next);
|
||||
if (c < 0)
|
||||
return c;
|
||||
v = skip_spaces_until_newline(v);
|
||||
/* If there is a comment, this has an empty value. */
|
||||
if (*v == '#') {
|
||||
next = skip_comment(v);
|
||||
*v = '\0';
|
||||
c = '\n';
|
||||
} else {
|
||||
c = __xbc_parse_value(&v, &next);
|
||||
if (c < 0)
|
||||
return c;
|
||||
}
|
||||
|
||||
child = xbc_node_get_child(last_parent);
|
||||
if (child && xbc_node_is_value(child)) {
|
||||
|
|
|
|||
4
tools/bootconfig/samples/bad-array-after-comment.bconf
Normal file
4
tools/bootconfig/samples/bad-array-after-comment.bconf
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# the first array value must be on the same line as the key
|
||||
key = # comment
|
||||
value1,
|
||||
value2
|
||||
4
tools/bootconfig/samples/bad-array-in-next-line.bconf
Normal file
4
tools/bootconfig/samples/bad-array-in-next-line.bconf
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# the first array value must be on the same line as the key
|
||||
key =
|
||||
value1,
|
||||
value2
|
||||
|
|
@ -0,0 +1 @@
|
|||
key = "value1", "value2", "value3";
|
||||
|
|
@ -0,0 +1 @@
|
|||
key = "value";
|
||||
2
tools/bootconfig/samples/exp-good-mixed-append.bconf
Normal file
2
tools/bootconfig/samples/exp-good-mixed-append.bconf
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
key = "foo", "bar";
|
||||
keyx.subkey = "value";
|
||||
2
tools/bootconfig/samples/exp-good-mixed-kv1.bconf
Normal file
2
tools/bootconfig/samples/exp-good-mixed-kv1.bconf
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
key = "value";
|
||||
key.subkey = "another-value";
|
||||
2
tools/bootconfig/samples/exp-good-mixed-kv2.bconf
Normal file
2
tools/bootconfig/samples/exp-good-mixed-kv2.bconf
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
key = "another-value";
|
||||
key.subkey = "value";
|
||||
5
tools/bootconfig/samples/exp-good-mixed-kv3.bconf
Normal file
5
tools/bootconfig/samples/exp-good-mixed-kv3.bconf
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
key = "value";
|
||||
key {
|
||||
subkey1;
|
||||
subkey2 = "foo";
|
||||
}
|
||||
2
tools/bootconfig/samples/exp-good-mixed-override.bconf
Normal file
2
tools/bootconfig/samples/exp-good-mixed-override.bconf
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
key = "value2";
|
||||
key.foo = "bar";
|
||||
4
tools/bootconfig/samples/exp-good-override.bconf
Normal file
4
tools/bootconfig/samples/exp-good-override.bconf
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
key {
|
||||
word = "2", "3";
|
||||
new.word = "new";
|
||||
}
|
||||
2
tools/bootconfig/samples/exp-good-printables.bconf
Normal file
2
tools/bootconfig/samples/exp-good-printables.bconf
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
key = "
|
||||
!#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
|
||||
8
tools/bootconfig/samples/exp-good-simple.bconf
Normal file
8
tools/bootconfig/samples/exp-good-simple.bconf
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
key {
|
||||
word1 = "1";
|
||||
word2 = "2";
|
||||
word3 = "3";
|
||||
word4 = "4";
|
||||
word5 = "5";
|
||||
word6 = "6";
|
||||
}
|
||||
3
tools/bootconfig/samples/exp-good-single.bconf
Normal file
3
tools/bootconfig/samples/exp-good-single.bconf
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
key = "1";
|
||||
key2 = "2";
|
||||
key3 = "alpha", "beta";
|
||||
|
|
@ -0,0 +1 @@
|
|||
key = "value";
|
||||
8
tools/bootconfig/samples/exp-good-tree.bconf
Normal file
8
tools/bootconfig/samples/exp-good-tree.bconf
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
key {
|
||||
word.tree.value = "0";
|
||||
word2.tree.value = "1", "2";
|
||||
}
|
||||
other.tree {
|
||||
value = "2";
|
||||
value2 = "3";
|
||||
}
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
key = # comment
|
||||
"value1", # comment1
|
||||
key = "value1", # comment1
|
||||
"value2" , # comment2
|
||||
"value3"
|
||||
|
|
|
|||
|
|
@ -179,6 +179,9 @@ done
|
|||
echo "=== expected success cases ==="
|
||||
for i in samples/good-* ; do
|
||||
xpass $BOOTCONF -a $i $INITRD
|
||||
x="samples/exp-"`basename $i`
|
||||
$BOOTCONF $i > $TEMPCONF
|
||||
xpass diff $x $TEMPCONF
|
||||
done
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user