diff options
author | Joshua Watt <jpewhacker@gmail.com> | 2023-08-31 10:51:39 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-09-11 16:27:49 -0400 |
commit | 368beaf7bb609b1daede46e3b31f5788d52e44e5 (patch) | |
tree | 04e911edcd64b315207a348b9db333d684e21761 /cmd | |
parent | a1e793add5dd21c2a1b08bc57ac99e43183913b6 (diff) | |
download | u-boot-368beaf7bb609b1daede46e3b31f5788d52e44e5.tar.gz |
cmd: gpt: Preserve type GUID if enabled
If CONFIG_PARTITION_TYPE_GUID is enabled, the type GUID will be
preserved when writing out the partition string. It was already
respected when writing out partitions; this ensures that if you capture
the current partition layout and write it back (such as when renaming),
the type GUIDs are preserved.
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/gpt.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/cmd/gpt.c b/cmd/gpt.c index 42e289c8724..9cc72934388 100644 --- a/cmd/gpt.c +++ b/cmd/gpt.c @@ -173,6 +173,9 @@ static int calc_parts_list_len(int numparts) /* see part.h for definition of struct disk_partition */ partlistlen += numparts * (strlen("start=MiB,") + sizeof(lbaint_t) + 1); partlistlen += numparts * (strlen("size=MiB,") + sizeof(lbaint_t) + 1); +#ifdef CONFIG_PARTITION_TYPE_GUID + partlistlen += numparts * (strlen("type=,") + UUID_STR_LEN + 1); +#endif partlistlen += numparts * (strlen("uuid=;") + UUID_STR_LEN + 1); /* for the terminating null */ partlistlen++; @@ -211,6 +214,11 @@ static struct disk_part *allocate_disk_part(struct disk_partition *info, PART_TYPE_LEN); newpart->gpt_part_info.type[PART_TYPE_LEN - 1] = '\0'; newpart->gpt_part_info.bootable = info->bootable; +#ifdef CONFIG_PARTITION_TYPE_GUID + strncpy(newpart->gpt_part_info.type_guid, (const char *)info->type_guid, + UUID_STR_LEN); + newpart->gpt_part_info.type_guid[UUID_STR_LEN] = '\0'; +#endif if (IS_ENABLED(CONFIG_PARTITION_UUIDS)) { strlcpy(newpart->gpt_part_info.uuid, disk_partition_uuid(info), UUID_STR_LEN + 1); @@ -250,6 +258,9 @@ static void print_gpt_info(void) curr->gpt_part_info.name); printf("Type %s, bootable %d\n", curr->gpt_part_info.type, curr->gpt_part_info.bootable & PART_BOOTABLE); +#ifdef CONFIG_PARTITION_TYPE_GUID + printf("Type GUID %s\n", curr->gpt_part_info.type_guid); +#endif #ifdef CONFIG_PARTITION_UUIDS printf("UUID %s\n", curr->gpt_part_info.uuid); #endif @@ -297,6 +308,11 @@ static int create_gpt_partitions_list(int numparts, const char *guid, curr->gpt_part_info.blksz); strncat(partitions_list, partstr, PART_NAME_LEN + 1); +#ifdef CONFIG_PARTITION_TYPE_GUID + strcat(partitions_list, ",type="); + strncat(partitions_list, curr->gpt_part_info.type_guid, + UUID_STR_LEN + 1); +#endif strcat(partitions_list, ",uuid="); strncat(partitions_list, curr->gpt_part_info.uuid, UUID_STR_LEN + 1); |