direct-io.hg

changeset 15509:646ec1f2b41f

Allow inversion of boolean cmdline parameters with 'no-' prefix.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Mon Jul 09 14:13:56 2007 +0100 (2007-07-09)
parents ecb89c6ce615
children 5e8eb0cf2daf
files xen/common/kernel.c xen/include/xen/init.h
line diff
     1.1 --- a/xen/common/kernel.c	Mon Jul 09 14:06:22 2007 +0100
     1.2 +++ b/xen/common/kernel.c	Mon Jul 09 14:13:56 2007 +0100
     1.3 @@ -26,10 +26,11 @@ int tainted;
     1.4  
     1.5  void cmdline_parse(char *cmdline)
     1.6  {
     1.7 -    char opt[100], *optval, *q;
     1.8 +    char opt[100], *optval, *optkey, *q;
     1.9      const char *p = cmdline;
    1.10      struct kernel_param *param;
    1.11 -    
    1.12 +    int invbool;
    1.13 +
    1.14      if ( p == NULL )
    1.15          return;
    1.16  
    1.17 @@ -48,7 +49,7 @@ void cmdline_parse(char *cmdline)
    1.18              break;
    1.19  
    1.20          /* Grab the next whitespace-delimited option. */
    1.21 -        q = opt;
    1.22 +        q = optkey = opt;
    1.23          while ( (*p != ' ') && (*p != '\0') )
    1.24          {
    1.25              if ( (q-opt) < (sizeof(opt)-1) ) /* avoid overflow */
    1.26 @@ -64,9 +65,14 @@ void cmdline_parse(char *cmdline)
    1.27          else
    1.28              optval = q;       /* default option value is empty string */
    1.29  
    1.30 +        /* Boolean parameters can be inverted with 'no-' prefix. */
    1.31 +        invbool = !strncmp("no-", optkey, 3);
    1.32 +        if ( invbool )
    1.33 +            optkey += 3;
    1.34 +
    1.35          for ( param = &__setup_start; param <= &__setup_end; param++ )
    1.36          {
    1.37 -            if ( strcmp(param->name, opt ) != 0 )
    1.38 +            if ( strcmp(param->name, optkey) )
    1.39                  continue;
    1.40  
    1.41              switch ( param->type )
    1.42 @@ -79,7 +85,10 @@ void cmdline_parse(char *cmdline)
    1.43                      simple_strtol(optval, (const char **)&optval, 0);
    1.44                  break;
    1.45              case OPT_BOOL:
    1.46 -                *(int *)param->var = 1;
    1.47 +                *(int *)param->var = !invbool;
    1.48 +                break;
    1.49 +            case OPT_INVBOOL:
    1.50 +                *(int *)param->var = invbool;
    1.51                  break;
    1.52              case OPT_CUSTOM:
    1.53                  ((void (*)(const char *))param->var)(optval);
     2.1 --- a/xen/include/xen/init.h	Mon Jul 09 14:06:22 2007 +0100
     2.2 +++ b/xen/include/xen/init.h	Mon Jul 09 14:13:56 2007 +0100
     2.3 @@ -78,7 +78,7 @@ extern initcall_t __initcall_start, __in
     2.4   */
     2.5  struct kernel_param {
     2.6      const char *name;
     2.7 -    enum { OPT_STR, OPT_UINT, OPT_BOOL, OPT_CUSTOM } type;
     2.8 +    enum { OPT_STR, OPT_UINT, OPT_BOOL, OPT_INVBOOL, OPT_CUSTOM } type;
     2.9      void *var;
    2.10      unsigned int len;
    2.11  };
    2.12 @@ -93,6 +93,10 @@ extern struct kernel_param __setup_start
    2.13      static char __setup_str_##_var[] __initdata = _name; \
    2.14      static struct kernel_param __setup_##_var __attribute_used__ \
    2.15          __initsetup = { __setup_str_##_var, OPT_BOOL, &_var, sizeof(_var) }
    2.16 +#define invboolean_param(_name, _var) \
    2.17 +    static char __setup_str_##_var[] __initdata = _name; \
    2.18 +    static struct kernel_param __setup_##_var __attribute_used__ \
    2.19 +        __initsetup = { __setup_str_##_var, OPT_INVBOOL, &_var, sizeof(_var) }
    2.20  #define integer_param(_name, _var) \
    2.21      static char __setup_str_##_var[] __initdata = _name; \
    2.22      static struct kernel_param __setup_##_var __attribute_used__ \