Code to print gpt patition guids has been duplicated in multiple places. Add a common function for that.
Signed-off-by: Oliver Steffen <ostef...@redhat.com> --- grub-core/partmap/gpt.c | 13 +++++++++++++ include/grub/gpt_partition.h | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/grub-core/partmap/gpt.c b/grub-core/partmap/gpt.c index 075cc96f1..e0da7e885 100644 --- a/grub-core/partmap/gpt.c +++ b/grub-core/partmap/gpt.c @@ -227,6 +227,19 @@ static struct grub_partition_map grub_gpt_partition_map = #endif }; +int +grub_gpt_part_guid_snprint (char *str, grub_size_t n, const grub_gpt_part_guid_t *guid) +{ + return grub_snprintf (str, n, + GRUB_PRIxGPT_GUID, + grub_le_to_cpu32 (guid->data1), + grub_le_to_cpu16 (guid->data2), + grub_le_to_cpu16 (guid->data3), + guid->data4[0], guid->data4[1], guid->data4[2], + guid->data4[3], guid->data4[4], guid->data4[5], + guid->data4[6], guid->data4[7]); +} + GRUB_MOD_INIT(part_gpt) { grub_partition_map_register (&grub_gpt_partition_map); diff --git a/include/grub/gpt_partition.h b/include/grub/gpt_partition.h index 7a93f4329..9b1660322 100644 --- a/include/grub/gpt_partition.h +++ b/include/grub/gpt_partition.h @@ -50,6 +50,9 @@ typedef struct grub_gpt_part_guid grub_gpt_part_guid_t; { 0x85, 0xD2, 0xE1, 0xE9, 0x04, 0x34, 0xCF, 0xB3 } \ } +#define GRUB_PRIxGPT_GUID "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x" +#define GRUB_GPT_GUID_STR_LEN 36 + struct grub_gpt_header { grub_uint8_t magic[8]; @@ -83,5 +86,8 @@ grub_gpt_partition_map_iterate (grub_disk_t disk, grub_partition_iterate_hook_t hook, void *hook_data); +int +grub_gpt_part_guid_snprint (char *str, grub_size_t n, + const grub_gpt_part_guid_t *guid); #endif /* ! GRUB_GPT_PARTITION_HEADER */ -- 2.39.2 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel