summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2010-09-21 15:54:07 +0200
committerMichael Brown2010-09-21 15:57:33 +0200
commitc4af205cf0fa73c546c7b7e236f6d9f1614508a6 (patch)
tree440b8675d4f14b002b0c0650ee0922d462e02bd4
parent[hermon] Add support for dual-protocol devices (diff)
downloadipxe-c4af205cf0fa73c546c7b7e236f6d9f1614508a6.tar.gz
ipxe-c4af205cf0fa73c546c7b7e236f6d9f1614508a6.tar.xz
ipxe-c4af205cf0fa73c546c7b7e236f6d9f1614508a6.zip
[settings] Modify "set" command to allow space separated values
Allow multiple, space separated values (such as kernel arguments, passed via DHCP) to be assigned to an identifier using the "set" command. Originally-implemented-by: Aaron Brooks <aaron@brooks1.net> Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r--src/hci/commands/nvo_cmd.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/hci/commands/nvo_cmd.c b/src/hci/commands/nvo_cmd.c
index 331c3e47..cebb8949 100644
--- a/src/hci/commands/nvo_cmd.c
+++ b/src/hci/commands/nvo_cmd.c
@@ -30,17 +30,37 @@ static int show_exec ( int argc, char **argv ) {
}
static int set_exec ( int argc, char **argv ) {
+ size_t len;
+ int i;
int rc;
- if ( argc != 3 ) {
+ if ( argc < 3 ) {
printf ( "Syntax: %s <identifier> <value>\n", argv[0] );
return 1;
}
- if ( ( rc = storef_named_setting ( argv[1], argv[2] ) ) != 0 ) {
- printf ( "Could not set \"%s\"=\"%s\": %s\n",
- argv[1], argv[2], strerror ( rc ) );
- return 1;
+ /* Determine total length of command line */
+ len = 1; /* NUL */
+ for ( i = 2 ; i < argc ; i++ )
+ len += ( 1 /* possible space */ + strlen ( argv[i] ) );
+
+ {
+ char buf[len];
+ char *ptr = buf;
+
+ /* Assemble command line */
+ buf[0] = '\0';
+ for ( i = 2 ; i < argc ; i++ ) {
+ ptr += sprintf ( ptr, "%s%s", ( buf[0] ? " " : "" ),
+ argv[i] );
+ }
+ assert ( ptr < ( buf + len ) );
+
+ if ( ( rc = storef_named_setting ( argv[1], buf ) ) != 0 ) {
+ printf ( "Could not set \"%s\"=\"%s\": %s\n",
+ argv[1], buf, strerror ( rc ) );
+ return 1;
+ }
}
return 0;