Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+88 -18
+16 -8
Documentation/admin-guide/bootconfig.rst
··· 20 20 21 21 The boot config syntax is a simple structured key-value. Each key consists 22 22 of dot-connected-words, and key and value are connected by ``=``. The value 23 - has to be terminated by semi-colon (``;``) or newline (``\n``). 24 - For array value, array entries are separated by comma (``,``). :: 25 - 26 - KEY[.WORD[...]] = VALUE[, VALUE2[...]][;] 27 - 28 - Unlike the kernel command line syntax, spaces are OK around the comma and ``=``. 23 + string has to be terminated by the following delimiters described below. 29 24 30 25 Each key word must contain only alphabets, numbers, dash (``-``) or underscore 31 26 (``_``). And each value only contains printable characters or spaces except 32 27 for delimiters such as semi-colon (``;``), new-line (``\n``), comma (``,``), 33 28 hash (``#``) and closing brace (``}``). 29 + 30 + If the ``=`` is followed by whitespace up to one of these delimiters, the 31 + key is assigned an empty value. 32 + 33 + For arrays, the array values are comma (``,``) separated, and comments and 34 + line breaks with newline (``\n``) are allowed between array values for 35 + readability. Thus the first entry of the array must be on the same line as 36 + the key.:: 37 + 38 + KEY[.WORD[...]] = VALUE[, VALUE2[...]][;] 39 + 40 + Unlike the kernel command line syntax, white spaces (including tabs) are 41 + ignored around the comma and ``=``. 34 42 35 43 If you want to use those delimiters in a value, you can use either double- 36 44 quotes (``"VALUE"``) or single-quotes (``'VALUE'``) to quote it. Note that ··· 146 138 foo = value 147 139 bar = 1, 2, 3 148 140 149 - Note that you can not put a comment between value and delimiter(``,`` or 150 - ``;``). This means following config has a syntax error :: 141 + Note that you can NOT put a comment or a newline between value and delimiter 142 + (``,`` or ``;``). This means following config has a syntax error :: 151 143 152 144 key = 1 # comment 153 145 ,2
+19 -8
lib/bootconfig.c
··· 557 557 /* 558 558 * Return delimiter or error, no node added. As same as lib/cmdline.c, 559 559 * you can use " around spaces, but can't escape " for value. 560 + * *@__v must point real value string. (not including spaces before value.) 560 561 */ 561 562 static int __init __xbc_parse_value(char **__v, char **__n) 562 563 { 563 564 char *p, *v = *__v; 564 565 int c, quotes = 0; 565 566 566 - v = skip_spaces(v); 567 - while (*v == '#') { 568 - v = skip_comment(v); 569 - v = skip_spaces(v); 570 - } 571 567 if (*v == '"' || *v == '\'') { 572 568 quotes = *v; 573 569 v++; ··· 613 617 last_parent = xbc_node_get_child(last_parent); 614 618 615 619 do { 620 + /* Search the next array value beyond comments and empty lines */ 621 + next = skip_spaces(*__v); 622 + while (*next == '#') { 623 + next = skip_comment(next); 624 + next = skip_spaces(next); 625 + } 626 + *__v = next; 616 627 c = __xbc_parse_value(__v, &next); 617 628 if (c < 0) 618 629 return c; ··· 704 701 if (ret) 705 702 return ret; 706 703 707 - c = __xbc_parse_value(&v, &next); 708 - if (c < 0) 709 - return c; 704 + v = skip_spaces_until_newline(v); 705 + /* If there is a comment, this has an empty value. */ 706 + if (*v == '#') { 707 + next = skip_comment(v); 708 + *v = '\0'; 709 + c = '\n'; 710 + } else { 711 + c = __xbc_parse_value(&v, &next); 712 + if (c < 0) 713 + return c; 714 + } 710 715 711 716 child = xbc_node_get_child(last_parent); 712 717 if (child && xbc_node_is_value(child)) {
+4
tools/bootconfig/samples/bad-array-after-comment.bconf
··· 1 + # the first array value must be on the same line as the key 2 + key = # comment 3 + value1, 4 + value2
+4
tools/bootconfig/samples/bad-array-in-next-line.bconf
··· 1 + # the first array value must be on the same line as the key 2 + key = 3 + value1, 4 + value2
+1
tools/bootconfig/samples/exp-good-array-space-comment.bconf
··· 1 + key = "value1", "value2", "value3";
+1
tools/bootconfig/samples/exp-good-comment-after-value.bconf
··· 1 + key = "value";
+2
tools/bootconfig/samples/exp-good-mixed-append.bconf
··· 1 + key = "foo", "bar"; 2 + keyx.subkey = "value";
+2
tools/bootconfig/samples/exp-good-mixed-kv1.bconf
··· 1 + key = "value"; 2 + key.subkey = "another-value";
+2
tools/bootconfig/samples/exp-good-mixed-kv2.bconf
··· 1 + key = "another-value"; 2 + key.subkey = "value";
+5
tools/bootconfig/samples/exp-good-mixed-kv3.bconf
··· 1 + key = "value"; 2 + key { 3 + subkey1; 4 + subkey2 = "foo"; 5 + }
+2
tools/bootconfig/samples/exp-good-mixed-override.bconf
··· 1 + key = "value2"; 2 + key.foo = "bar";
+4
tools/bootconfig/samples/exp-good-override.bconf
··· 1 + key { 2 + word = "2", "3"; 3 + new.word = "new"; 4 + }
+2
tools/bootconfig/samples/exp-good-printables.bconf
··· 1 + key = " 2 + !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
+8
tools/bootconfig/samples/exp-good-simple.bconf
··· 1 + key { 2 + word1 = "1"; 3 + word2 = "2"; 4 + word3 = "3"; 5 + word4 = "4"; 6 + word5 = "5"; 7 + word6 = "6"; 8 + }
+3
tools/bootconfig/samples/exp-good-single.bconf
··· 1 + key = "1"; 2 + key2 = "2"; 3 + key3 = "alpha", "beta";
+1
tools/bootconfig/samples/exp-good-space-after-value.bconf
··· 1 + key = "value";
+8
tools/bootconfig/samples/exp-good-tree.bconf
··· 1 + key { 2 + word.tree.value = "0"; 3 + word2.tree.value = "1", "2"; 4 + } 5 + other.tree { 6 + value = "2"; 7 + value2 = "3"; 8 + }
+1 -2
tools/bootconfig/samples/good-array-space-comment.bconf
··· 1 - key = # comment 2 - "value1", # comment1 1 + key = "value1", # comment1 3 2 "value2" , # comment2 4 3 "value3"
+3
tools/bootconfig/test-bootconfig.sh
··· 179 179 echo "=== expected success cases ===" 180 180 for i in samples/good-* ; do 181 181 xpass $BOOTCONF -a $i $INITRD 182 + x="samples/exp-"`basename $i` 183 + $BOOTCONF $i > $TEMPCONF 184 + xpass diff $x $TEMPCONF 182 185 done 183 186 184 187