feat(partition): add a function to identify a partition by GUID
With the GPT partition scheme, a partition can be identified using
it's UniquePartitionGUID, instead of it's name. Add a function to
identify the partition based on this GUID value. This functionality is
useful in identification of a partition whose UniquePartitionGUID
value is known.
Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Change-Id: I543f794e1f7773f969968a6bce85ecca6f6a1659
diff --git a/drivers/partition/partition.c b/drivers/partition/partition.c
index fdea10d..7706f88 100644
--- a/drivers/partition/partition.c
+++ b/drivers/partition/partition.c
@@ -11,6 +11,7 @@
#include <common/debug.h>
#include <drivers/io/io_storage.h>
+#include <drivers/partition/efi.h>
#include <drivers/partition/partition.h>
#include <drivers/partition/gpt.h>
#include <drivers/partition/mbr.h>
@@ -246,6 +247,19 @@
return NULL;
}
+const partition_entry_t *get_partition_entry_by_uuid(const uuid_t *part_uuid)
+{
+ int i;
+
+ for (i = 0; i < list.entry_count; i++) {
+ if (guidcmp(part_uuid, &list.list[i].part_guid) == 0) {
+ return &list.list[i];
+ }
+ }
+
+ return NULL;
+}
+
const partition_entry_list_t *get_partition_entry_list(void)
{
return &list;