grub2/grub2-ieee1275-open-raw-mode.patch

61 lines
1.8 KiB
Diff

From: diegodo@br.ibm.com
References: bsc#1071559
Patch-Mainline: no
Because Openfirmware returns invalid ihandler when it tries to open a disk
which his first partition is not a supported one by the firmware (Prep, FAT,
ISO), the grub needs to understand when it should open the disk in "raw mode",
appending a ":0" in the end of the device path.
Openfirmware is unable to open disk that contains a unknown first partition
(i.e it is not a PreP, Fat, ISO) ; We needed to open the disk in "raw mode" and
so Grub was required to take care of partitions and contents.
Index: grub-2.02/grub-core/kern/ieee1275/ieee1275.c
===================================================================
--- grub-2.02.orig/grub-core/kern/ieee1275/ieee1275.c
+++ grub-2.02/grub-core/kern/ieee1275/ieee1275.c
@@ -19,6 +19,8 @@
#include <grub/ieee1275/ieee1275.h>
#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
#define IEEE1275_PHANDLE_INVALID ((grub_ieee1275_cell_t) -1)
#define IEEE1275_IHANDLE_INVALID ((grub_ieee1275_cell_t) 0)
@@ -458,8 +460,31 @@ grub_ieee1275_open (const char *path, gr
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
return -1;
*result = args.result;
- if (args.result == IEEE1275_IHANDLE_INVALID)
- return -1;
+ if (args.result == IEEE1275_IHANDLE_INVALID){
+
+ int path_len = grub_strlen(path);
+ if ((path[path_len-3] == ':') && (path[path_len-2] == '0')){
+ return -1;
+ }
+
+ char *new_path = grub_malloc(grub_strlen(path) + 3);
+ char *optr;
+ optr = grub_stpcpy (new_path, path);
+ *optr++ = ':';
+ *optr++ = '0';
+ *optr++ = '\0';
+
+ args.path = (grub_ieee1275_cell_t) new_path;
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+
+ *result = args.result;
+ if (args.result == IEEE1275_IHANDLE_INVALID)
+ return -1;
+
+ }
+
return 0;
}