gpt: move gpt guid printing function to common library
This commit is contained in:
parent
b97f2fa47e
commit
13761c8675
3 changed files with 19 additions and 14 deletions
|
@ -141,20 +141,8 @@ grub_find_next (const char *disk_name,
|
||||||
if (!*part_name)
|
if (!*part_name)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
*part_guid =
|
*part_guid = grub_gpt_guid_to_str (&part_found->guid);
|
||||||
grub_xasprintf ("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
if (!*part_guid)
|
||||||
grub_le_to_cpu32 (part_found->guid.data1),
|
|
||||||
grub_le_to_cpu16 (part_found->guid.data2),
|
|
||||||
grub_le_to_cpu16 (part_found->guid.data3),
|
|
||||||
part_found->guid.data4[0],
|
|
||||||
part_found->guid.data4[1],
|
|
||||||
part_found->guid.data4[2],
|
|
||||||
part_found->guid.data4[3],
|
|
||||||
part_found->guid.data4[4],
|
|
||||||
part_found->guid.data4[5],
|
|
||||||
part_found->guid.data4[6],
|
|
||||||
part_found->guid.data4[7]);
|
|
||||||
if (!*part_name)
|
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
grub_errno = GRUB_ERR_NONE;
|
grub_errno = GRUB_ERR_NONE;
|
||||||
|
|
|
@ -31,6 +31,19 @@ GRUB_MOD_LICENSE ("GPLv3+");
|
||||||
static grub_uint8_t grub_gpt_magic[] = GRUB_GPT_HEADER_MAGIC;
|
static grub_uint8_t grub_gpt_magic[] = GRUB_GPT_HEADER_MAGIC;
|
||||||
|
|
||||||
|
|
||||||
|
char *
|
||||||
|
grub_gpt_guid_to_str (grub_gpt_guid_t *guid)
|
||||||
|
{
|
||||||
|
return grub_xasprintf ("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||||
|
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]);
|
||||||
|
}
|
||||||
|
|
||||||
static grub_uint64_t
|
static grub_uint64_t
|
||||||
grub_gpt_size_to_sectors (grub_gpt_t gpt, grub_size_t size)
|
grub_gpt_size_to_sectors (grub_gpt_t gpt, grub_size_t size)
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,6 +33,10 @@ struct grub_gpt_guid
|
||||||
typedef struct grub_gpt_guid grub_gpt_guid_t;
|
typedef struct grub_gpt_guid grub_gpt_guid_t;
|
||||||
typedef struct grub_gpt_guid grub_gpt_part_type_t;
|
typedef struct grub_gpt_guid grub_gpt_part_type_t;
|
||||||
|
|
||||||
|
/* Format the raw little-endian GUID as a newly allocated string. */
|
||||||
|
char * grub_gpt_guid_to_str (grub_gpt_guid_t *guid);
|
||||||
|
|
||||||
|
|
||||||
#define GRUB_GPT_GUID_INIT(a, b, c, d1, d2, d3, d4, d5, d6, d7, d8) \
|
#define GRUB_GPT_GUID_INIT(a, b, c, d1, d2, d3, d4, d5, d6, d7, d8) \
|
||||||
{ \
|
{ \
|
||||||
grub_cpu_to_le32_compile_time (a), \
|
grub_cpu_to_le32_compile_time (a), \
|
||||||
|
|
Loading…
Reference in a new issue