WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] Allow inversion of boolean cmdline parame

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Allow inversion of boolean cmdline parameters with 'no-' prefix.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 09 Jul 2007 09:51:52 -0700
Delivery-date: Mon, 09 Jul 2007 09:50:04 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1183986836 -3600
# Node ID 646ec1f2b41f717646d6d9f6bfd4e7ea11c9fb74
# Parent  ecb89c6ce615d1dab0036b36c0fdb5a3e1b3faf7
Allow inversion of boolean cmdline parameters with 'no-' prefix.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 xen/common/kernel.c    |   19 ++++++++++++++-----
 xen/include/xen/init.h |    6 +++++-
 2 files changed, 19 insertions(+), 6 deletions(-)

diff -r ecb89c6ce615 -r 646ec1f2b41f xen/common/kernel.c
--- a/xen/common/kernel.c       Mon Jul 09 14:06:22 2007 +0100
+++ b/xen/common/kernel.c       Mon Jul 09 14:13:56 2007 +0100
@@ -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);
diff -r ecb89c6ce615 -r 646ec1f2b41f xen/include/xen/init.h
--- a/xen/include/xen/init.h    Mon Jul 09 14:06:22 2007 +0100
+++ b/xen/include/xen/init.h    Mon Jul 09 14:13:56 2007 +0100
@@ -78,7 +78,7 @@ extern initcall_t __initcall_start, __in
  */
 struct kernel_param {
     const char *name;
-    enum { OPT_STR, OPT_UINT, OPT_BOOL, OPT_CUSTOM } type;
+    enum { OPT_STR, OPT_UINT, OPT_BOOL, OPT_INVBOOL, OPT_CUSTOM } type;
     void *var;
     unsigned int len;
 };
@@ -93,6 +93,10 @@ extern struct kernel_param __setup_start
     static char __setup_str_##_var[] __initdata = _name; \
     static struct kernel_param __setup_##_var __attribute_used__ \
         __initsetup = { __setup_str_##_var, OPT_BOOL, &_var, sizeof(_var) }
+#define invboolean_param(_name, _var) \
+    static char __setup_str_##_var[] __initdata = _name; \
+    static struct kernel_param __setup_##_var __attribute_used__ \
+        __initsetup = { __setup_str_##_var, OPT_INVBOOL, &_var, sizeof(_var) }
 #define integer_param(_name, _var) \
     static char __setup_str_##_var[] __initdata = _name; \
     static struct kernel_param __setup_##_var __attribute_used__ \

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] Allow inversion of boolean cmdline parameters with 'no-' prefix., Xen patchbot-unstable <=