You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
317 lines
16 KiB
317 lines
16 KiB
6 months ago
|
From 4280dc5179071758294e661600b37e3d5c7658c9 Mon Sep 17 00:00:00 2001
|
||
|
From: Jan Janssen <medhefgo@web.de>
|
||
|
Date: Fri, 9 Dec 2022 11:15:41 +0100
|
||
|
Subject: [PATCH] boot: Use unicode literals
|
||
|
|
||
|
No changes in behavior.
|
||
|
|
||
|
(cherry picked from commit a083aed03fc4a2bf64b2c41df508a47e3ceba91c)
|
||
|
|
||
|
Related: RHEL-16952
|
||
|
---
|
||
|
src/boot/efi/boot.c | 54 +++++++++++++++++++-------------------
|
||
|
src/boot/efi/drivers.c | 4 +--
|
||
|
src/boot/efi/random-seed.c | 2 +-
|
||
|
src/boot/efi/stub.c | 18 ++++++-------
|
||
|
4 files changed, 39 insertions(+), 39 deletions(-)
|
||
|
|
||
|
diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c
|
||
|
index 385cfd563a..a39c356158 100644
|
||
|
--- a/src/boot/efi/boot.c
|
||
|
+++ b/src/boot/efi/boot.c
|
||
|
@@ -427,7 +427,7 @@ static bool unicode_supported(void) {
|
||
|
if (cache < 0)
|
||
|
/* Basic unicode box drawing support is mandated by the spec, but it does
|
||
|
* not hurt to make sure it works. */
|
||
|
- cache = ST->ConOut->TestString(ST->ConOut, (char16_t *) L"─") == EFI_SUCCESS;
|
||
|
+ cache = ST->ConOut->TestString(ST->ConOut, (char16_t *) u"─") == EFI_SUCCESS;
|
||
|
|
||
|
return cache;
|
||
|
}
|
||
|
@@ -728,7 +728,7 @@ static bool menu_run(
|
||
|
print_at(x_start,
|
||
|
y_start + i - idx_first,
|
||
|
i == idx_highlight ? COLOR_HIGHLIGHT : COLOR_ENTRY,
|
||
|
- unicode_supported() ? L" ►" : L"=>");
|
||
|
+ unicode_supported() ? u" ►" : u"=>");
|
||
|
}
|
||
|
refresh = false;
|
||
|
} else if (highlight) {
|
||
|
@@ -738,12 +738,12 @@ static bool menu_run(
|
||
|
print_at(x_start,
|
||
|
y_start + idx_highlight_prev - idx_first,
|
||
|
COLOR_ENTRY,
|
||
|
- unicode_supported() ? L" ►" : L"=>");
|
||
|
+ unicode_supported() ? u" ►" : u"=>");
|
||
|
if (idx_highlight == config->idx_default_efivar)
|
||
|
print_at(x_start,
|
||
|
y_start + idx_highlight - idx_first,
|
||
|
COLOR_HIGHLIGHT,
|
||
|
- unicode_supported() ? L" ►" : L"=>");
|
||
|
+ unicode_supported() ? u" ►" : u"=>");
|
||
|
highlight = false;
|
||
|
}
|
||
|
|
||
|
@@ -1504,7 +1504,7 @@ static void config_entry_add_type1(
|
||
|
|
||
|
config_add_entry(config, entry);
|
||
|
|
||
|
- config_entry_parse_tries(entry, path, file, L".conf");
|
||
|
+ config_entry_parse_tries(entry, path, file, u".conf");
|
||
|
TAKE_PTR(entry);
|
||
|
}
|
||
|
|
||
|
@@ -1556,7 +1556,7 @@ static void config_load_defaults(Config *config, EFI_FILE *root_dir) {
|
||
|
.timeout_sec_efivar = TIMEOUT_UNSET,
|
||
|
};
|
||
|
|
||
|
- err = file_read(root_dir, L"\\loader\\loader.conf", 0, 0, &content, NULL);
|
||
|
+ err = file_read(root_dir, u"\\loader\\loader.conf", 0, 0, &content, NULL);
|
||
|
if (err == EFI_SUCCESS)
|
||
|
config_defaults_load_from_file(config, content);
|
||
|
|
||
|
@@ -1591,8 +1591,8 @@ static void config_load_defaults(Config *config, EFI_FILE *root_dir) {
|
||
|
strtolower16(config->entry_oneshot);
|
||
|
strtolower16(config->entry_saved);
|
||
|
|
||
|
- config->use_saved_entry = streq16(config->entry_default_config, L"@saved");
|
||
|
- config->use_saved_entry_efivar = streq16(config->entry_default_efivar, L"@saved");
|
||
|
+ config->use_saved_entry = streq16(config->entry_default_config, u"@saved");
|
||
|
+ config->use_saved_entry_efivar = streq16(config->entry_default_efivar, u"@saved");
|
||
|
if (config->use_saved_entry || config->use_saved_entry_efivar)
|
||
|
(void) efivar_get(LOADER_GUID, L"LoaderEntryLastBooted", &config->entry_saved);
|
||
|
}
|
||
|
@@ -1614,7 +1614,7 @@ static void config_load_entries(
|
||
|
|
||
|
/* Adds Boot Loader Type #1 entries (i.e. /loader/entries/….conf) */
|
||
|
|
||
|
- err = open_directory(root_dir, L"\\loader\\entries", &entries_dir);
|
||
|
+ err = open_directory(root_dir, u"\\loader\\entries", &entries_dir);
|
||
|
if (err != EFI_SUCCESS)
|
||
|
return;
|
||
|
|
||
|
@@ -1630,14 +1630,14 @@ static void config_load_entries(
|
||
|
if (FLAGS_SET(f->Attribute, EFI_FILE_DIRECTORY))
|
||
|
continue;
|
||
|
|
||
|
- if (!endswith_no_case(f->FileName, L".conf"))
|
||
|
+ if (!endswith_no_case(f->FileName, u".conf"))
|
||
|
continue;
|
||
|
- if (startswith(f->FileName, L"auto-"))
|
||
|
+ if (startswith(f->FileName, u"auto-"))
|
||
|
continue;
|
||
|
|
||
|
err = file_read(entries_dir, f->FileName, 0, 0, &content, NULL);
|
||
|
if (err == EFI_SUCCESS)
|
||
|
- config_entry_add_type1(config, device, root_dir, L"\\loader\\entries", f->FileName, content, loaded_image_path);
|
||
|
+ config_entry_add_type1(config, device, root_dir, u"\\loader\\entries", f->FileName, content, loaded_image_path);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@@ -1876,7 +1876,7 @@ static ConfigEntry *config_entry_add_loader_auto(
|
||
|
return NULL;
|
||
|
|
||
|
if (!loader) {
|
||
|
- loader = L"\\EFI\\BOOT\\BOOT" EFI_MACHINE_TYPE_NAME ".efi";
|
||
|
+ loader = u"\\EFI\\BOOT\\BOOT" EFI_MACHINE_TYPE_NAME ".efi";
|
||
|
|
||
|
/* We are trying to add the default EFI loader here,
|
||
|
* but we do not want to do that if that would be us.
|
||
|
@@ -1885,7 +1885,7 @@ static ConfigEntry *config_entry_add_loader_auto(
|
||
|
* chainload GRUBX64.EFI in that case, which might be us.*/
|
||
|
if (strcaseeq16(loader, loaded_image_path) ||
|
||
|
is_sd_boot(root_dir, loader) ||
|
||
|
- is_sd_boot(root_dir, L"\\EFI\\BOOT\\GRUB" EFI_MACHINE_TYPE_NAME L".EFI"))
|
||
|
+ is_sd_boot(root_dir, u"\\EFI\\BOOT\\GRUB" EFI_MACHINE_TYPE_NAME u".EFI"))
|
||
|
return NULL;
|
||
|
}
|
||
|
|
||
|
@@ -1936,10 +1936,10 @@ static void config_entry_add_osx(Config *config) {
|
||
|
handles[i],
|
||
|
root,
|
||
|
NULL,
|
||
|
- L"auto-osx",
|
||
|
+ u"auto-osx",
|
||
|
'a',
|
||
|
- L"macOS",
|
||
|
- L"\\System\\Library\\CoreServices\\boot.efi"))
|
||
|
+ u"macOS",
|
||
|
+ u"\\System\\Library\\CoreServices\\boot.efi"))
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
@@ -2008,7 +2008,7 @@ static EFI_STATUS boot_windows_bitlocker(void) {
|
||
|
if (buf_size < offset + sizeof(char16_t))
|
||
|
continue;
|
||
|
|
||
|
- if (streq16((char16_t *) (buf + offset), L"Windows Boot Manager")) {
|
||
|
+ if (streq16((char16_t *) (buf + offset), u"Windows Boot Manager")) {
|
||
|
err = efivar_set_raw(
|
||
|
EFI_GLOBAL_GUID,
|
||
|
L"BootNext",
|
||
|
@@ -2040,13 +2040,13 @@ static void config_entry_add_windows(Config *config, EFI_HANDLE *device, EFI_FIL
|
||
|
return;
|
||
|
|
||
|
/* Try to find a better title. */
|
||
|
- err = file_read(root_dir, L"\\EFI\\Microsoft\\Boot\\BCD", 0, 100*1024, &bcd, &len);
|
||
|
+ err = file_read(root_dir, u"\\EFI\\Microsoft\\Boot\\BCD", 0, 100*1024, &bcd, &len);
|
||
|
if (err == EFI_SUCCESS)
|
||
|
title = get_bcd_title((uint8_t *) bcd, len);
|
||
|
|
||
|
ConfigEntry *e = config_entry_add_loader_auto(config, device, root_dir, NULL,
|
||
|
- L"auto-windows", 'w', title ?: L"Windows Boot Manager",
|
||
|
- L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi");
|
||
|
+ u"auto-windows", 'w', title ?: u"Windows Boot Manager",
|
||
|
+ u"\\EFI\\Microsoft\\Boot\\bootmgfw.efi");
|
||
|
|
||
|
if (config->reboot_for_bitlocker)
|
||
|
e->call = boot_windows_bitlocker;
|
||
|
@@ -2069,7 +2069,7 @@ static void config_entry_add_unified(
|
||
|
assert(device);
|
||
|
assert(root_dir);
|
||
|
|
||
|
- err = open_directory(root_dir, L"\\EFI\\Linux", &linux_dir);
|
||
|
+ err = open_directory(root_dir, u"\\EFI\\Linux", &linux_dir);
|
||
|
if (err != EFI_SUCCESS)
|
||
|
return;
|
||
|
|
||
|
@@ -2101,9 +2101,9 @@ static void config_entry_add_unified(
|
||
|
continue;
|
||
|
if (FLAGS_SET(f->Attribute, EFI_FILE_DIRECTORY))
|
||
|
continue;
|
||
|
- if (!endswith_no_case(f->FileName, L".efi"))
|
||
|
+ if (!endswith_no_case(f->FileName, u".efi"))
|
||
|
continue;
|
||
|
- if (startswith(f->FileName, L"auto-"))
|
||
|
+ if (startswith(f->FileName, u"auto-"))
|
||
|
continue;
|
||
|
|
||
|
/* look for .osrel and .cmdline sections in the .efi binary */
|
||
|
@@ -2196,7 +2196,7 @@ static void config_entry_add_unified(
|
||
|
|
||
|
strtolower16(entry->id);
|
||
|
config_add_entry(config, entry);
|
||
|
- config_entry_parse_tries(entry, L"\\EFI\\Linux", f->FileName, L".efi");
|
||
|
+ config_entry_parse_tries(entry, u"\\EFI\\Linux", f->FileName, u".efi");
|
||
|
|
||
|
if (szs[SECTION_CMDLINE] == 0)
|
||
|
continue;
|
||
|
@@ -2571,9 +2571,9 @@ static void config_load_all_entries(
|
||
|
config_entry_add_osx(config);
|
||
|
config_entry_add_windows(config, loaded_image->DeviceHandle, root_dir);
|
||
|
config_entry_add_loader_auto(config, loaded_image->DeviceHandle, root_dir, NULL,
|
||
|
- L"auto-efi-shell", 's', L"EFI Shell", L"\\shell" EFI_MACHINE_TYPE_NAME ".efi");
|
||
|
+ u"auto-efi-shell", 's', u"EFI Shell", u"\\shell" EFI_MACHINE_TYPE_NAME ".efi");
|
||
|
config_entry_add_loader_auto(config, loaded_image->DeviceHandle, root_dir, loaded_image_path,
|
||
|
- L"auto-efi-default", '\0', L"EFI Default Loader", NULL);
|
||
|
+ u"auto-efi-default", '\0', u"EFI Default Loader", NULL);
|
||
|
|
||
|
if (config->auto_firmware && FLAGS_SET(get_os_indications_supported(), EFI_OS_INDICATIONS_BOOT_TO_FW_UI)) {
|
||
|
ConfigEntry *entry = xnew(ConfigEntry, 1);
|
||
|
diff --git a/src/boot/efi/drivers.c b/src/boot/efi/drivers.c
|
||
|
index c073e1a4f2..41a7d8fe15 100644
|
||
|
--- a/src/boot/efi/drivers.c
|
||
|
+++ b/src/boot/efi/drivers.c
|
||
|
@@ -82,7 +82,7 @@ EFI_STATUS load_drivers(
|
||
|
|
||
|
err = open_directory(
|
||
|
root_dir,
|
||
|
- L"\\EFI\\systemd\\drivers",
|
||
|
+ u"\\EFI\\systemd\\drivers",
|
||
|
&drivers_dir);
|
||
|
if (err == EFI_NOT_FOUND)
|
||
|
return EFI_SUCCESS;
|
||
|
@@ -100,7 +100,7 @@ EFI_STATUS load_drivers(
|
||
|
continue;
|
||
|
if (FLAGS_SET(dirent->Attribute, EFI_FILE_DIRECTORY))
|
||
|
continue;
|
||
|
- if (!endswith_no_case(dirent->FileName, EFI_MACHINE_TYPE_NAME L".efi"))
|
||
|
+ if (!endswith_no_case(dirent->FileName, EFI_MACHINE_TYPE_NAME u".efi"))
|
||
|
continue;
|
||
|
|
||
|
err = load_one_driver(parent_image, loaded_image, dirent->FileName);
|
||
|
diff --git a/src/boot/efi/random-seed.c b/src/boot/efi/random-seed.c
|
||
|
index 5d7459d87e..a52934a901 100644
|
||
|
--- a/src/boot/efi/random-seed.c
|
||
|
+++ b/src/boot/efi/random-seed.c
|
||
|
@@ -196,7 +196,7 @@ EFI_STATUS process_random_seed(EFI_FILE *root_dir) {
|
||
|
err = root_dir->Open(
|
||
|
root_dir,
|
||
|
&handle,
|
||
|
- (char16_t *) L"\\loader\\random-seed",
|
||
|
+ (char16_t *) u"\\loader\\random-seed",
|
||
|
EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE,
|
||
|
0);
|
||
|
if (err != EFI_SUCCESS) {
|
||
|
diff --git a/src/boot/efi/stub.c b/src/boot/efi/stub.c
|
||
|
index e3b97164a8..433fef548c 100644
|
||
|
--- a/src/boot/efi/stub.c
|
||
|
+++ b/src/boot/efi/stub.c
|
||
|
@@ -286,27 +286,27 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
|
||
|
|
||
|
if (pack_cpio(loaded_image,
|
||
|
NULL,
|
||
|
- L".cred",
|
||
|
+ u".cred",
|
||
|
".extra/credentials",
|
||
|
/* dir_mode= */ 0500,
|
||
|
/* access_mode= */ 0400,
|
||
|
/* tpm_pcr= */ (uint32_t[]) { TPM_PCR_INDEX_KERNEL_PARAMETERS, TPM_PCR_INDEX_KERNEL_PARAMETERS_COMPAT },
|
||
|
/* n_tpm_pcr= */ 2,
|
||
|
- L"Credentials initrd",
|
||
|
+ u"Credentials initrd",
|
||
|
&credential_initrd,
|
||
|
&credential_initrd_size,
|
||
|
&m) == EFI_SUCCESS)
|
||
|
parameters_measured = parameters_measured < 0 ? m : (parameters_measured && m);
|
||
|
|
||
|
if (pack_cpio(loaded_image,
|
||
|
- L"\\loader\\credentials",
|
||
|
- L".cred",
|
||
|
+ u"\\loader\\credentials",
|
||
|
+ u".cred",
|
||
|
".extra/global_credentials",
|
||
|
/* dir_mode= */ 0500,
|
||
|
/* access_mode= */ 0400,
|
||
|
/* tpm_pcr= */ (uint32_t[]) { TPM_PCR_INDEX_KERNEL_PARAMETERS, TPM_PCR_INDEX_KERNEL_PARAMETERS_COMPAT },
|
||
|
/* n_tpm_pcr= */ 2,
|
||
|
- L"Global credentials initrd",
|
||
|
+ u"Global credentials initrd",
|
||
|
&global_credential_initrd,
|
||
|
&global_credential_initrd_size,
|
||
|
&m) == EFI_SUCCESS)
|
||
|
@@ -314,13 +314,13 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
|
||
|
|
||
|
if (pack_cpio(loaded_image,
|
||
|
NULL,
|
||
|
- L".raw",
|
||
|
+ u".raw",
|
||
|
".extra/sysext",
|
||
|
/* dir_mode= */ 0555,
|
||
|
/* access_mode= */ 0444,
|
||
|
/* tpm_pcr= */ (uint32_t[]) { TPM_PCR_INDEX_INITRD_SYSEXTS },
|
||
|
/* n_tpm_pcr= */ 1,
|
||
|
- L"System extension initrd",
|
||
|
+ u"System extension initrd",
|
||
|
&sysext_initrd,
|
||
|
&sysext_initrd_size,
|
||
|
&m) == EFI_SUCCESS)
|
||
|
@@ -341,7 +341,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
|
||
|
(uint8_t*) loaded_image->ImageBase + addrs[UNIFIED_SECTION_PCRSIG],
|
||
|
szs[UNIFIED_SECTION_PCRSIG],
|
||
|
".extra",
|
||
|
- L"tpm2-pcr-signature.json",
|
||
|
+ u"tpm2-pcr-signature.json",
|
||
|
/* dir_mode= */ 0555,
|
||
|
/* access_mode= */ 0444,
|
||
|
/* tpm_pcr= */ NULL,
|
||
|
@@ -360,7 +360,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
|
||
|
(uint8_t*) loaded_image->ImageBase + addrs[UNIFIED_SECTION_PCRPKEY],
|
||
|
szs[UNIFIED_SECTION_PCRPKEY],
|
||
|
".extra",
|
||
|
- L"tpm2-pcr-public-key.pem",
|
||
|
+ u"tpm2-pcr-public-key.pem",
|
||
|
/* dir_mode= */ 0555,
|
||
|
/* access_mode= */ 0444,
|
||
|
/* tpm_pcr= */ NULL,
|