summaryrefslogtreecommitdiff
path: root/src/shared/efivars.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-01-21 01:02:53 +0100
committerLennart Poettering <lennart@poettering.net>2013-01-21 01:04:16 +0100
commitf4ce2b3e5ce93b83f14f8785e205ebb5a9b8c1df (patch)
tree144cbcadc5d1dc8fe0e15952d68bc19e4270de95 /src/shared/efivars.c
parent34e5a31ec5897de8ba1436dad53df99637569d0a (diff)
efi: add efi boot generator that automatically mounts the ESP to /boot
Diffstat (limited to 'src/shared/efivars.c')
-rw-r--r--src/shared/efivars.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/shared/efivars.c b/src/shared/efivars.c
index 784ff364d9..183d33c772 100644
--- a/src/shared/efivars.c
+++ b/src/shared/efivars.c
@@ -235,3 +235,33 @@ int efi_get_boot_timestamps(const dual_timestamp *n, dual_timestamp *firmware, d
return 0;
}
+
+int efi_get_loader_device_part_uuid(sd_id128_t *u) {
+ _cleanup_free_ void *s = NULL;
+ _cleanup_free_ char *p = NULL;
+ size_t ss;
+ int r, parsed[16];
+ unsigned i;
+
+ assert(u);
+
+ r = efi_get_variable(EFI_VENDOR_LOADER, "LoaderDevicePartUUID", NULL, &s, &ss);
+ if (r < 0)
+ return r;
+
+ p = utf16_to_utf8(s, ss);
+ if (!p)
+ return -ENOMEM;
+
+ if (sscanf(p, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ &parsed[0], &parsed[1], &parsed[2], &parsed[3],
+ &parsed[4], &parsed[5], &parsed[6], &parsed[7],
+ &parsed[8], &parsed[9], &parsed[10], &parsed[11],
+ &parsed[12], &parsed[13], &parsed[14], &parsed[15]) != 16)
+ return -EIO;
+
+ for (i = 0; i < ELEMENTSOF(parsed); i++)
+ u->bytes[i] = parsed[i];
+
+ return 0;
+}