[PATCH 06/16] efi: add helper to get the GPT partition UUID for a device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Michael Olbrich <m.olbrich@xxxxxxxxxxxxxx>
---
v2: use xasprintf()

 common/efi-devicepath.c | 30 ++++++++++++++++++++++++++++++
 include/efi.h           |  1 +
 2 files changed, 31 insertions(+)

diff --git a/common/efi-devicepath.c b/common/efi-devicepath.c
index a53c6d2e8b9b..a1cd0952f929 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("%pU)", (efi_guid_t *)&(hd->signature[0]));
+		break;
+	}
+
+	return str;
+}
+
diff --git a/include/efi.h b/include/efi.h
index e79a407bc2c8..b6ee42b3fd49 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -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);
 
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux