]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
feat(partition): add a function to identify a partition by GUID
authorSughosh Ganu <sughosh.ganu@linaro.org>
Wed, 10 Nov 2021 07:30:30 +0000 (13:00 +0530)
committerSughosh Ganu <sughosh.ganu@linaro.org>
Thu, 27 Jan 2022 12:39:02 +0000 (18:09 +0530)
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

drivers/partition/partition.c
include/drivers/partition/partition.h

index fdea10dbda8f8cd4482c4d95d098d33f6de05e9e..7706f88affe8d4d1bb2c02dc723fb1ba92274693 100644 (file)
@@ -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 @@ const partition_entry_t *get_partition_entry(const char *name)
        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;
index cd1a95b4521b89c8c68ada0a0b132a5f378d5d58..b292ec7b228325128cd999b6c8c2c23df4fac01a 100644 (file)
@@ -43,6 +43,7 @@ typedef struct partition_entry_list {
 
 int load_partition_table(unsigned int image_id);
 const partition_entry_t *get_partition_entry(const char *name);
+const partition_entry_t *get_partition_entry_by_uuid(const uuid_t *part_uuid);
 const partition_entry_list_t *get_partition_entry_list(void);
 void partition_init(unsigned int image_id);