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
This commit is contained in:
Sughosh Ganu 2021-11-10 13:00:30 +05:30
parent 7585ec4d36
commit 3cb1065581
2 changed files with 15 additions and 0 deletions

View 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;

View 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);