mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Michael Olbrich <m.olbrich@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Michael Olbrich <m.olbrich@pengutronix.de>
Subject: [PATCH 06/16] efi: add helper to get the GPT partition UUID for a device
Date: Fri, 17 Jul 2015 21:22:39 +0200	[thread overview]
Message-ID: <1437160969-31517-7-git-send-email-m.olbrich@pengutronix.de> (raw)
In-Reply-To: <1437160969-31517-1-git-send-email-m.olbrich@pengutronix.de>

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
---
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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2015-07-17 19:23 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-17 19:22 [PATCHv2 00/16] EFI updates Michael Olbrich
2015-07-17 19:22 ` [PATCH 01/16] xfuncs: add xasprintf() and xvasprintf() Michael Olbrich
2015-07-17 19:22 ` [PATCH 02/16] xfuncs: add wrapper for wchar strdup functions Michael Olbrich
2015-07-17 19:22 ` [PATCH 03/16] efi: improve malloc pool allocation Michael Olbrich
2015-07-17 19:22 ` [PATCH 04/16] efi: refactor & improve application loading code Michael Olbrich
2015-07-17 19:22 ` [PATCH 05/16] efi: add support for initrd loading Michael Olbrich
2015-07-17 19:22 ` Michael Olbrich [this message]
2015-07-17 19:22 ` [PATCH 07/16] efi: export device_path_from_handle() Michael Olbrich
2015-07-17 19:22 ` [PATCH 08/16] efi: add helper functions to write EFI variables Michael Olbrich
2015-07-17 19:22 ` [PATCH 09/16] efi: write volatile EFI variables used by systemd Michael Olbrich
2015-07-17 19:22 ` [PATCH 10/16] efi: use xasprintf() when appropriate Michael Olbrich
2015-07-17 19:22 ` [PATCH 11/16] efi: use xstrdup_* " Michael Olbrich
2015-07-17 19:22 ` [PATCH 12/16] fs: " Michael Olbrich
2015-07-17 19:22 ` [PATCH 13/16] fs: efivars: " Michael Olbrich
2015-07-17 19:22 ` [PATCH 14/16] fs: efivars: add more error checking Michael Olbrich
2015-07-17 19:22 ` [PATCH 15/16] fs: efivars: read the attributes on the second get_variable() Michael Olbrich
2015-07-17 19:22 ` [PATCH 16/16] efi: use an EFI variable to save the environment Michael Olbrich
2015-07-20  5:26 ` [PATCHv2 00/16] EFI updates Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1437160969-31517-7-git-send-email-m.olbrich@pengutronix.de \
    --to=m.olbrich@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox