|
|
a5bd9f6 |
From d81bf19e26c7af47e38206a7cbd825f559ac7457 Mon Sep 17 00:00:00 2001
|
|
|
a5bd9f6 |
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
|
|
|
a5bd9f6 |
Date: Fri, 1 Mar 2013 10:37:11 +0100
|
|
|
a5bd9f6 |
Subject: [PATCH 172/364] * grub-core/disk/efi/efidisk.c: Transform
|
|
|
a5bd9f6 |
iterate_child_devices into a FOR_CHILDREN macro.
|
|
|
a5bd9f6 |
|
|
|
a5bd9f6 |
---
|
|
|
a5bd9f6 |
ChangeLog | 5 ++++
|
|
|
a5bd9f6 |
grub-core/disk/efi/efidisk.c | 55 +++++++++++++++++---------------------------
|
|
|
a5bd9f6 |
2 files changed, 26 insertions(+), 34 deletions(-)
|
|
|
a5bd9f6 |
|
|
|
a5bd9f6 |
diff --git a/ChangeLog b/ChangeLog
|
|
|
a5bd9f6 |
index 986871c..ccd6c0a 100644
|
|
|
a5bd9f6 |
--- a/ChangeLog
|
|
|
a5bd9f6 |
+++ b/ChangeLog
|
|
|
a5bd9f6 |
@@ -1,5 +1,10 @@
|
|
|
a5bd9f6 |
2013-03-01 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
a5bd9f6 |
|
|
|
a5bd9f6 |
+ * grub-core/disk/efi/efidisk.c: Transform iterate_child_devices into
|
|
|
a5bd9f6 |
+ a FOR_CHILDREN macro.
|
|
|
a5bd9f6 |
+
|
|
|
a5bd9f6 |
+2013-03-01 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
a5bd9f6 |
+
|
|
|
a5bd9f6 |
* grub-core/kern/main.c (grub_set_prefix_and_root): Strip trailing
|
|
|
a5bd9f6 |
platform from firmware path.
|
|
|
a5bd9f6 |
|
|
|
a5bd9f6 |
diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c
|
|
|
a5bd9f6 |
index 19c5923..c883b2c 100644
|
|
|
a5bd9f6 |
--- a/grub-core/disk/efi/efidisk.c
|
|
|
a5bd9f6 |
+++ b/grub-core/disk/efi/efidisk.c
|
|
|
a5bd9f6 |
@@ -175,39 +175,29 @@ find_parent_device (struct grub_efidisk_data *devices,
|
|
|
a5bd9f6 |
}
|
|
|
a5bd9f6 |
|
|
|
a5bd9f6 |
static int
|
|
|
a5bd9f6 |
-iterate_child_devices (struct grub_efidisk_data *devices,
|
|
|
a5bd9f6 |
- struct grub_efidisk_data *d,
|
|
|
a5bd9f6 |
- int (*hook) (struct grub_efidisk_data *child))
|
|
|
a5bd9f6 |
+is_child (struct grub_efidisk_data *child,
|
|
|
a5bd9f6 |
+ struct grub_efidisk_data *parent)
|
|
|
a5bd9f6 |
{
|
|
|
a5bd9f6 |
- struct grub_efidisk_data *p;
|
|
|
a5bd9f6 |
-
|
|
|
a5bd9f6 |
- for (p = devices; p; p = p->next)
|
|
|
a5bd9f6 |
- {
|
|
|
a5bd9f6 |
- grub_efi_device_path_t *dp, *ldp;
|
|
|
a5bd9f6 |
-
|
|
|
a5bd9f6 |
- dp = duplicate_device_path (p->device_path);
|
|
|
a5bd9f6 |
- if (! dp)
|
|
|
a5bd9f6 |
- return 0;
|
|
|
a5bd9f6 |
-
|
|
|
a5bd9f6 |
- ldp = find_last_device_path (dp);
|
|
|
a5bd9f6 |
- ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
|
|
|
a5bd9f6 |
- ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
|
|
|
a5bd9f6 |
- ldp->length[0] = sizeof (*ldp);
|
|
|
a5bd9f6 |
- ldp->length[1] = 0;
|
|
|
a5bd9f6 |
+ grub_efi_device_path_t *dp, *ldp;
|
|
|
a5bd9f6 |
+ int ret;
|
|
|
a5bd9f6 |
|
|
|
a5bd9f6 |
- if (grub_efi_compare_device_paths (dp, d->device_path) == 0)
|
|
|
a5bd9f6 |
- if (hook (p))
|
|
|
a5bd9f6 |
- {
|
|
|
a5bd9f6 |
- grub_free (dp);
|
|
|
a5bd9f6 |
- return 1;
|
|
|
a5bd9f6 |
- }
|
|
|
a5bd9f6 |
+ dp = duplicate_device_path (child->device_path);
|
|
|
a5bd9f6 |
+ if (! dp)
|
|
|
a5bd9f6 |
+ return 0;
|
|
|
a5bd9f6 |
|
|
|
a5bd9f6 |
- grub_free (dp);
|
|
|
a5bd9f6 |
- }
|
|
|
a5bd9f6 |
+ ldp = find_last_device_path (dp);
|
|
|
a5bd9f6 |
+ ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
|
|
|
a5bd9f6 |
+ ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
|
|
|
a5bd9f6 |
+ ldp->length[0] = sizeof (*ldp);
|
|
|
a5bd9f6 |
+ ldp->length[1] = 0;
|
|
|
a5bd9f6 |
|
|
|
a5bd9f6 |
- return 0;
|
|
|
a5bd9f6 |
+ ret = (grub_efi_compare_device_paths (dp, parent->device_path) == 0);
|
|
|
a5bd9f6 |
+ grub_free (dp);
|
|
|
a5bd9f6 |
+ return ret;
|
|
|
a5bd9f6 |
}
|
|
|
a5bd9f6 |
|
|
|
a5bd9f6 |
+#define FOR_CHILDREN(p, dev) for (p = dev; p; p = p->next) if (is_child (p, d))
|
|
|
a5bd9f6 |
+
|
|
|
a5bd9f6 |
/* Add a device into a list of devices in an ascending order. */
|
|
|
a5bd9f6 |
static void
|
|
|
a5bd9f6 |
add_device (struct grub_efidisk_data **devices, struct grub_efidisk_data *d)
|
|
|
a5bd9f6 |
@@ -655,9 +645,10 @@ grub_efidisk_get_device_handle (grub_disk_t disk)
|
|
|
a5bd9f6 |
{
|
|
|
a5bd9f6 |
struct grub_efidisk_data *devices;
|
|
|
a5bd9f6 |
grub_efi_handle_t handle = 0;
|
|
|
a5bd9f6 |
- auto int find_partition (struct grub_efidisk_data *c);
|
|
|
a5bd9f6 |
+ struct grub_efidisk_data *c;
|
|
|
a5bd9f6 |
|
|
|
a5bd9f6 |
- int find_partition (struct grub_efidisk_data *c)
|
|
|
a5bd9f6 |
+ devices = make_devices ();
|
|
|
a5bd9f6 |
+ FOR_CHILDREN (c, devices)
|
|
|
a5bd9f6 |
{
|
|
|
a5bd9f6 |
grub_efi_hard_drive_device_path_t hd;
|
|
|
a5bd9f6 |
|
|
|
a5bd9f6 |
@@ -673,14 +664,10 @@ grub_efidisk_get_device_handle (grub_disk_t disk)
|
|
|
a5bd9f6 |
== hd.partition_size))
|
|
|
a5bd9f6 |
{
|
|
|
a5bd9f6 |
handle = c->handle;
|
|
|
a5bd9f6 |
- return 1;
|
|
|
a5bd9f6 |
+ break;
|
|
|
a5bd9f6 |
}
|
|
|
a5bd9f6 |
-
|
|
|
a5bd9f6 |
- return 0;
|
|
|
a5bd9f6 |
}
|
|
|
a5bd9f6 |
|
|
|
a5bd9f6 |
- devices = make_devices ();
|
|
|
a5bd9f6 |
- iterate_child_devices (devices, d, find_partition);
|
|
|
a5bd9f6 |
free_devices (devices);
|
|
|
a5bd9f6 |
|
|
|
a5bd9f6 |
if (handle != 0)
|
|
|
a5bd9f6 |
--
|
|
|
a5bd9f6 |
1.8.1.4
|
|
|
a5bd9f6 |
|