mirror of
https://gitlab.com/qemu-project/openbios.git
synced 2024-02-13 08:34:06 +08:00
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:
committed by
Mark Cave-Ayland
parent
fd32324336
commit
c6a9039103
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
@@ -134,7 +145,7 @@ sunparts_open( sunparts_info_t *di )
|
||||
parnum = parstr[0] - 'a';
|
||||
else
|
||||
parnum = atol(parstr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user