j
: Next unread message k
: Previous unread message j a
: Jump to all threads
j l
: Jump to MailingList overview
Author: mcayland Date: Tue Jun 15 21:59:47 2010 New Revision: 795 URL: http://tracker.coreboot.org/trac/openbios/changeset/795
Log: 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
Modified: trunk/openbios-devel/packages/mac-parts.c trunk/openbios-devel/packages/pc-parts.c trunk/openbios-devel/packages/sun-parts.c
Modified: trunk/openbios-devel/packages/mac-parts.c ============================================================================== --- trunk/openbios-devel/packages/mac-parts.c Tue Jun 15 18:31:54 2010 (r794) +++ trunk/openbios-devel/packages/mac-parts.c Tue Jun 15 21:59:47 2010 (r795) @@ -62,26 +62,37 @@ /* 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 */
Modified: trunk/openbios-devel/packages/pc-parts.c ============================================================================== --- trunk/openbios-devel/packages/pc-parts.c Tue Jun 15 18:31:54 2010 (r794) +++ trunk/openbios-devel/packages/pc-parts.c Tue Jun 15 21:59:47 2010 (r795) @@ -89,26 +89,37 @@ /* 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 */
Modified: trunk/openbios-devel/packages/sun-parts.c ============================================================================== --- trunk/openbios-devel/packages/sun-parts.c Tue Jun 15 18:31:54 2010 (r794) +++ trunk/openbios-devel/packages/sun-parts.c Tue Jun 15 21:59:47 2010 (r795) @@ -106,26 +106,37 @@ /* 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 @@ parnum = parstr[0] - 'a'; else parnum = atol(parstr); - } + } } }