File tree Expand file tree Collapse file tree 3 files changed +34
-7
lines changed
Documentation/admin-guide Expand file tree Collapse file tree 3 files changed +34
-7
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,15 @@ For example,::
71
71
foo = bar, baz
72
72
foo = qux # !ERROR! we can not re-define same key
73
73
74
- Also, a sub-key and a value can not co-exist under a parent key.
74
+ If you want to append the value to existing key as an array member,
75
+ you can use ``+= `` operator. For example::
76
+
77
+ foo = bar, baz
78
+ foo += qux
79
+
80
+ In this case, the key ``foo `` has ``bar ``, ``baz `` and ``qux ``.
81
+
82
+ However, a sub-key and a value can not co-exist under a parent key.
75
83
For example, following config is NOT allowed.::
76
84
77
85
foo = value1
Original file line number Diff line number Diff line change @@ -578,7 +578,7 @@ static int __init __xbc_parse_keys(char *k)
578
578
return __xbc_add_key (k );
579
579
}
580
580
581
- static int __init xbc_parse_kv (char * * k , char * v )
581
+ static int __init xbc_parse_kv (char * * k , char * v , int op )
582
582
{
583
583
struct xbc_node * prev_parent = last_parent ;
584
584
struct xbc_node * child ;
@@ -593,7 +593,7 @@ static int __init xbc_parse_kv(char **k, char *v)
593
593
if (child ) {
594
594
if (xbc_node_is_key (child ))
595
595
return xbc_parse_error ("Value is mixed with subkey" , v );
596
- else
596
+ else if ( op == '=' )
597
597
return xbc_parse_error ("Value is redefined" , v );
598
598
}
599
599
@@ -774,7 +774,7 @@ int __init xbc_init(char *buf)
774
774
775
775
p = buf ;
776
776
do {
777
- q = strpbrk (p , "{}=;\n#" );
777
+ q = strpbrk (p , "{}=+ ;\n#" );
778
778
if (!q ) {
779
779
p = skip_spaces (p );
780
780
if (* p != '\0' )
@@ -785,8 +785,15 @@ int __init xbc_init(char *buf)
785
785
c = * q ;
786
786
* q ++ = '\0' ;
787
787
switch (c ) {
788
+ case '+' :
789
+ if (* q ++ != '=' ) {
790
+ ret = xbc_parse_error ("Wrong '+' operator" ,
791
+ q - 2 );
792
+ break ;
793
+ }
794
+ /* Fall through */
788
795
case '=' :
789
- ret = xbc_parse_kv (& p , q );
796
+ ret = xbc_parse_kv (& p , q , c );
790
797
break ;
791
798
case '{' :
792
799
ret = xbc_open_brace (& p , q );
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ TEMPCONF=`mktemp temp-XXXX.bconf`
9
9
NG=0
10
10
11
11
cleanup () {
12
- rm -f $INITRD $TEMPCONF
12
+ rm -f $INITRD $TEMPCONF $OUTFILE
13
13
exit $NG
14
14
}
15
15
@@ -71,7 +71,6 @@ printf " \0\0\0 \0\0\0" >> $INITRD
71
71
$BOOTCONF -a $TEMPCONF $INITRD > $OUTFILE 2>&1
72
72
xfail grep -i " failed" $OUTFILE
73
73
xfail grep -i " error" $OUTFILE
74
- rm $OUTFILE
75
74
76
75
echo " Max node number check"
77
76
@@ -96,6 +95,19 @@ truncate -s 32764 $TEMPCONF
96
95
echo " \" " >> $TEMPCONF # add 2 bytes + terminal ('\"\n\0')
97
96
xpass $BOOTCONF -a $TEMPCONF $INITRD
98
97
98
+ echo " Adding same-key values"
99
+ cat > $TEMPCONF << EOF
100
+ key = bar, baz
101
+ key += qux
102
+ EOF
103
+ echo > $INITRD
104
+
105
+ xpass $BOOTCONF -a $TEMPCONF $INITRD
106
+ $BOOTCONF $INITRD > $OUTFILE
107
+ xpass grep -q " bar" $OUTFILE
108
+ xpass grep -q " baz" $OUTFILE
109
+ xpass grep -q " qux" $OUTFILE
110
+
99
111
echo " === expected failure cases ==="
100
112
for i in samples/bad-* ; do
101
113
xfail $BOOTCONF -a $i $INITRD
You can’t perform that action at this time.
0 commit comments