|
|
a5bd9f6 |
From 595ef9fc233b0cf6b4c07c02acce3f61c9a7b947 Mon Sep 17 00:00:00 2001
|
|
|
a5bd9f6 |
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
|
|
|
a5bd9f6 |
Date: Sun, 14 Apr 2013 16:55:20 +0200
|
|
|
a5bd9f6 |
Subject: [PATCH 301/364] * grub-core/disk/ieee1275/ofdisk.c: Iterate
|
|
|
a5bd9f6 |
over bootpath even if it would be otherwise excluded.
|
|
|
a5bd9f6 |
|
|
|
a5bd9f6 |
---
|
|
|
a5bd9f6 |
ChangeLog | 7 +++++-
|
|
|
a5bd9f6 |
grub-core/disk/ieee1275/ofdisk.c | 49 +++++++++++++++++++++++++++++++++++++---
|
|
|
a5bd9f6 |
2 files changed, 52 insertions(+), 4 deletions(-)
|
|
|
a5bd9f6 |
|
|
|
a5bd9f6 |
diff --git a/ChangeLog b/ChangeLog
|
|
|
a5bd9f6 |
index 9df4d1e..1088061 100644
|
|
|
a5bd9f6 |
--- a/ChangeLog
|
|
|
a5bd9f6 |
+++ b/ChangeLog
|
|
|
a5bd9f6 |
@@ -1,4 +1,9 @@
|
|
|
a5bd9f6 |
-2013-04-13 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
a5bd9f6 |
+2013-04-14 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
a5bd9f6 |
+
|
|
|
a5bd9f6 |
+ * grub-core/disk/ieee1275/ofdisk.c: Iterate over bootpath even if it
|
|
|
a5bd9f6 |
+ would be otherwise excluded.
|
|
|
a5bd9f6 |
+
|
|
|
a5bd9f6 |
+2013-04-14 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
a5bd9f6 |
|
|
|
a5bd9f6 |
* grub-core/kern/ieee1275/cmain.c (grub_ieee1275_find_options):
|
|
|
a5bd9f6 |
Inline name defines used only once.
|
|
|
a5bd9f6 |
diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c
|
|
|
a5bd9f6 |
index 1d4de90..bebf777 100644
|
|
|
a5bd9f6 |
--- a/grub-core/disk/ieee1275/ofdisk.c
|
|
|
a5bd9f6 |
+++ b/grub-core/disk/ieee1275/ofdisk.c
|
|
|
a5bd9f6 |
@@ -31,6 +31,7 @@ static grub_ieee1275_ihandle_t last_ihandle;
|
|
|
a5bd9f6 |
struct ofdisk_hash_ent
|
|
|
a5bd9f6 |
{
|
|
|
a5bd9f6 |
char *devpath;
|
|
|
a5bd9f6 |
+ int is_boot;
|
|
|
a5bd9f6 |
/* Pointer to shortest available name on nodes representing canonical names,
|
|
|
a5bd9f6 |
otherwise NULL. */
|
|
|
a5bd9f6 |
const char *shortest;
|
|
|
a5bd9f6 |
@@ -69,13 +70,12 @@ ofdisk_hash_add_real (char *devpath)
|
|
|
a5bd9f6 |
struct ofdisk_hash_ent *p;
|
|
|
a5bd9f6 |
struct ofdisk_hash_ent **head = &ofdisk_hash[ofdisk_hash_fn(devpath)];
|
|
|
a5bd9f6 |
|
|
|
a5bd9f6 |
- p = grub_malloc(sizeof (*p));
|
|
|
a5bd9f6 |
+ p = grub_zalloc (sizeof (*p));
|
|
|
a5bd9f6 |
if (!p)
|
|
|
a5bd9f6 |
return NULL;
|
|
|
a5bd9f6 |
|
|
|
a5bd9f6 |
p->devpath = devpath;
|
|
|
a5bd9f6 |
p->next = *head;
|
|
|
a5bd9f6 |
- p->shortest = 0;
|
|
|
a5bd9f6 |
*head = p;
|
|
|
a5bd9f6 |
return p;
|
|
|
a5bd9f6 |
}
|
|
|
a5bd9f6 |
@@ -267,7 +267,8 @@ grub_ofdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
|
|
|
a5bd9f6 |
}
|
|
|
a5bd9f6 |
}
|
|
|
a5bd9f6 |
|
|
|
a5bd9f6 |
- if (grub_strncmp (ent->shortest, "cdrom", 5) == 0)
|
|
|
a5bd9f6 |
+ if (grub_strncmp (ent->shortest, "cdrom", 5) == 0
|
|
|
a5bd9f6 |
+ || ent->is_boot)
|
|
|
a5bd9f6 |
continue;
|
|
|
a5bd9f6 |
|
|
|
a5bd9f6 |
{
|
|
|
a5bd9f6 |
@@ -491,9 +492,51 @@ static struct grub_disk_dev grub_ofdisk_dev =
|
|
|
a5bd9f6 |
.next = 0
|
|
|
a5bd9f6 |
};
|
|
|
a5bd9f6 |
|
|
|
a5bd9f6 |
+static void
|
|
|
a5bd9f6 |
+insert_bootpath (void)
|
|
|
a5bd9f6 |
+{
|
|
|
a5bd9f6 |
+ char *bootpath;
|
|
|
a5bd9f6 |
+ grub_ssize_t bootpath_size;
|
|
|
a5bd9f6 |
+ char *type;
|
|
|
a5bd9f6 |
+
|
|
|
a5bd9f6 |
+ if (grub_ieee1275_get_property_length (grub_ieee1275_chosen, "bootpath",
|
|
|
a5bd9f6 |
+ &bootpath_size)
|
|
|
a5bd9f6 |
+ || bootpath_size <= 0)
|
|
|
a5bd9f6 |
+ {
|
|
|
a5bd9f6 |
+ /* Should never happen. */
|
|
|
a5bd9f6 |
+ grub_printf ("/chosen/bootpath property missing!\n");
|
|
|
a5bd9f6 |
+ return;
|
|
|
a5bd9f6 |
+ }
|
|
|
a5bd9f6 |
+
|
|
|
a5bd9f6 |
+ bootpath = (char *) grub_malloc ((grub_size_t) bootpath_size + 64);
|
|
|
a5bd9f6 |
+ if (! bootpath)
|
|
|
a5bd9f6 |
+ {
|
|
|
a5bd9f6 |
+ grub_print_error ();
|
|
|
a5bd9f6 |
+ return;
|
|
|
a5bd9f6 |
+ }
|
|
|
a5bd9f6 |
+ grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", bootpath,
|
|
|
a5bd9f6 |
+ (grub_size_t) bootpath_size + 1, 0);
|
|
|
a5bd9f6 |
+ bootpath[bootpath_size] = '\0';
|
|
|
a5bd9f6 |
+
|
|
|
a5bd9f6 |
+ /* Transform an OF device path to a GRUB path. */
|
|
|
a5bd9f6 |
+
|
|
|
a5bd9f6 |
+ type = grub_ieee1275_get_device_type (bootpath);
|
|
|
a5bd9f6 |
+ if (!(type && grub_strcmp (type, "network") == 0))
|
|
|
a5bd9f6 |
+ {
|
|
|
a5bd9f6 |
+ struct ofdisk_hash_ent *op;
|
|
|
a5bd9f6 |
+ char *device = grub_ieee1275_get_devname (bootpath);
|
|
|
a5bd9f6 |
+ op = ofdisk_hash_add (device, NULL);
|
|
|
a5bd9f6 |
+ op->is_boot = 1;
|
|
|
a5bd9f6 |
+ }
|
|
|
a5bd9f6 |
+ grub_free (type);
|
|
|
a5bd9f6 |
+ grub_free (bootpath);
|
|
|
a5bd9f6 |
+}
|
|
|
a5bd9f6 |
+
|
|
|
a5bd9f6 |
void
|
|
|
a5bd9f6 |
grub_ofdisk_init (void)
|
|
|
a5bd9f6 |
{
|
|
|
a5bd9f6 |
+ insert_bootpath ();
|
|
|
a5bd9f6 |
+
|
|
|
a5bd9f6 |
grub_disk_dev_register (&grub_ofdisk_dev);
|
|
|
a5bd9f6 |
}
|
|
|
a5bd9f6 |
|
|
|
a5bd9f6 |
--
|
|
|
a5bd9f6 |
1.8.1.4
|
|
|
a5bd9f6 |
|