* grub-core/disk/ieee1275/ofdisk.c: Iterate over bootpath even if it
would be otherwise excluded.
This commit is contained in:
parent
87206f2cf1
commit
ac4fea7998
2 changed files with 52 additions and 4 deletions
|
@ -1,4 +1,9 @@
|
||||||
2013-04-13 Vladimir Serbinenko <phcoder@gmail.com>
|
2013-04-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* grub-core/disk/ieee1275/ofdisk.c: Iterate over bootpath even if it
|
||||||
|
would be otherwise excluded.
|
||||||
|
|
||||||
|
2013-04-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* grub-core/kern/ieee1275/cmain.c (grub_ieee1275_find_options):
|
* grub-core/kern/ieee1275/cmain.c (grub_ieee1275_find_options):
|
||||||
Inline name defines used only once.
|
Inline name defines used only once.
|
||||||
|
|
|
@ -31,6 +31,7 @@ static grub_ieee1275_ihandle_t last_ihandle;
|
||||||
struct ofdisk_hash_ent
|
struct ofdisk_hash_ent
|
||||||
{
|
{
|
||||||
char *devpath;
|
char *devpath;
|
||||||
|
int is_boot;
|
||||||
/* Pointer to shortest available name on nodes representing canonical names,
|
/* Pointer to shortest available name on nodes representing canonical names,
|
||||||
otherwise NULL. */
|
otherwise NULL. */
|
||||||
const char *shortest;
|
const char *shortest;
|
||||||
|
@ -69,13 +70,12 @@ ofdisk_hash_add_real (char *devpath)
|
||||||
struct ofdisk_hash_ent *p;
|
struct ofdisk_hash_ent *p;
|
||||||
struct ofdisk_hash_ent **head = &ofdisk_hash[ofdisk_hash_fn(devpath)];
|
struct ofdisk_hash_ent **head = &ofdisk_hash[ofdisk_hash_fn(devpath)];
|
||||||
|
|
||||||
p = grub_malloc(sizeof (*p));
|
p = grub_zalloc (sizeof (*p));
|
||||||
if (!p)
|
if (!p)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
p->devpath = devpath;
|
p->devpath = devpath;
|
||||||
p->next = *head;
|
p->next = *head;
|
||||||
p->shortest = 0;
|
|
||||||
*head = p;
|
*head = p;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
@ -267,7 +267,8 @@ grub_ofdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (grub_strncmp (ent->shortest, "cdrom", 5) == 0)
|
if (grub_strncmp (ent->shortest, "cdrom", 5) == 0
|
||||||
|
|| ent->is_boot)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -491,9 +492,51 @@ static struct grub_disk_dev grub_ofdisk_dev =
|
||||||
.next = 0
|
.next = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
insert_bootpath (void)
|
||||||
|
{
|
||||||
|
char *bootpath;
|
||||||
|
grub_ssize_t bootpath_size;
|
||||||
|
char *type;
|
||||||
|
|
||||||
|
if (grub_ieee1275_get_property_length (grub_ieee1275_chosen, "bootpath",
|
||||||
|
&bootpath_size)
|
||||||
|
|| bootpath_size <= 0)
|
||||||
|
{
|
||||||
|
/* Should never happen. */
|
||||||
|
grub_printf ("/chosen/bootpath property missing!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bootpath = (char *) grub_malloc ((grub_size_t) bootpath_size + 64);
|
||||||
|
if (! bootpath)
|
||||||
|
{
|
||||||
|
grub_print_error ();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", bootpath,
|
||||||
|
(grub_size_t) bootpath_size + 1, 0);
|
||||||
|
bootpath[bootpath_size] = '\0';
|
||||||
|
|
||||||
|
/* Transform an OF device path to a GRUB path. */
|
||||||
|
|
||||||
|
type = grub_ieee1275_get_device_type (bootpath);
|
||||||
|
if (!(type && grub_strcmp (type, "network") == 0))
|
||||||
|
{
|
||||||
|
struct ofdisk_hash_ent *op;
|
||||||
|
char *device = grub_ieee1275_get_devname (bootpath);
|
||||||
|
op = ofdisk_hash_add (device, NULL);
|
||||||
|
op->is_boot = 1;
|
||||||
|
}
|
||||||
|
grub_free (type);
|
||||||
|
grub_free (bootpath);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_ofdisk_init (void)
|
grub_ofdisk_init (void)
|
||||||
{
|
{
|
||||||
|
insert_bootpath ();
|
||||||
|
|
||||||
grub_disk_dev_register (&grub_ofdisk_dev);
|
grub_disk_dev_register (&grub_ofdisk_dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue