diff options
author | Alison Chaiken <alison@peloton-tech.com> | 2017-06-25 16:43:23 -0700 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2017-08-04 09:56:04 -0400 |
commit | 73d6d18b7147c90d6f8a60acb8dad663a225e63d (patch) | |
tree | 0df0ea577d085439b7a87dac0d92e0b46cb5862a /disk | |
parent | e6faf21f259ccc0601d06d458e33fb742deb1843 (diff) | |
download | u-boot-73d6d18b7147c90d6f8a60acb8dad663a225e63d.tar.gz |
GPT: add accessor function for disk GUID
In order to read the GPT, modify the partition name strings, and then
write out a new GPT, the disk GUID is needed. While there is an
existing accessor for the partition UUIDs, there is none yet for the
disk GUID.
Changes since v6: none.
Signed-off-by: Alison Chaiken <alison@peloton-tech.com>
Diffstat (limited to 'disk')
-rw-r--r-- | disk/part_efi.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/disk/part_efi.c b/disk/part_efi.c index 20d33ef275..71c3cb3f78 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -178,6 +178,37 @@ static void prepare_backup_gpt_header(gpt_header *gpt_h) * Public Functions (include/part.h) */ +/* + * UUID is displayed as 32 hexadecimal digits, in 5 groups, + * separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters + */ +int get_disk_guid(struct blk_desc * dev_desc, char *guid) +{ + ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_head, 1, dev_desc->blksz); + gpt_entry *gpt_pte = NULL; + unsigned char *guid_bin; + + /* This function validates AND fills in the GPT header and PTE */ + if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA, + gpt_head, &gpt_pte) != 1) { + printf("%s: *** ERROR: Invalid GPT ***\n", __func__); + if (is_gpt_valid(dev_desc, dev_desc->lba - 1, + gpt_head, &gpt_pte) != 1) { + printf("%s: *** ERROR: Invalid Backup GPT ***\n", + __func__); + return -EINVAL; + } else { + printf("%s: *** Using Backup GPT ***\n", + __func__); + } + } + + guid_bin = gpt_head->disk_guid.b; + uuid_bin_to_str(guid_bin, guid, UUID_STR_FORMAT_GUID); + + return 0; +} + void part_print_efi(struct blk_desc *dev_desc) { ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_head, 1, dev_desc->blksz); |