Skip to content

Commit

Permalink
efi: add helper to get the GPT partition UUID for a device
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Olbrich <[email protected]>
Signed-off-by: Sascha Hauer <[email protected]>
  • Loading branch information
michaelolbrich authored and saschahauer committed Jul 27, 2015
1 parent 55da0cf commit be2edd9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
30 changes: 30 additions & 0 deletions common/efi-devicepath.c
Original file line number Diff line number Diff line change
Expand Up @@ -1383,3 +1383,33 @@ u8 device_path_to_type(struct efi_device_path *dev_path)

return device_path_type(dev_path);
}

char *device_path_to_partuuid(struct efi_device_path *dev_path)
{
struct efi_device_path *dev_path_node;
struct harddrive_device_path *hd;
char *str = NULL;;

dev_path = unpack_device_path(dev_path);

for (dev_path_node = dev_path; !is_device_path_end(dev_path_node);
dev_path_node = next_device_path_node(dev_path_node)) {

if (device_path_type(dev_path_node) != MEDIA_DEVICE_PATH)
continue;

if (dev_path_node->sub_type != MEDIA_HARDDRIVE_DP)
continue;

hd = (struct harddrive_device_path *)dev_path_node;

if (hd->signature_type != SIGNATURE_TYPE_GUID)
continue;

str = xasprintf("%pUl", (efi_guid_t *)&(hd->signature[0]));
break;
}

return str;
}

1 change: 1 addition & 0 deletions include/efi.h
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ static inline int efi_compare_guid(efi_guid_t *a, efi_guid_t *b)

char *device_path_to_str(struct efi_device_path *dev_path);
u8 device_path_to_type(struct efi_device_path *dev_path);
char *device_path_to_partuuid(struct efi_device_path *dev_path);

const char *efi_guid_string(efi_guid_t *g);

Expand Down

0 comments on commit be2edd9

Please sign in to comment.