summaryrefslogtreecommitdiff
path: root/src/boot/efi
diff options
context:
space:
mode:
authorSpencer Michaels <sxmichaels@gmail.com>2019-11-05 21:28:05 -0800
committerSpencer Michaels <sxmichaels@gmail.com>2019-11-18 22:59:51 -0800
commit10d0024a07c8a919a5637c1295d26145fde7cd56 (patch)
tree8cce3059bc782973809faa721505eba96207140a /src/boot/efi
parent6cd12ebcfe459466257ea63022a32515d756e719 (diff)
downloadsystemd-10d0024a07c8a919a5637c1295d26145fde7cd56.tar.gz
boot: Improve EFISTUB name and version detection.
Make two minor cosmetic changes to how config_entry_add_linux() extracts OS information from the embedded /etc/os-release in EFISTUB binaries. This increases the detail of information available to the user for EFISTUB entries. * entry->version, which was previously always null, is now set to the value of VERSION, or VERSION_ID, or BUILD_ID (preferred in that order). * entry->title, which was previously set to the value of PRETTY_NAME, can now fall back to NAME or ID if PRETTY_NAME is not present. In that case, NAME is preferred over ID.
Diffstat (limited to 'src/boot/efi')
-rw-r--r--src/boot/efi/boot.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c
index f6989ddb9b..e86824ad31 100644
--- a/src/boot/efi/boot.c
+++ b/src/boot/efi/boot.c
@@ -1770,7 +1770,8 @@ static ConfigEntry *config_entry_add_loader(
CHAR16 *id,
CHAR16 key,
CHAR16 *title,
- CHAR16 *loader) {
+ CHAR16 *loader,
+ CHAR16 *version) {
ConfigEntry *entry;
@@ -1778,6 +1779,7 @@ static ConfigEntry *config_entry_add_loader(
*entry = (ConfigEntry) {
.type = type,
.title = StrDuplicate(title),
+ .version = StrDuplicate(version),
.device = device,
.loader = StrDuplicate(loader),
.id = StrDuplicate(id),
@@ -1835,7 +1837,7 @@ static BOOLEAN config_entry_add_loader_auto(
return FALSE;
uefi_call_wrapper(handle->Close, 1, handle);
- entry = config_entry_add_loader(config, device, LOADER_UNDEFINED, id, key, title, loader);
+ entry = config_entry_add_loader(config, device, LOADER_UNDEFINED, id, key, title, loader, NULL);
if (!entry)
return FALSE;
@@ -1903,10 +1905,12 @@ static VOID config_entry_add_linux(
CHAR8 *line;
UINTN pos = 0;
CHAR8 *key, *value;
+ CHAR16 *os_name_pretty = NULL;
CHAR16 *os_name = NULL;
CHAR16 *os_id = NULL;
CHAR16 *os_version = NULL;
- CHAR16 *os_build = NULL;
+ CHAR16 *os_version_id = NULL;
+ CHAR16 *os_build_id = NULL;
err = uefi_call_wrapper(linux_dir->Read, 3, linux_dir, &bufsize, buf);
if (bufsize == 0 || EFI_ERROR(err))
@@ -1937,6 +1941,12 @@ static VOID config_entry_add_linux(
/* read properties from the embedded os-release file */
while ((line = line_get_key_value(content, (CHAR8 *)"=", &pos, &key, &value))) {
if (strcmpa((CHAR8 *)"PRETTY_NAME", key) == 0) {
+ FreePool(os_name_pretty);
+ os_name_pretty = stra_to_str(value);
+ continue;
+ }
+
+ if (strcmpa((CHAR8 *)"NAME", key) == 0) {
FreePool(os_name);
os_name = stra_to_str(value);
continue;
@@ -1954,19 +1964,27 @@ static VOID config_entry_add_linux(
continue;
}
+ if (strcmpa((CHAR8 *)"VERSION_ID", key) == 0) {
+ FreePool(os_version_id);
+ os_version_id = stra_to_str(value);
+ continue;
+ }
+
if (strcmpa((CHAR8 *)"BUILD_ID", key) == 0) {
- FreePool(os_build);
- os_build = stra_to_str(value);
+ FreePool(os_build_id);
+ os_build_id = stra_to_str(value);
continue;
}
}
- if (os_name && os_id && (os_version || os_build)) {
+ if ((os_name_pretty || os_name) && os_id && (os_version || os_version_id || os_build_id)) {
_cleanup_freepool_ CHAR16 *path = NULL;
path = PoolPrint(L"\\EFI\\Linux\\%s", f->FileName);
- entry = config_entry_add_loader(config, device, LOADER_LINUX, f->FileName, 'l', os_name, path);
+ entry = config_entry_add_loader(config, device, LOADER_LINUX, f->FileName, 'l',
+ os_name_pretty ? : (os_name ? : os_id), path,
+ os_version ? : (os_version_id ? : os_build_id));
FreePool(content);
content = NULL;
@@ -1985,10 +2003,12 @@ static VOID config_entry_add_linux(
config_entry_parse_tries(entry, L"\\EFI\\Linux", f->FileName, L".efi");
}
+ FreePool(os_name_pretty);
FreePool(os_name);
FreePool(os_id);
FreePool(os_version);
- FreePool(os_build);
+ FreePool(os_version_id);
+ FreePool(os_build_id);
FreePool(content);
}