Fix partition string parsing code so that it correctly handles boot strings beginning with a comma of the form

<device>,\path\to\file. This fixes all outstanding issues with PPC.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@siriusit.co.uk>


git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@795 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
Mark Cave-Ayland
2010-06-15 19:59:47 +00:00
committed by Mark Cave-Ayland
parent fd32324336
commit c6a9039103
3 changed files with 76 additions and 43 deletions

View File

@@ -62,26 +62,37 @@ macparts_open( macparts_info_t *di )
/*
Arguments that we accept:
id: [0-7]
[(id,)][filespec]
[(id)][,][filespec]
*/
if( str ) {
if ( !strlen(str) )
parnum = -1;
else {
/* If end of string, we just have a partition id */
if (str[1] == '\0') {
parstr = str;
} else {
/* If a comma, then we have a partition id plus argument */
if (str[1] == ',') {
str[1] = '\0';
parstr = str;
argstr = &str[2];
} else {
/* Otherwise we have just an argument */
argstr = str;
}
/* Detect the boot parameters */
char *ptr;
ptr = str;
/* <id>,<file> */
if (*ptr >= '0' && *ptr <= '9' && *(ptr + 1) == ',') {
parstr = ptr;
*(ptr + 1) = '\0';
argstr = ptr + 2;
}
/* <id> */
else if (*ptr >= '0' && *ptr <='9' && *(ptr + 1) == '\0') {
parstr = ptr;
}
/* ,<file> */
else if (*ptr == ',') {
argstr = ptr + 1;
}
/* <file> */
else {
argstr = str;
}
/* Convert the id to a partition number */

View File

@@ -89,26 +89,37 @@ pcparts_open( pcparts_info_t *di )
/*
Arguments that we accept:
id: [0-7]
[(id,)][filespec]
[(id)][,][filespec]
*/
if( str ) {
if ( !strlen(str) )
parnum = -1;
else {
/* If end of string, we just have a partition id */
if (str[1] == '\0') {
parstr = str;
} else {
/* If a comma, then we have a partition id plus argument */
if (str[1] == ',') {
str[1] = '\0';
parstr = str;
argstr = &str[2];
} else {
/* Otherwise we have just an argument */
argstr = str;
}
/* Detect the boot parameters */
char *ptr;
ptr = str;
/* <id>,<file> */
if (*ptr >= '0' && *ptr <= '9' && *(ptr + 1) == ',') {
parstr = ptr;
*(ptr + 1) = '\0';
argstr = ptr + 2;
}
/* <id> */
else if (*ptr >= '0' && *ptr <='9' && *(ptr + 1) == '\0') {
parstr = ptr;
}
/* ,<file> */
else if (*ptr == ',') {
argstr = ptr + 1;
}
/* <file> */
else {
argstr = str;
}
/* Convert the id to a partition number */

View File

@@ -106,26 +106,37 @@ sunparts_open( sunparts_info_t *di )
/*
Arguments that we accept:
id: [0-7] | [a-h]
[(id,)][filespec]
[(id)][,][filespec]
*/
if( str ) {
if ( !strlen(str) )
parnum = -1;
else {
/* If end of string, we just have a partition id */
if (str[1] == '\0') {
parstr = str;
} else {
/* If a comma, then we have a partition id plus argument */
if (str[1] == ',') {
str[1] = '\0';
parstr = str;
argstr = &str[2];
} else {
/* Otherwise we have just an argument */
argstr = str;
}
/* Detect the boot parameters */
char *ptr;
ptr = str;
/* <id>,<file> */
if (((*ptr >= '0' && *ptr <= '9') || (*ptr >= 'a' && *ptr <= 'a' + 8)) && *(ptr + 1) == ',') {
parstr = ptr;
*(ptr + 1) = '\0';
argstr = ptr + 2;
}
/* <id> */
else if (((*ptr >= '0' && *ptr <= '9') || (*ptr >= 'a' && *ptr <= 'a' + 8)) && *(ptr + 1) == '\0') {
parstr = ptr;
}
/* ,<file> */
else if (*ptr == ',') {
argstr = ptr + 1;
}
/* <file> */
else {
argstr = str;
}
/* Convert the id to a partition number */