efi: add efi boot generator that automatically mounts the ESP to /boot

This commit is contained in:
Lennart Poettering
2013-01-21 01:04:16 +01:00
parent 34e5a31ec5
commit f4ce2b3e5c
6 changed files with 163 additions and 1 deletions
+30
View File
@@ -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;
}
+4
View File
@@ -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);