]> git.ozlabs.org Git - yaboot.git/commitdiff
Fix partition numbering handling with bplan firmware
authorPaul Nasrat <pauln@truemesh.com>
Mon, 3 Dec 2007 14:05:48 +0000 (14:05 +0000)
committerPaul Nasrat <pauln@truemesh.com>
Mon, 3 Dec 2007 14:05:48 +0000 (14:05 +0000)
Patch based on Fedora patch by dwmw2@infradead.org

include/bootinfo.h
second/fs_ext2.c
second/fs_reiserfs.c
second/fs_xfs.c
second/partition.c
second/yaboot.c

index f61409a374053df2174e33e7a8da904d71cc966c..7602e489ded1c64fcbf114b1f552051616f54503 100644 (file)
@@ -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"
index 3240ce215ac802c6164f459f2f06df7e67c937d0..67571f28fadda668e967cde6e263a2ce37dda0a8 100644 (file)
@@ -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);
 
index 4ad1c2ec176dbb9bb7495e9550e0d4312c40643e..238f523e843c848246522e064be08a402c4b6794 100644 (file)
@@ -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 );
index 9a2aaa6bd097bfcdf1a7fcdbba470bc3095cef53..04d6cf3a4db03943a444636abec51c27bc26c6d7 100644 (file)
@@ -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);
index 0cb8ae85f1768bb7aef755c6ef37f64b64f5f168..9a7fe7394b683e2e8113852c8a105c4ae3a189f3 100644 (file)
@@ -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);
index 9b499b96cb014fc063bd5cd0b2ecef24a5214ccf..2fa47363255b3bb5ecd5d7c8731d9cde740e1eec 100644 (file)
@@ -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))