From: Paul Nasrat Date: Mon, 3 Dec 2007 14:05:48 +0000 (+0000) Subject: Fix partition numbering handling with bplan firmware X-Git-Tag: yaboot-1.3.15-rc~15 X-Git-Url: http://git.ozlabs.org/?p=yaboot.git;a=commitdiff_plain;h=082b8310e3f92ea8da0b7011549bd86c9fd4ce95 Fix partition numbering handling with bplan firmware Patch based on Fedora patch by dwmw2@infradead.org --- diff --git a/include/bootinfo.h b/include/bootinfo.h index f61409a..7602e48 100644 --- a/include/bootinfo.h +++ b/include/bootinfo.h @@ -34,6 +34,7 @@ #define _MACH_classic 0x00000400 /* RPCG RPX-Classic 8xx board */ #define _MACH_oak 0x00000800 /* IBM "Oak" 403 eval. board */ #define _MACH_walnut 0x00001000 /* IBM "Walnut" 405GP eval. board */ +#define _MACH_bplan 0x00002000 /* Pegasos/Efika, broken partition #s */ struct bi_record { unsigned long tag; /* tag ID */ @@ -51,6 +52,8 @@ struct bi_record { #endif /* _PPC_BOOTINFO_H */ +extern int _machine; + /* * Local variables: * c-file-style: "k&r" diff --git a/second/fs_ext2.c b/second/fs_ext2.c index 3240ce2..67571f2 100644 --- a/second/fs_ext2.c +++ b/second/fs_ext2.c @@ -35,6 +35,7 @@ #include "fs.h" #include "errors.h" #include "debug.h" +#include "bootinfo.h" #define FAST_VERSION #define MAX_READ_RANGE 256 @@ -170,7 +171,8 @@ ext2_open( struct boot_file_t* file, /* Open the OF device for the entire disk */ strncpy(buffer, dev_name, 1020); - strcat(buffer, ":0"); + if (_machine != _MACH_bplan) + strcat(buffer, ":0"); DEBUG_F("<%s>\n", buffer); diff --git a/second/fs_reiserfs.c b/second/fs_reiserfs.c index 4ad1c2e..238f523 100644 --- a/second/fs_reiserfs.c +++ b/second/fs_reiserfs.c @@ -29,6 +29,7 @@ #include "fs.h" #include "errors.h" #include "debug.h" +#include "bootinfo.h" #include "reiserfs/reiserfs.h" /* Exported in struct fs_t */ @@ -84,7 +85,10 @@ reiserfs_open( struct boot_file_t *file, const char *dev_name, else INFO->partition_offset = 0; - sprintf( buffer, "%s:%d", dev_name, 0 ); /* 0 is full disk in OF */ + strncpy(buffer, dev_name, 1020); + if (_machine != _MACH_bplan) + strcat(buffer, ":0"); /* 0 is full disk in (non-buggy) OF */ + file->of_device = prom_open( buffer ); DEBUG_F( "Trying to open dev_name=%s; filename=%s; partition offset=%Lu\n", buffer, file_name, INFO->partition_offset ); diff --git a/second/fs_xfs.c b/second/fs_xfs.c index 9a2aaa6..04d6cf3 100644 --- a/second/fs_xfs.c +++ b/second/fs_xfs.c @@ -30,6 +30,7 @@ #include "xfs/xfs.h" #include "errors.h" #include "debug.h" +#include "bootinfo.h" #define SECTOR_BITS 9 @@ -77,7 +78,9 @@ xfs_open(struct boot_file_t *file, const char *dev_name, else partition_offset = 0; - sprintf(buffer, "%s:%d", dev_name, 0); /* 0 is full disk in OF */ + strncpy(buffer, dev_name, 1020); + if (_machine != _MACH_bplan) + strcat(buffer, ":0"); /* 0 is full disk in (non-buggy) OF */ DEBUG_F("Trying to open dev_name=%s; filename=%s; partition offset=%Lu\n", buffer, file_name, partition_offset); file->of_device = prom_open(buffer); diff --git a/second/partition.c b/second/partition.c index 0cb8ae8..9a7fe73 100644 --- a/second/partition.c +++ b/second/partition.c @@ -40,6 +40,7 @@ #include "linux/iso_fs.h" #include "debug.h" #include "errors.h" +#include "bootinfo.h" #include "byteorder.h" /* We currently don't check the partition type, some users @@ -337,7 +338,8 @@ partitions_lookup(const char *device) unsigned int prom_blksize, iso_root_block; strncpy(block_buffer, device, 2040); - strcat(block_buffer, ":0"); + if (_machine != _MACH_bplan) + strcat(block_buffer, ":0"); /* Open device */ disk = prom_open(block_buffer); diff --git a/second/yaboot.c b/second/yaboot.c index 9b499b9..2fa4736 100644 --- a/second/yaboot.c +++ b/second/yaboot.c @@ -223,7 +223,10 @@ yaboot_start (unsigned long r3, unsigned long r4, unsigned long r5) root = prom_finddevice("/"); if (root != 0) { static char model[256]; - if (prom_getprop(root, "device_type", model, 256 ) > 0 && + if (prom_getprop(root, "CODEGEN,vendor", model, 256) > 0 && + !strncmp("bplan", model, 5)) + _machine = _MACH_bplan; + else if (prom_getprop(root, "device_type", model, 256 ) > 0 && !strncmp("chrp", model, 4)) _machine = _MACH_chrp; else { @@ -459,7 +462,7 @@ static int load_my_config_file(struct boot_fspec_t *orig_fspec) struct bootp_packet *packet; int rc = 0; struct boot_fspec_t fspec = *orig_fspec; - char *cfgpath = (_machine == _MACH_chrp) ? "/etc/" : ""; + char *cfgpath = (_machine == _MACH_chrp || _machine == _MACH_bplan) ? "/etc/" : ""; int flen; int minlen; @@ -1726,11 +1729,13 @@ yaboot_main(void) prom_printf("%s: Unable to parse\n", bootdevice); return -1; } + if (_machine == MACH_bplan) + boot.part++; DEBUG_F("After parse_device_path: dev=%s, part=%d, file=%s\n", boot.dev, boot.part, boot.file); if (!conf_given) { - if (_machine == _MACH_chrp) + if (_machine == _MACH_chrp || machine == _MACH_bplan) boot.file = "/etc/"; else if (strlen(boot.file)) { if (!strncmp(boot.file, "\\\\", 2))