* grub-core/disk/efi/efidisk.c: Transform iterate_child_devices into
a FOR_CHILDREN macro.
This commit is contained in:
parent
be174e5ef3
commit
f42e3a2f67
2 changed files with 26 additions and 34 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2013-03-01 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* grub-core/disk/efi/efidisk.c: Transform iterate_child_devices into
|
||||||
|
a FOR_CHILDREN macro.
|
||||||
|
|
||||||
2013-03-01 Vladimir Serbinenko <phcoder@gmail.com>
|
2013-03-01 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* grub-core/kern/main.c (grub_set_prefix_and_root): Strip trailing
|
* grub-core/kern/main.c (grub_set_prefix_and_root): Strip trailing
|
||||||
|
|
|
@ -175,39 +175,29 @@ find_parent_device (struct grub_efidisk_data *devices,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
iterate_child_devices (struct grub_efidisk_data *devices,
|
is_child (struct grub_efidisk_data *child,
|
||||||
struct grub_efidisk_data *d,
|
struct grub_efidisk_data *parent)
|
||||||
int (*hook) (struct grub_efidisk_data *child))
|
|
||||||
{
|
{
|
||||||
struct grub_efidisk_data *p;
|
grub_efi_device_path_t *dp, *ldp;
|
||||||
|
int ret;
|
||||||
|
|
||||||
for (p = devices; p; p = p->next)
|
dp = duplicate_device_path (child->device_path);
|
||||||
{
|
if (! dp)
|
||||||
grub_efi_device_path_t *dp, *ldp;
|
return 0;
|
||||||
|
|
||||||
dp = duplicate_device_path (p->device_path);
|
ldp = find_last_device_path (dp);
|
||||||
if (! dp)
|
ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
|
||||||
return 0;
|
ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
|
||||||
|
ldp->length[0] = sizeof (*ldp);
|
||||||
|
ldp->length[1] = 0;
|
||||||
|
|
||||||
ldp = find_last_device_path (dp);
|
ret = (grub_efi_compare_device_paths (dp, parent->device_path) == 0);
|
||||||
ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
|
grub_free (dp);
|
||||||
ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
|
return ret;
|
||||||
ldp->length[0] = sizeof (*ldp);
|
|
||||||
ldp->length[1] = 0;
|
|
||||||
|
|
||||||
if (grub_efi_compare_device_paths (dp, d->device_path) == 0)
|
|
||||||
if (hook (p))
|
|
||||||
{
|
|
||||||
grub_free (dp);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
grub_free (dp);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define FOR_CHILDREN(p, dev) for (p = dev; p; p = p->next) if (is_child (p, d))
|
||||||
|
|
||||||
/* Add a device into a list of devices in an ascending order. */
|
/* Add a device into a list of devices in an ascending order. */
|
||||||
static void
|
static void
|
||||||
add_device (struct grub_efidisk_data **devices, struct grub_efidisk_data *d)
|
add_device (struct grub_efidisk_data **devices, struct grub_efidisk_data *d)
|
||||||
|
@ -655,9 +645,10 @@ grub_efidisk_get_device_handle (grub_disk_t disk)
|
||||||
{
|
{
|
||||||
struct grub_efidisk_data *devices;
|
struct grub_efidisk_data *devices;
|
||||||
grub_efi_handle_t handle = 0;
|
grub_efi_handle_t handle = 0;
|
||||||
auto int find_partition (struct grub_efidisk_data *c);
|
struct grub_efidisk_data *c;
|
||||||
|
|
||||||
int find_partition (struct grub_efidisk_data *c)
|
devices = make_devices ();
|
||||||
|
FOR_CHILDREN (c, devices)
|
||||||
{
|
{
|
||||||
grub_efi_hard_drive_device_path_t hd;
|
grub_efi_hard_drive_device_path_t hd;
|
||||||
|
|
||||||
|
@ -673,14 +664,10 @@ grub_efidisk_get_device_handle (grub_disk_t disk)
|
||||||
== hd.partition_size))
|
== hd.partition_size))
|
||||||
{
|
{
|
||||||
handle = c->handle;
|
handle = c->handle;
|
||||||
return 1;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
devices = make_devices ();
|
|
||||||
iterate_child_devices (devices, d, find_partition);
|
|
||||||
free_devices (devices);
|
free_devices (devices);
|
||||||
|
|
||||||
if (handle != 0)
|
if (handle != 0)
|
||||||
|
|
Loading…
Reference in a new issue