summaryrefslogtreecommitdiffstats
path: root/common/efi-devicepath.c
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2015-07-17 21:22:39 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2015-07-27 07:23:17 +0200
commitbe2edd99c02c3790ae3f1d5c2e109d66df0c28a3 (patch)
tree2ee7c8b5051105c3a27476aae3c34cc75515cb7f /common/efi-devicepath.c
parent55da0cf13eda4a29ce6d2aa58b3de6448a806e9e (diff)
downloadbarebox-be2edd99c02c3790ae3f1d5c2e109d66df0c28a3.tar.gz
efi: add helper to get the GPT partition UUID for a device
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/efi-devicepath.c')
-rw-r--r--common/efi-devicepath.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/common/efi-devicepath.c b/common/efi-devicepath.c
index a53c6d2..54c2f4e 100644
--- a/common/efi-devicepath.c
+++ b/common/efi-devicepath.c
@@ -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;
+}
+