aboutsummaryrefslogtreecommitdiffstats
path: root/xen/common/kernel.c
diff options
context:
space:
mode:
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>2007-07-09 14:13:56 +0100
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>2007-07-09 14:13:56 +0100
commitc2a2f409564ec042c0c982b2de469d65c41a8037 (patch)
treef1a159a429f4b8c2e3cb7cdf62e37feb1dcfdeee /xen/common/kernel.c
parent6df628045b5dd29ca52334e683d93b38b52e3dc4 (diff)
downloadxen-c2a2f409564ec042c0c982b2de469d65c41a8037.tar.gz
xen-c2a2f409564ec042c0c982b2de469d65c41a8037.tar.bz2
xen-c2a2f409564ec042c0c982b2de469d65c41a8037.zip
Allow inversion of boolean cmdline parameters with 'no-' prefix.
Signed-off-by: Keir Fraser <keir@xensource.com>
Diffstat (limited to 'xen/common/kernel.c')
-rw-r--r--xen/common/kernel.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index f8e4f11a0e..fea3224a76 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -26,10 +26,11 @@ int tainted;
void cmdline_parse(char *cmdline)
{
- char opt[100], *optval, *q;
+ char opt[100], *optval, *optkey, *q;
const char *p = cmdline;
struct kernel_param *param;
-
+ int invbool;
+
if ( p == NULL )
return;
@@ -48,7 +49,7 @@ void cmdline_parse(char *cmdline)
break;
/* Grab the next whitespace-delimited option. */
- q = opt;
+ q = optkey = opt;
while ( (*p != ' ') && (*p != '\0') )
{
if ( (q-opt) < (sizeof(opt)-1) ) /* avoid overflow */
@@ -64,9 +65,14 @@ void cmdline_parse(char *cmdline)
else
optval = q; /* default option value is empty string */
+ /* Boolean parameters can be inverted with 'no-' prefix. */
+ invbool = !strncmp("no-", optkey, 3);
+ if ( invbool )
+ optkey += 3;
+
for ( param = &__setup_start; param <= &__setup_end; param++ )
{
- if ( strcmp(param->name, opt ) != 0 )
+ if ( strcmp(param->name, optkey) )
continue;
switch ( param->type )
@@ -79,7 +85,10 @@ void cmdline_parse(char *cmdline)
simple_strtol(optval, (const char **)&optval, 0);
break;
case OPT_BOOL:
- *(int *)param->var = 1;
+ *(int *)param->var = !invbool;
+ break;
+ case OPT_INVBOOL:
+ *(int *)param->var = invbool;
break;
case OPT_CUSTOM:
((void (*)(const char *))param->var)(optval);