File tree Expand file tree Collapse file tree
Documentation/admin-guide Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -71,7 +71,15 @@ For example,::
7171 foo = bar, baz
7272 foo = qux # !ERROR! we can not re-define same key
7373
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.
7583For example, following config is NOT allowed.::
7684
7785 foo = value1
Original file line number Diff line number Diff line change @@ -578,7 +578,7 @@ static int __init __xbc_parse_keys(char *k)
578578 return __xbc_add_key (k );
579579}
580580
581- static int __init xbc_parse_kv (char * * k , char * v )
581+ static int __init xbc_parse_kv (char * * k , char * v , int op )
582582{
583583 struct xbc_node * prev_parent = last_parent ;
584584 struct xbc_node * child ;
@@ -593,7 +593,7 @@ static int __init xbc_parse_kv(char **k, char *v)
593593 if (child ) {
594594 if (xbc_node_is_key (child ))
595595 return xbc_parse_error ("Value is mixed with subkey" , v );
596- else
596+ else if ( op == '=' )
597597 return xbc_parse_error ("Value is redefined" , v );
598598 }
599599
@@ -774,7 +774,7 @@ int __init xbc_init(char *buf)
774774
775775 p = buf ;
776776 do {
777- q = strpbrk (p , "{}=;\n#" );
777+ q = strpbrk (p , "{}=+ ;\n#" );
778778 if (!q ) {
779779 p = skip_spaces (p );
780780 if (* p != '\0' )
@@ -785,8 +785,15 @@ int __init xbc_init(char *buf)
785785 c = * q ;
786786 * q ++ = '\0' ;
787787 switch (c ) {
788+ case '+' :
789+ if (* q ++ != '=' ) {
790+ ret = xbc_parse_error ("Wrong '+' operator" ,
791+ q - 2 );
792+ break ;
793+ }
794+ /* Fall through */
788795 case '=' :
789- ret = xbc_parse_kv (& p , q );
796+ ret = xbc_parse_kv (& p , q , c );
790797 break ;
791798 case '{' :
792799 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`
99NG=0
1010
1111cleanup () {
12- rm -f $INITRD $TEMPCONF
12+ rm -f $INITRD $TEMPCONF $OUTFILE
1313 exit $NG
1414}
1515
@@ -71,7 +71,6 @@ printf " \0\0\0 \0\0\0" >> $INITRD
7171$BOOTCONF -a $TEMPCONF $INITRD > $OUTFILE 2>&1
7272xfail grep -i " failed" $OUTFILE
7373xfail grep -i " error" $OUTFILE
74- rm $OUTFILE
7574
7675echo " Max node number check"
7776
@@ -96,6 +95,19 @@ truncate -s 32764 $TEMPCONF
9695echo " \" " >> $TEMPCONF # add 2 bytes + terminal ('\"\n\0')
9796xpass $BOOTCONF -a $TEMPCONF $INITRD
9897
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+
99111echo " === expected failure cases ==="
100112for i in samples/bad-* ; do
101113 xfail $BOOTCONF -a $i $INITRD
You can’t perform that action at this time.
0 commit comments