Fix command-line parsing in a few respects -- be more

generous about what we accept, avoid stack overflow, and
print the command line during boot (rather useful!).

This should fix the 'lapic' and 'nolapic' boot options.

Signed-off-by: Keir Fraser <keir@xensource.com>
This commit is contained in:
kaf24@firebug.cl.cam.ac.uk committed 2006-04-21 18:09:32 +01:00
1 parent a3fd8815ef
commit b07b5dcc56
2 files changed
+18 -14

No files matched your search

+5 -2
View File
@@ -194,7 +194,7 @@ static void percpu_free_unused_areas(void)
void __init __start_xen(multiboot_info_t *mbi)
{
char *cmdline;
char __cmdline[] = "", *cmdline = __cmdline;
struct domain *idle_domain;
unsigned long _initrd_start = 0, _initrd_len = 0;
unsigned int initrdidx = 1;
@@ -210,7 +210,8 @@ void __init __start_xen(multiboot_info_t *mbi)
/* Parse the command-line options. */
if ( (mbi->flags & MBI_CMDLINE) && (mbi->cmdline != 0) )
cmdline_parse(__va(mbi->cmdline));
cmdline = __va(mbi->cmdline);
cmdline_parse(cmdline);
set_current((struct vcpu *)0xfffff000); /* debug sanity */
set_processor_id(0); /* needed early, for smp_processor_id() */
@@ -228,6 +229,8 @@ void __init __start_xen(multiboot_info_t *mbi)
init_console();
printf("Command line: %s\n", cmdline);
/* Check that we have at least one Multiboot module. */
if ( !(mbi->flags & MBI_MODULES) || (mbi->mods_count == 0) )
{
+13 -12
View File
@@ -43,13 +43,19 @@ void cmdline_parse(char *cmdline)
/* Grab the next whitespace-delimited option. */
q = opt;
while ( (*p != ' ') && (*p != '\0') )
*q++ = *p++;
{
if ( (q-opt) < (sizeof(opt)-1) ) /* avoid overflow */
*q++ = *p;
p++;
}
*q = '\0';
/* Search for value part of a key=value option. */
optval = strchr(opt, '=');
if ( optval != NULL )
*optval++ = '\0';
*optval++ = '\0'; /* nul-terminate the option value */
else
optval = q; /* default option value is empty string */
for ( param = &__setup_start; param <= &__setup_end; param++ )
{
@@ -59,23 +65,18 @@ void cmdline_parse(char *cmdline)
switch ( param->type )
{
case OPT_STR:
if ( optval != NULL )
{
strncpy(param->var, optval, param->len);
((char *)param->var)[param->len-1] = '\0';
}
strncpy(param->var, optval, param->len);
((char *)param->var)[param->len-1] = '\0';
break;
case OPT_UINT:
if ( optval != NULL )
*(unsigned int *)param->var =
simple_strtol(optval, (char **)&optval, 0);
*(unsigned int *)param->var =
simple_strtol(optval, (char **)&optval, 0);
break;
case OPT_BOOL:
*(int *)param->var = 1;
break;
case OPT_CUSTOM:
if ( optval != NULL )
((void (*)(char *))param->var)(optval);
((void (*)(char *))param->var)(optval);
break;
}
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.