summaryrefslogtreecommitdiff
path: root/src/shared
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
parent34e5a31ec5897de8ba1436dad53df99637569d0a (diff)
efi: add efi boot generator that automatically mounts the ESP to /boot
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/efivars.c30
-rw-r--r--src/shared/efivars.h4
2 files changed, 34 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;
+}
diff --git a/src/shared/efivars.h b/src/shared/efivars.h
index 120f3c7a6a..d5cfb4fa0d 100644
--- a/src/shared/efivars.h
+++ b/src/shared/efivars.h
@@ -23,11 +23,15 @@
#include <sys/types.h>
#include <inttypes.h>
+#include <stdbool.h>
#include "sd-id128.h"
+#include "time-util.h"
bool is_efiboot(void);
int efi_get_variable(sd_id128_t vendor, const char *name, uint32_t *attribute, void **value, size_t *size);
int efi_get_boot_timestamps(const dual_timestamp *n, dual_timestamp *firmware, dual_timestamp *loader);
+
+int efi_get_loader_device_part_uuid(sd_id128_t *u);