mirror of
https://github.com/systemd/systemd.git
synced 2024-12-05 08:13:48 +08:00
boot: Use char
This also switches to _cleanup_free_. Otherwise no code changes.
This commit is contained in:
parent
3639d1b021
commit
07d0fde49e
@ -10,7 +10,6 @@
|
||||
# include "efi-string.h"
|
||||
# include "string-util-fundamental.h"
|
||||
|
||||
# define CHAR8 char
|
||||
# define UINTN size_t
|
||||
# define TEST_STATIC static
|
||||
#endif
|
||||
@ -66,7 +65,7 @@ typedef struct {
|
||||
uint32_t _pad3[7];
|
||||
uint16_t key_name_len;
|
||||
uint16_t _pad4;
|
||||
CHAR8 key_name[];
|
||||
char key_name[];
|
||||
} _packed_ Key;
|
||||
assert_cc(offsetof(Key, sig) == 0);
|
||||
assert_cc(offsetof(Key, subkeys_offset) == 28);
|
||||
@ -80,7 +79,7 @@ typedef struct {
|
||||
uint16_t n_entries;
|
||||
struct SubkeyFastEntry {
|
||||
uint32_t key_offset;
|
||||
CHAR8 name_hint[4];
|
||||
char name_hint[4];
|
||||
} _packed_ entries[];
|
||||
} _packed_ SubkeyFast;
|
||||
assert_cc(offsetof(SubkeyFast, sig) == 0);
|
||||
@ -94,7 +93,7 @@ typedef struct {
|
||||
uint32_t data_offset;
|
||||
uint32_t data_type;
|
||||
uint32_t _pad;
|
||||
CHAR8 name[];
|
||||
char name[];
|
||||
} _packed_ KeyValue;
|
||||
assert_cc(offsetof(KeyValue, sig) == 0);
|
||||
assert_cc(offsetof(KeyValue, name_len) == 2);
|
||||
@ -113,9 +112,9 @@ assert_cc(offsetof(KeyValue, name) == 20);
|
||||
((uint64_t) (offset) + offsetof(type, array) + \
|
||||
sizeof((type){}.array[0]) * (uint64_t) (array_len) >= (max))
|
||||
|
||||
static const Key *get_key(const uint8_t *bcd, uint32_t bcd_len, uint32_t offset, const CHAR8 *name);
|
||||
static const Key *get_key(const uint8_t *bcd, uint32_t bcd_len, uint32_t offset, const char *name);
|
||||
|
||||
static const Key *get_subkey(const uint8_t *bcd, uint32_t bcd_len, uint32_t offset, const CHAR8 *name) {
|
||||
static const Key *get_subkey(const uint8_t *bcd, uint32_t bcd_len, uint32_t offset, const char *name) {
|
||||
assert(bcd);
|
||||
assert(name);
|
||||
|
||||
@ -130,7 +129,7 @@ static const Key *get_subkey(const uint8_t *bcd, uint32_t bcd_len, uint32_t offs
|
||||
return NULL;
|
||||
|
||||
for (uint16_t i = 0; i < subkey->n_entries; i++) {
|
||||
if (!strncaseeq8((char *) name, (char *) subkey->entries[i].name_hint, sizeof(subkey->entries[i].name_hint)))
|
||||
if (!strncaseeq8(name, subkey->entries[i].name_hint, sizeof(subkey->entries[i].name_hint)))
|
||||
continue;
|
||||
|
||||
const Key *key = get_key(bcd, bcd_len, subkey->entries[i].key_offset, name);
|
||||
@ -144,7 +143,7 @@ static const Key *get_subkey(const uint8_t *bcd, uint32_t bcd_len, uint32_t offs
|
||||
/* We use NUL as registry path separators for convenience. To start from the root, begin
|
||||
* name with a NUL. Name must end with two NUL. The lookup depth is not restricted, so
|
||||
* name must be properly validated before calling get_key(). */
|
||||
static const Key *get_key(const uint8_t *bcd, uint32_t bcd_len, uint32_t offset, const CHAR8 *name) {
|
||||
static const Key *get_key(const uint8_t *bcd, uint32_t bcd_len, uint32_t offset, const char *name) {
|
||||
assert(bcd);
|
||||
assert(name);
|
||||
|
||||
@ -159,7 +158,7 @@ static const Key *get_key(const uint8_t *bcd, uint32_t bcd_len, uint32_t offset,
|
||||
return NULL;
|
||||
|
||||
if (*name) {
|
||||
if (strncaseeq8((char *) name, (char *) key->key_name, key->key_name_len) && strlen8((const char *) name) == key->key_name_len)
|
||||
if (strncaseeq8(name, key->key_name, key->key_name_len) && strlen8(name) == key->key_name_len)
|
||||
name += key->key_name_len;
|
||||
else
|
||||
return NULL;
|
||||
@ -169,7 +168,7 @@ static const Key *get_key(const uint8_t *bcd, uint32_t bcd_len, uint32_t offset,
|
||||
return *name ? get_subkey(bcd, bcd_len, key->subkeys_offset, name) : key;
|
||||
}
|
||||
|
||||
static const KeyValue *get_key_value(const uint8_t *bcd, uint32_t bcd_len, const Key *key, const CHAR8 *name) {
|
||||
static const KeyValue *get_key_value(const uint8_t *bcd, uint32_t bcd_len, const Key *key, const char *name) {
|
||||
assert(bcd);
|
||||
assert(key);
|
||||
assert(name);
|
||||
@ -204,7 +203,7 @@ static const KeyValue *get_key_value(const uint8_t *bcd, uint32_t bcd_len, const
|
||||
if (BAD_OFFSET(kv->data_offset, kv->data_size, bcd_len))
|
||||
continue;
|
||||
|
||||
if (strncaseeq8((char *)name, (char *) kv->name, kv->name_len) && strlen8((const char *) name) == kv->name_len)
|
||||
if (strncaseeq8(name, kv->name, kv->name_len) && strlen8(name) == kv->name_len)
|
||||
return kv;
|
||||
}
|
||||
|
||||
@ -245,28 +244,23 @@ TEST_STATIC char16_t *get_bcd_title(uint8_t *bcd, UINTN bcd_len) {
|
||||
bcd += HIVE_CELL_OFFSET;
|
||||
bcd_len -= HIVE_CELL_OFFSET;
|
||||
|
||||
const Key *objects_key = get_key(
|
||||
bcd, bcd_len,
|
||||
base_block->root_cell_offset,
|
||||
(const CHAR8 *) "\0Objects\0");
|
||||
const Key *objects_key = get_key(bcd, bcd_len, base_block->root_cell_offset, "\0Objects\0");
|
||||
if (!objects_key)
|
||||
return NULL;
|
||||
|
||||
const Key *displayorder_key = get_subkey(
|
||||
bcd, bcd_len,
|
||||
objects_key->subkeys_offset,
|
||||
(const CHAR8 *) "{9dea862c-5cdd-4e70-acc1-f32b344d4795}\0Elements\00024000001\0");
|
||||
bcd,
|
||||
bcd_len,
|
||||
objects_key->subkeys_offset,
|
||||
"{9dea862c-5cdd-4e70-acc1-f32b344d4795}\0Elements\00024000001\0");
|
||||
if (!displayorder_key)
|
||||
return NULL;
|
||||
|
||||
const KeyValue *displayorder_value = get_key_value(
|
||||
bcd, bcd_len,
|
||||
displayorder_key,
|
||||
(const CHAR8 *) "Element");
|
||||
const KeyValue *displayorder_value = get_key_value(bcd, bcd_len, displayorder_key, "Element");
|
||||
if (!displayorder_value)
|
||||
return NULL;
|
||||
|
||||
CHAR8 order_guid[sizeof("{00000000-0000-0000-0000-000000000000}\0")];
|
||||
char order_guid[sizeof("{00000000-0000-0000-0000-000000000000}\0")];
|
||||
if (displayorder_value->data_type != REG_MULTI_SZ ||
|
||||
displayorder_value->data_size != sizeof(char16_t[sizeof(order_guid)]) ||
|
||||
(UINTN)(bcd + displayorder_value->data_offset) % sizeof(char16_t) != 0)
|
||||
@ -300,16 +294,11 @@ TEST_STATIC char16_t *get_bcd_title(uint8_t *bcd, UINTN bcd_len) {
|
||||
return NULL;
|
||||
|
||||
const Key *description_key = get_subkey(
|
||||
bcd, bcd_len,
|
||||
default_key->subkeys_offset,
|
||||
(const CHAR8 *) "Elements\00012000004\0");
|
||||
bcd, bcd_len, default_key->subkeys_offset, "Elements\00012000004\0");
|
||||
if (!description_key)
|
||||
return NULL;
|
||||
|
||||
const KeyValue *description_value = get_key_value(
|
||||
bcd, bcd_len,
|
||||
description_key,
|
||||
(const CHAR8 *) "Element");
|
||||
const KeyValue *description_value = get_key_value(bcd, bcd_len, description_key, "Element");
|
||||
if (!description_value)
|
||||
return NULL;
|
||||
|
||||
|
@ -1074,14 +1074,14 @@ static inline void config_entry_freep(ConfigEntry **entry) {
|
||||
config_entry_free(*entry);
|
||||
}
|
||||
|
||||
static CHAR8 *line_get_key_value(
|
||||
CHAR8 *content,
|
||||
const CHAR8 *sep,
|
||||
static char *line_get_key_value(
|
||||
char *content,
|
||||
const char *sep,
|
||||
UINTN *pos,
|
||||
CHAR8 **key_ret,
|
||||
CHAR8 **value_ret) {
|
||||
char **key_ret,
|
||||
char **value_ret) {
|
||||
|
||||
CHAR8 *line, *value;
|
||||
char *line, *value;
|
||||
UINTN linelen;
|
||||
|
||||
assert(content);
|
||||
@ -1127,13 +1127,13 @@ static CHAR8 *line_get_key_value(
|
||||
|
||||
/* split key/value */
|
||||
value = line;
|
||||
while (*value && !strchr8((char *) sep, *value))
|
||||
while (*value && !strchr8(sep, *value))
|
||||
value++;
|
||||
if (*value == '\0')
|
||||
continue;
|
||||
*value = '\0';
|
||||
value++;
|
||||
while (*value && strchr8((char *) sep, *value))
|
||||
while (*value && strchr8(sep, *value))
|
||||
value++;
|
||||
|
||||
/* unquote */
|
||||
@ -1148,24 +1148,24 @@ static CHAR8 *line_get_key_value(
|
||||
}
|
||||
}
|
||||
|
||||
static void config_defaults_load_from_file(Config *config, CHAR8 *content) {
|
||||
CHAR8 *line;
|
||||
static void config_defaults_load_from_file(Config *config, char *content) {
|
||||
char *line;
|
||||
UINTN pos = 0;
|
||||
CHAR8 *key, *value;
|
||||
char *key, *value;
|
||||
EFI_STATUS err;
|
||||
|
||||
assert(config);
|
||||
assert(content);
|
||||
|
||||
while ((line = line_get_key_value(content, (CHAR8 *)" \t", &pos, &key, &value))) {
|
||||
if (streq8((char *) key, "timeout")) {
|
||||
if (streq8((char *) value, "menu-force"))
|
||||
while ((line = line_get_key_value(content, " \t", &pos, &key, &value))) {
|
||||
if (streq8(key, "timeout")) {
|
||||
if (streq8( value, "menu-force"))
|
||||
config->timeout_sec_config = TIMEOUT_MENU_FORCE;
|
||||
else if (streq8((char *) value, "menu-hidden"))
|
||||
else if (streq8(value, "menu-hidden"))
|
||||
config->timeout_sec_config = TIMEOUT_MENU_HIDDEN;
|
||||
else {
|
||||
uint64_t u;
|
||||
if (!parse_number8((char *) value, &u, NULL) || u > TIMEOUT_TYPE_MAX) {
|
||||
if (!parse_number8(value, &u, NULL) || u > TIMEOUT_TYPE_MAX) {
|
||||
log_error_stall(L"Error parsing 'timeout' config option: %a", value);
|
||||
continue;
|
||||
}
|
||||
@ -1175,8 +1175,8 @@ static void config_defaults_load_from_file(Config *config, CHAR8 *content) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (streq8((char *) key, "default")) {
|
||||
if (value[0] == '@' && !strcaseeq8((char *) value, "@saved")) {
|
||||
if (streq8(key, "default")) {
|
||||
if (value[0] == '@' && !strcaseeq8(value, "@saved")) {
|
||||
log_error_stall(L"Unsupported special entry identifier: %a", value);
|
||||
continue;
|
||||
}
|
||||
@ -1185,51 +1185,51 @@ static void config_defaults_load_from_file(Config *config, CHAR8 *content) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (streq8((char *) key, "editor")) {
|
||||
if (streq8(key, "editor")) {
|
||||
err = parse_boolean(value, &config->editor);
|
||||
if (err != EFI_SUCCESS)
|
||||
log_error_stall(L"Error parsing 'editor' config option: %a", value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (streq8((char *) key, "auto-entries")) {
|
||||
if (streq8(key, "auto-entries")) {
|
||||
err = parse_boolean(value, &config->auto_entries);
|
||||
if (err != EFI_SUCCESS)
|
||||
log_error_stall(L"Error parsing 'auto-entries' config option: %a", value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (streq8((char *) key, "auto-firmware")) {
|
||||
if (streq8(key, "auto-firmware")) {
|
||||
err = parse_boolean(value, &config->auto_firmware);
|
||||
if (err != EFI_SUCCESS)
|
||||
log_error_stall(L"Error parsing 'auto-firmware' config option: %a", value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (streq8((char *) key, "beep")) {
|
||||
if (streq8(key, "beep")) {
|
||||
err = parse_boolean(value, &config->beep);
|
||||
if (err != EFI_SUCCESS)
|
||||
log_error_stall(L"Error parsing 'beep' config option: %a", value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (streq8((char *) key, "reboot-for-bitlocker")) {
|
||||
if (streq8(key, "reboot-for-bitlocker")) {
|
||||
err = parse_boolean(value, &config->reboot_for_bitlocker);
|
||||
if (err != EFI_SUCCESS)
|
||||
log_error_stall(L"Error parsing 'reboot-for-bitlocker' config option: %a", value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (streq8((char *) key, "console-mode")) {
|
||||
if (streq8((char *) value, "auto"))
|
||||
if (streq8(key, "console-mode")) {
|
||||
if (streq8(value, "auto"))
|
||||
config->console_mode = CONSOLE_MODE_AUTO;
|
||||
else if (streq8((char *) value, "max"))
|
||||
else if (streq8(value, "max"))
|
||||
config->console_mode = CONSOLE_MODE_FIRMWARE_MAX;
|
||||
else if (streq8((char *) value, "keep"))
|
||||
else if (streq8(value, "keep"))
|
||||
config->console_mode = CONSOLE_MODE_KEEP;
|
||||
else {
|
||||
uint64_t u;
|
||||
if (!parse_number8((char *) value, &u, NULL) || u > CONSOLE_MODE_RANGE_MAX) {
|
||||
if (!parse_number8(value, &u, NULL) || u > CONSOLE_MODE_RANGE_MAX) {
|
||||
log_error_stall(L"Error parsing 'console-mode' config option: %a", value);
|
||||
continue;
|
||||
}
|
||||
@ -1238,12 +1238,12 @@ static void config_defaults_load_from_file(Config *config, CHAR8 *content) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (streq8((char *) key, "random-seed-mode")) {
|
||||
if (streq8((char *) value, "off"))
|
||||
if (streq8(key, "random-seed-mode")) {
|
||||
if (streq8(value, "off"))
|
||||
config->random_seed_mode = RANDOM_SEED_OFF;
|
||||
else if (streq8((char *) value, "with-system-token"))
|
||||
else if (streq8(value, "with-system-token"))
|
||||
config->random_seed_mode = RANDOM_SEED_WITH_SYSTEM_TOKEN;
|
||||
else if (streq8((char *) value, "always"))
|
||||
else if (streq8(value, "always"))
|
||||
config->random_seed_mode = RANDOM_SEED_ALWAYS;
|
||||
else {
|
||||
BOOLEAN on;
|
||||
@ -1380,13 +1380,13 @@ static void config_entry_add_type1(
|
||||
EFI_FILE *root_dir,
|
||||
const char16_t *path,
|
||||
const char16_t *file,
|
||||
CHAR8 *content,
|
||||
char *content,
|
||||
const char16_t *loaded_image_path) {
|
||||
|
||||
_cleanup_(config_entry_freep) ConfigEntry *entry = NULL;
|
||||
CHAR8 *line;
|
||||
char *line;
|
||||
UINTN pos = 0, n_initrd = 0;
|
||||
CHAR8 *key, *value;
|
||||
char *key, *value;
|
||||
EFI_STATUS err;
|
||||
|
||||
assert(config);
|
||||
@ -1402,32 +1402,32 @@ static void config_entry_add_type1(
|
||||
.tries_left = -1,
|
||||
};
|
||||
|
||||
while ((line = line_get_key_value(content, (CHAR8 *)" \t", &pos, &key, &value))) {
|
||||
if (streq8((char *) key, "title")) {
|
||||
while ((line = line_get_key_value(content, " \t", &pos, &key, &value))) {
|
||||
if (streq8(key, "title")) {
|
||||
free(entry->title);
|
||||
entry->title = xstra_to_str(value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (streq8((char *) key, "sort-key")) {
|
||||
if (streq8(key, "sort-key")) {
|
||||
free(entry->sort_key);
|
||||
entry->sort_key = xstra_to_str(value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (streq8((char *) key, "version")) {
|
||||
if (streq8(key, "version")) {
|
||||
free(entry->version);
|
||||
entry->version = xstra_to_str(value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (streq8((char *) key, "machine-id")) {
|
||||
if (streq8(key, "machine-id")) {
|
||||
free(entry->machine_id);
|
||||
entry->machine_id = xstra_to_str(value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (streq8((char *) key, "linux")) {
|
||||
if (streq8(key, "linux")) {
|
||||
free(entry->loader);
|
||||
entry->type = LOADER_LINUX;
|
||||
entry->loader = xstra_to_path(value);
|
||||
@ -1435,7 +1435,7 @@ static void config_entry_add_type1(
|
||||
continue;
|
||||
}
|
||||
|
||||
if (streq8((char *) key, "efi")) {
|
||||
if (streq8(key, "efi")) {
|
||||
entry->type = LOADER_EFI;
|
||||
free(entry->loader);
|
||||
entry->loader = xstra_to_path(value);
|
||||
@ -1448,22 +1448,22 @@ static void config_entry_add_type1(
|
||||
continue;
|
||||
}
|
||||
|
||||
if (streq8((char *) key, "architecture")) {
|
||||
if (streq8(key, "architecture")) {
|
||||
/* do not add an entry for an EFI image of architecture not matching with that of the image */
|
||||
if (!streq8((char *) value, EFI_MACHINE_TYPE_NAME)) {
|
||||
if (!streq8(value, EFI_MACHINE_TYPE_NAME)) {
|
||||
entry->type = LOADER_UNDEFINED;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (streq8((char *) key, "devicetree")) {
|
||||
if (streq8(key, "devicetree")) {
|
||||
free(entry->devicetree);
|
||||
entry->devicetree = xstra_to_path(value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (streq8((char *) key, "initrd")) {
|
||||
if (streq8(key, "initrd")) {
|
||||
entry->initrd = xrealloc(
|
||||
entry->initrd,
|
||||
n_initrd == 0 ? 0 : (n_initrd + 1) * sizeof(uint16_t *),
|
||||
@ -1473,7 +1473,7 @@ static void config_entry_add_type1(
|
||||
continue;
|
||||
}
|
||||
|
||||
if (streq8((char *) key, "options")) {
|
||||
if (streq8(key, "options")) {
|
||||
_cleanup_free_ char16_t *new = NULL;
|
||||
|
||||
new = xstra_to_str(value);
|
||||
@ -1508,7 +1508,7 @@ static void config_entry_add_type1(
|
||||
}
|
||||
|
||||
static void config_load_defaults(Config *config, EFI_FILE *root_dir) {
|
||||
_cleanup_freepool_ CHAR8 *content = NULL;
|
||||
_cleanup_free_ char *content = NULL;
|
||||
UINTN value;
|
||||
EFI_STATUS err;
|
||||
|
||||
@ -1590,7 +1590,7 @@ static void config_load_entries(
|
||||
return;
|
||||
|
||||
for (;;) {
|
||||
_cleanup_freepool_ CHAR8 *content = NULL;
|
||||
_cleanup_free_ char *content = NULL;
|
||||
|
||||
err = readdir_harder(entries_dir, &f, &f_size);
|
||||
if (err != EFI_SUCCESS || !f)
|
||||
@ -1806,12 +1806,12 @@ static void config_title_generate(Config *config) {
|
||||
|
||||
static BOOLEAN is_sd_boot(EFI_FILE *root_dir, const char16_t *loader_path) {
|
||||
EFI_STATUS err;
|
||||
const CHAR8 *sections[] = {
|
||||
(CHAR8 *)".sdmagic",
|
||||
const char *sections[] = {
|
||||
".sdmagic",
|
||||
NULL
|
||||
};
|
||||
UINTN offset = 0, size = 0, read;
|
||||
_cleanup_freepool_ CHAR8 *content = NULL;
|
||||
_cleanup_free_ char *content = NULL;
|
||||
|
||||
assert(root_dir);
|
||||
assert(loader_path);
|
||||
@ -1940,7 +1940,7 @@ static EFI_STATUS boot_windows_bitlocker(void) {
|
||||
if (err != EFI_SUCCESS || block_io->Media->BlockSize < 512 || block_io->Media->BlockSize > 4096)
|
||||
continue;
|
||||
|
||||
CHAR8 buf[4096];
|
||||
char buf[4096];
|
||||
err = block_io->ReadBlocks(block_io, block_io->Media->MediaId, 0, sizeof(buf), buf);
|
||||
if (err != EFI_SUCCESS)
|
||||
continue;
|
||||
@ -1960,12 +1960,12 @@ static EFI_STATUS boot_windows_bitlocker(void) {
|
||||
|
||||
/* There can be gaps in Boot#### entries. Instead of iterating over the full
|
||||
* EFI var list or uint16_t namespace, just look for "Windows Boot Manager" in BootOrder. */
|
||||
err = efivar_get_raw(EFI_GLOBAL_GUID, L"BootOrder", (CHAR8 **) &boot_order, &boot_order_size);
|
||||
err = efivar_get_raw(EFI_GLOBAL_GUID, L"BootOrder", (char **) &boot_order, &boot_order_size);
|
||||
if (err != EFI_SUCCESS || boot_order_size % sizeof(uint16_t) != 0)
|
||||
return err;
|
||||
|
||||
for (UINTN i = 0; i < boot_order_size / sizeof(uint16_t); i++) {
|
||||
_cleanup_freepool_ CHAR8 *buf = NULL;
|
||||
_cleanup_free_ char *buf = NULL;
|
||||
char16_t name[sizeof(L"Boot0000")];
|
||||
UINTN buf_size;
|
||||
|
||||
@ -1999,7 +1999,7 @@ static EFI_STATUS boot_windows_bitlocker(void) {
|
||||
|
||||
static void config_entry_add_windows(Config *config, EFI_HANDLE *device, EFI_FILE *root_dir) {
|
||||
#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
|
||||
_cleanup_freepool_ CHAR8 *bcd = NULL;
|
||||
_cleanup_free_ char *bcd = NULL;
|
||||
char16_t *title = NULL;
|
||||
EFI_STATUS err;
|
||||
UINTN len;
|
||||
@ -2052,21 +2052,21 @@ static void config_entry_add_unified(
|
||||
_SECTION_MAX,
|
||||
};
|
||||
|
||||
static const CHAR8* const sections[_SECTION_MAX + 1] = {
|
||||
[SECTION_CMDLINE] = (const CHAR8 *) ".cmdline",
|
||||
[SECTION_OSREL] = (const CHAR8 *) ".osrel",
|
||||
static const char * const sections[_SECTION_MAX + 1] = {
|
||||
[SECTION_CMDLINE] = ".cmdline",
|
||||
[SECTION_OSREL] = ".osrel",
|
||||
NULL,
|
||||
};
|
||||
|
||||
_cleanup_free_ char16_t *os_pretty_name = NULL, *os_image_id = NULL, *os_name = NULL, *os_id = NULL,
|
||||
*os_image_version = NULL, *os_version = NULL, *os_version_id = NULL, *os_build_id = NULL;
|
||||
const char16_t *good_name, *good_version, *good_sort_key;
|
||||
_cleanup_freepool_ CHAR8 *content = NULL;
|
||||
_cleanup_free_ char *content = NULL;
|
||||
UINTN offs[_SECTION_MAX] = {};
|
||||
UINTN szs[_SECTION_MAX] = {};
|
||||
CHAR8 *line;
|
||||
char *line;
|
||||
UINTN pos = 0;
|
||||
CHAR8 *key, *value;
|
||||
char *key, *value;
|
||||
|
||||
err = readdir_harder(linux_dir, &f, &f_size);
|
||||
if (err != EFI_SUCCESS || !f)
|
||||
@ -2082,7 +2082,7 @@ static void config_entry_add_unified(
|
||||
continue;
|
||||
|
||||
/* look for .osrel and .cmdline sections in the .efi binary */
|
||||
err = pe_file_locate_sections(linux_dir, f->FileName, (const CHAR8**) sections, offs, szs);
|
||||
err = pe_file_locate_sections(linux_dir, f->FileName, (const char **) sections, offs, szs);
|
||||
if (err != EFI_SUCCESS || szs[SECTION_OSREL] == 0)
|
||||
continue;
|
||||
|
||||
@ -2091,50 +2091,50 @@ static void config_entry_add_unified(
|
||||
continue;
|
||||
|
||||
/* read properties from the embedded os-release file */
|
||||
while ((line = line_get_key_value(content, (CHAR8 *)"=", &pos, &key, &value))) {
|
||||
if (streq8((char *) key, "PRETTY_NAME")) {
|
||||
while ((line = line_get_key_value(content, "=", &pos, &key, &value))) {
|
||||
if (streq8(key, "PRETTY_NAME")) {
|
||||
free(os_pretty_name);
|
||||
os_pretty_name = xstra_to_str(value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (streq8((char *) key, "IMAGE_ID")) {
|
||||
if (streq8(key, "IMAGE_ID")) {
|
||||
free(os_image_id);
|
||||
os_image_id = xstra_to_str(value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (streq8((char *) key, "NAME")) {
|
||||
if (streq8(key, "NAME")) {
|
||||
free(os_name);
|
||||
os_name = xstra_to_str(value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (streq8((char *) key, "ID")) {
|
||||
if (streq8(key, "ID")) {
|
||||
free(os_id);
|
||||
os_id = xstra_to_str(value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (streq8((char *) key, "IMAGE_VERSION")) {
|
||||
if (streq8(key, "IMAGE_VERSION")) {
|
||||
free(os_image_version);
|
||||
os_image_version = xstra_to_str(value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (streq8((char *) key, "VERSION")) {
|
||||
if (streq8(key, "VERSION")) {
|
||||
free(os_version);
|
||||
os_version = xstra_to_str(value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (streq8((char *) key, "VERSION_ID")) {
|
||||
if (streq8(key, "VERSION_ID")) {
|
||||
free(os_version_id);
|
||||
os_version_id = xstra_to_str(value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (streq8((char *) key, "BUILD_ID")) {
|
||||
if (streq8(key, "BUILD_ID")) {
|
||||
free(os_build_id);
|
||||
os_build_id = xstra_to_str(value);
|
||||
continue;
|
||||
@ -2380,9 +2380,9 @@ static void config_free(Config *config) {
|
||||
}
|
||||
|
||||
static void config_write_entries_to_variable(Config *config) {
|
||||
_cleanup_freepool_ CHAR8 *buffer = NULL;
|
||||
_cleanup_free_ char *buffer = NULL;
|
||||
UINTN sz = 0;
|
||||
CHAR8 *p;
|
||||
char *p;
|
||||
|
||||
assert(config);
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "measure.h"
|
||||
#include "util.h"
|
||||
|
||||
static CHAR8* write_cpio_word(CHAR8 *p, uint32_t v) {
|
||||
static char *write_cpio_word(char *p, uint32_t v) {
|
||||
static const char hex[] = "0123456789abcdef";
|
||||
|
||||
assert(p);
|
||||
@ -17,8 +17,8 @@ static CHAR8* write_cpio_word(CHAR8 *p, uint32_t v) {
|
||||
return p + 8;
|
||||
}
|
||||
|
||||
static CHAR8* mangle_filename(CHAR8 *p, const char16_t *f) {
|
||||
CHAR8* w;
|
||||
static char *mangle_filename(char *p, const char16_t *f) {
|
||||
char* w;
|
||||
|
||||
assert(p);
|
||||
assert(f);
|
||||
@ -36,7 +36,7 @@ static CHAR8* mangle_filename(CHAR8 *p, const char16_t *f) {
|
||||
return w;
|
||||
}
|
||||
|
||||
static CHAR8* pad4(CHAR8 *p, const CHAR8* start) {
|
||||
static char *pad4(char *p, const char *start) {
|
||||
assert(p);
|
||||
assert(start);
|
||||
assert(p >= start);
|
||||
@ -53,14 +53,14 @@ static EFI_STATUS pack_cpio_one(
|
||||
const char16_t *fname,
|
||||
const void *contents,
|
||||
UINTN contents_size,
|
||||
const CHAR8 *target_dir_prefix,
|
||||
const char *target_dir_prefix,
|
||||
uint32_t access_mode,
|
||||
uint32_t *inode_counter,
|
||||
void **cpio_buffer,
|
||||
UINTN *cpio_buffer_size) {
|
||||
|
||||
UINTN l, target_dir_prefix_size, fname_size, q;
|
||||
CHAR8 *a;
|
||||
char *a;
|
||||
|
||||
assert(fname);
|
||||
assert(contents_size || contents_size == 0);
|
||||
@ -81,7 +81,7 @@ static EFI_STATUS pack_cpio_one(
|
||||
|
||||
l = 6 + 13*8 + 1 + 1; /* Fixed CPIO header size, slash separator, and NUL byte after the file name*/
|
||||
|
||||
target_dir_prefix_size = strlen8((const char *) target_dir_prefix);
|
||||
target_dir_prefix_size = strlen8(target_dir_prefix);
|
||||
if (l > UINTN_MAX - target_dir_prefix_size)
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
l += target_dir_prefix_size;
|
||||
@ -114,7 +114,7 @@ static EFI_STATUS pack_cpio_one(
|
||||
a = xrealloc(*cpio_buffer, *cpio_buffer_size, *cpio_buffer_size + l);
|
||||
|
||||
*cpio_buffer = a;
|
||||
a = (CHAR8*) *cpio_buffer + *cpio_buffer_size;
|
||||
a = (char *) *cpio_buffer + *cpio_buffer_size;
|
||||
|
||||
memcpy(a, "070701", 6); /* magic ID */
|
||||
a += 6;
|
||||
@ -153,21 +153,21 @@ static EFI_STATUS pack_cpio_one(
|
||||
/* Pad to next multiple of 4 */
|
||||
a = pad4(a, *cpio_buffer);
|
||||
|
||||
assert(a == (CHAR8*) *cpio_buffer + *cpio_buffer_size + l);
|
||||
assert(a == (char *) *cpio_buffer + *cpio_buffer_size + l);
|
||||
*cpio_buffer_size += l;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
static EFI_STATUS pack_cpio_dir(
|
||||
const CHAR8 *path,
|
||||
const char *path,
|
||||
uint32_t access_mode,
|
||||
uint32_t *inode_counter,
|
||||
void **cpio_buffer,
|
||||
UINTN *cpio_buffer_size) {
|
||||
|
||||
UINTN l, path_size;
|
||||
CHAR8 *a;
|
||||
char *a;
|
||||
|
||||
assert(path);
|
||||
assert(inode_counter);
|
||||
@ -182,7 +182,7 @@ static EFI_STATUS pack_cpio_dir(
|
||||
|
||||
l = 6 + 13*8 + 1; /* Fixed CPIO header size, and NUL byte after the file name*/
|
||||
|
||||
path_size = strlen8((const char *) path);
|
||||
path_size = strlen8(path);
|
||||
if (l > UINTN_MAX - path_size)
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
l += path_size;
|
||||
@ -196,7 +196,7 @@ static EFI_STATUS pack_cpio_dir(
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
|
||||
*cpio_buffer = a = xrealloc(*cpio_buffer, *cpio_buffer_size, *cpio_buffer_size + l);
|
||||
a = (CHAR8*) *cpio_buffer + *cpio_buffer_size;
|
||||
a = (char *) *cpio_buffer + *cpio_buffer_size;
|
||||
|
||||
memcpy(a, "070701", 6); /* magic ID */
|
||||
a += 6;
|
||||
@ -221,14 +221,14 @@ static EFI_STATUS pack_cpio_dir(
|
||||
/* Pad to next multiple of 4 */
|
||||
a = pad4(a, *cpio_buffer);
|
||||
|
||||
assert(a == (CHAR8*) *cpio_buffer + *cpio_buffer_size + l);
|
||||
assert(a == (char *) *cpio_buffer + *cpio_buffer_size + l);
|
||||
|
||||
*cpio_buffer_size += l;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
static EFI_STATUS pack_cpio_prefix(
|
||||
const CHAR8 *path,
|
||||
const char *path,
|
||||
uint32_t dir_mode,
|
||||
uint32_t *inode_counter,
|
||||
void **cpio_buffer,
|
||||
@ -245,17 +245,17 @@ static EFI_STATUS pack_cpio_prefix(
|
||||
* (similar to mkdir -p behaviour) all leading paths are created with 0555 access mode, only the
|
||||
* final dir is created with the specified directory access mode. */
|
||||
|
||||
for (const CHAR8 *p = path;;) {
|
||||
const CHAR8 *e;
|
||||
for (const char *p = path;;) {
|
||||
const char *e;
|
||||
|
||||
e = (const CHAR8 *) strchr8((const char *) p, '/');
|
||||
e = strchr8(p, '/');
|
||||
if (!e)
|
||||
break;
|
||||
|
||||
if (e > p) {
|
||||
_cleanup_freepool_ CHAR8 *t = NULL;
|
||||
_cleanup_free_ char *t = NULL;
|
||||
|
||||
t = (CHAR8 *) xstrndup8((const char *) path, e - path);
|
||||
t = xstrndup8(path, e - path);
|
||||
if (!t)
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
|
||||
@ -308,7 +308,7 @@ EFI_STATUS pack_cpio(
|
||||
EFI_LOADED_IMAGE *loaded_image,
|
||||
const char16_t *dropin_dir,
|
||||
const char16_t *match_suffix,
|
||||
const CHAR8 *target_dir_prefix,
|
||||
const char *target_dir_prefix,
|
||||
uint32_t dir_mode,
|
||||
uint32_t access_mode,
|
||||
const uint32_t tpm_pcr[],
|
||||
@ -427,7 +427,7 @@ EFI_STATUS pack_cpio(
|
||||
return log_error_status_stall(err, L"Failed to pack cpio prefix: %r", err);
|
||||
|
||||
for (UINTN i = 0; i < n_items; i++) {
|
||||
_cleanup_freepool_ CHAR8 *content = NULL;
|
||||
_cleanup_free_ char *content = NULL;
|
||||
UINTN contentsize;
|
||||
|
||||
err = file_read(extra_dir, items[i], 0, 0, &content, &contentsize);
|
||||
|
@ -8,7 +8,7 @@ EFI_STATUS pack_cpio(
|
||||
EFI_LOADED_IMAGE *loaded_image,
|
||||
const char16_t *dropin_dir,
|
||||
const char16_t *match_suffix,
|
||||
const CHAR8 *target_dir_prefix,
|
||||
const char *target_dir_prefix,
|
||||
uint32_t dir_mode,
|
||||
uint32_t access_mode,
|
||||
const uint32_t tpm_pcr[],
|
||||
|
@ -24,7 +24,7 @@ static EFI_LOADED_IMAGE * loaded_image_free(EFI_LOADED_IMAGE *img) {
|
||||
}
|
||||
|
||||
static EFI_STATUS loaded_image_register(
|
||||
const CHAR8 *cmdline, UINTN cmdline_len,
|
||||
const char *cmdline, UINTN cmdline_len,
|
||||
const void *linux_buffer, UINTN linux_length,
|
||||
EFI_HANDLE *ret_image) {
|
||||
|
||||
@ -106,7 +106,7 @@ static inline void cleanup_pages(struct pages *p) {
|
||||
|
||||
EFI_STATUS linux_exec(
|
||||
EFI_HANDLE image,
|
||||
const CHAR8 *cmdline, UINTN cmdline_len,
|
||||
const char *cmdline, UINTN cmdline_len,
|
||||
const void *linux_buffer, UINTN linux_length,
|
||||
const void *initrd_buffer, UINTN initrd_length) {
|
||||
|
||||
|
@ -5,6 +5,6 @@
|
||||
|
||||
EFI_STATUS linux_exec(
|
||||
EFI_HANDLE image,
|
||||
const CHAR8 *cmdline, UINTN cmdline_len,
|
||||
const char *cmdline, UINTN cmdline_len,
|
||||
const void *linux_buffer, UINTN linux_length,
|
||||
const void *initrd_buffer, UINTN initrd_length);
|
||||
|
@ -122,7 +122,7 @@ static void linux_efi_handover(EFI_HANDLE image, struct boot_params *params) {
|
||||
|
||||
EFI_STATUS linux_exec(
|
||||
EFI_HANDLE image,
|
||||
const CHAR8 *cmdline, UINTN cmdline_len,
|
||||
const char *cmdline, UINTN cmdline_len,
|
||||
const void *linux_buffer, UINTN linux_length,
|
||||
const void *initrd_buffer, UINTN initrd_length) {
|
||||
|
||||
@ -177,7 +177,7 @@ EFI_STATUS linux_exec(
|
||||
return err;
|
||||
|
||||
memcpy(PHYSICAL_ADDRESS_TO_POINTER(addr), cmdline, cmdline_len);
|
||||
((CHAR8 *) PHYSICAL_ADDRESS_TO_POINTER(addr))[cmdline_len] = 0;
|
||||
((char *) PHYSICAL_ADDRESS_TO_POINTER(addr))[cmdline_len] = 0;
|
||||
boot_params->hdr.cmd_line_ptr = (uint32_t) addr;
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ static inline UINTN section_table_offset(const struct DosFileHeader *dos, const
|
||||
static void locate_sections(
|
||||
const struct PeSectionHeader section_table[],
|
||||
UINTN n_table,
|
||||
const CHAR8 **sections,
|
||||
const char **sections,
|
||||
UINTN *addrs,
|
||||
UINTN *offsets,
|
||||
UINTN *sizes) {
|
||||
@ -154,7 +154,7 @@ static void locate_sections(
|
||||
const struct PeSectionHeader *sect = section_table + i;
|
||||
|
||||
for (UINTN j = 0; sections[j]; j++) {
|
||||
if (memcmp(sect->Name, sections[j], strlen8((const char *) sections[j])) != 0)
|
||||
if (memcmp(sect->Name, sections[j], strlen8(sections[j])) != 0)
|
||||
continue;
|
||||
|
||||
if (addrs)
|
||||
@ -168,7 +168,7 @@ static void locate_sections(
|
||||
|
||||
static uint32_t get_compatibility_entry_address(const struct DosFileHeader *dos, const struct PeFileHeader *pe) {
|
||||
UINTN addr = 0, size = 0;
|
||||
static const CHAR8 *sections[] = { (CHAR8 *) ".compat", NULL };
|
||||
static const char *sections[] = { ".compat", NULL };
|
||||
|
||||
/* The kernel may provide alternative PE entry points for different PE architectures. This allows
|
||||
* booting a 64bit kernel on 32bit EFI that is otherwise running on a 64bit CPU. The locations of any
|
||||
@ -248,8 +248,8 @@ EFI_STATUS pe_alignment_info(
|
||||
}
|
||||
|
||||
EFI_STATUS pe_memory_locate_sections(
|
||||
const CHAR8 *base,
|
||||
const CHAR8 **sections,
|
||||
const char *base,
|
||||
const char **sections,
|
||||
UINTN *addrs,
|
||||
UINTN *sizes) {
|
||||
const struct DosFileHeader *dos;
|
||||
@ -279,7 +279,7 @@ EFI_STATUS pe_memory_locate_sections(
|
||||
EFI_STATUS pe_file_locate_sections(
|
||||
EFI_FILE *dir,
|
||||
const char16_t *path,
|
||||
const CHAR8 **sections,
|
||||
const char **sections,
|
||||
UINTN *offsets,
|
||||
UINTN *sizes) {
|
||||
_cleanup_freepool_ struct PeSectionHeader *section_table = NULL;
|
||||
|
@ -5,15 +5,15 @@
|
||||
#include <uchar.h>
|
||||
|
||||
EFI_STATUS pe_memory_locate_sections(
|
||||
const CHAR8 *base,
|
||||
const CHAR8 **sections,
|
||||
const char *base,
|
||||
const char **sections,
|
||||
UINTN *addrs,
|
||||
UINTN *sizes);
|
||||
|
||||
EFI_STATUS pe_file_locate_sections(
|
||||
EFI_FILE *dir,
|
||||
const char16_t *path,
|
||||
const CHAR8 **sections,
|
||||
const char **sections,
|
||||
UINTN *offsets,
|
||||
UINTN *sizes);
|
||||
|
||||
|
@ -156,7 +156,7 @@ static EFI_STATUS mangle_random_seed(
|
||||
}
|
||||
|
||||
static EFI_STATUS acquire_system_token(void **ret, UINTN *ret_size) {
|
||||
_cleanup_freepool_ CHAR8 *data = NULL;
|
||||
_cleanup_free_ char *data = NULL;
|
||||
EFI_STATUS err;
|
||||
UINTN size;
|
||||
|
||||
|
@ -104,7 +104,7 @@ static EFIAPI EFI_STATUS security_policy_authentication (const EFI_SECURITY_PROT
|
||||
EFI_STATUS err;
|
||||
_cleanup_free_ char16_t *dev_path_str = NULL;
|
||||
EFI_HANDLE h;
|
||||
_cleanup_freepool_ CHAR8 *file_buffer = NULL;
|
||||
_cleanup_free_ char *file_buffer = NULL;
|
||||
UINTN file_size;
|
||||
|
||||
assert(this);
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "util.h"
|
||||
|
||||
struct bmp_file {
|
||||
CHAR8 signature[2];
|
||||
char signature[2];
|
||||
uint32_t size;
|
||||
uint16_t reserved[2];
|
||||
uint32_t offset;
|
||||
|
@ -158,12 +158,12 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
|
||||
_SECTION_MAX,
|
||||
};
|
||||
|
||||
static const CHAR8* const sections[_SECTION_MAX + 1] = {
|
||||
[SECTION_CMDLINE] = (const CHAR8*) ".cmdline",
|
||||
[SECTION_LINUX] = (const CHAR8*) ".linux",
|
||||
[SECTION_INITRD] = (const CHAR8*) ".initrd",
|
||||
[SECTION_SPLASH] = (const CHAR8*) ".splash",
|
||||
[SECTION_DTB] = (const CHAR8*) ".dtb",
|
||||
static const char * const sections[_SECTION_MAX + 1] = {
|
||||
[SECTION_CMDLINE] = ".cmdline",
|
||||
[SECTION_LINUX] = ".linux",
|
||||
[SECTION_INITRD] = ".initrd",
|
||||
[SECTION_SPLASH] = ".splash",
|
||||
[SECTION_DTB] = ".dtb",
|
||||
NULL,
|
||||
};
|
||||
|
||||
@ -176,8 +176,8 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
|
||||
EFI_LOADED_IMAGE *loaded_image;
|
||||
UINTN addrs[_SECTION_MAX] = {};
|
||||
UINTN szs[_SECTION_MAX] = {};
|
||||
CHAR8 *cmdline = NULL;
|
||||
_cleanup_freepool_ CHAR8 *cmdline_owned = NULL;
|
||||
char *cmdline = NULL;
|
||||
_cleanup_free_ char *cmdline_owned = NULL;
|
||||
EFI_STATUS err;
|
||||
|
||||
InitializeLib(image, sys_table);
|
||||
@ -195,7 +195,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
|
||||
if (err != EFI_SUCCESS)
|
||||
return log_error_status_stall(err, L"Error getting a LoadedImageProtocol handle: %r", err);
|
||||
|
||||
err = pe_memory_locate_sections(loaded_image->ImageBase, (const CHAR8**) sections, addrs, szs);
|
||||
err = pe_memory_locate_sections(loaded_image->ImageBase, (const char **) sections, addrs, szs);
|
||||
if (err != EFI_SUCCESS || szs[SECTION_LINUX] == 0) {
|
||||
if (err == EFI_SUCCESS)
|
||||
err = EFI_NOT_FOUND;
|
||||
@ -206,14 +206,14 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
|
||||
graphics_splash((const uint8_t*) loaded_image->ImageBase + addrs[SECTION_SPLASH], szs[SECTION_SPLASH], NULL);
|
||||
|
||||
if (szs[SECTION_CMDLINE] > 0) {
|
||||
cmdline = (CHAR8*) loaded_image->ImageBase + addrs[SECTION_CMDLINE];
|
||||
cmdline = (char *) loaded_image->ImageBase + addrs[SECTION_CMDLINE];
|
||||
cmdline_len = szs[SECTION_CMDLINE];
|
||||
}
|
||||
|
||||
/* if we are not in secure boot mode, or none was provided, accept a custom command line and replace the built-in one */
|
||||
if ((!secure_boot_enabled() || cmdline_len == 0) && loaded_image->LoadOptionsSize > 0 &&
|
||||
*(char16_t *) loaded_image->LoadOptions > 0x1F) {
|
||||
cmdline_len = (loaded_image->LoadOptionsSize / sizeof(char16_t)) * sizeof(CHAR8);
|
||||
cmdline_len = (loaded_image->LoadOptionsSize / sizeof(char16_t)) * sizeof(char);
|
||||
cmdline = cmdline_owned = xmalloc(cmdline_len);
|
||||
|
||||
for (UINTN i = 0; i < cmdline_len; i++)
|
||||
@ -231,7 +231,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
|
||||
(void) pack_cpio(loaded_image,
|
||||
NULL,
|
||||
L".cred",
|
||||
(const CHAR8*) ".extra/credentials",
|
||||
".extra/credentials",
|
||||
/* dir_mode= */ 0500,
|
||||
/* access_mode= */ 0400,
|
||||
/* tpm_pcr= */ (uint32_t[]) { TPM_PCR_INDEX_KERNEL_PARAMETERS, TPM_PCR_INDEX_KERNEL_PARAMETERS_COMPAT },
|
||||
@ -243,7 +243,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
|
||||
(void) pack_cpio(loaded_image,
|
||||
L"\\loader\\credentials",
|
||||
L".cred",
|
||||
(const CHAR8*) ".extra/global_credentials",
|
||||
".extra/global_credentials",
|
||||
/* dir_mode= */ 0500,
|
||||
/* access_mode= */ 0400,
|
||||
/* tpm_pcr= */ (uint32_t[]) { TPM_PCR_INDEX_KERNEL_PARAMETERS, TPM_PCR_INDEX_KERNEL_PARAMETERS_COMPAT },
|
||||
@ -255,7 +255,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
|
||||
(void) pack_cpio(loaded_image,
|
||||
NULL,
|
||||
L".raw",
|
||||
(const CHAR8*) ".extra/sysext",
|
||||
".extra/sysext",
|
||||
/* dir_mode= */ 0555,
|
||||
/* access_mode= */ 0444,
|
||||
/* tpm_pcr= */ (uint32_t[]) { TPM_PCR_INDEX_INITRD },
|
||||
|
@ -6,20 +6,20 @@
|
||||
#include "ticks.h"
|
||||
#include "util.h"
|
||||
|
||||
EFI_STATUS parse_boolean(const CHAR8 *v, BOOLEAN *b) {
|
||||
EFI_STATUS parse_boolean(const char *v, BOOLEAN *b) {
|
||||
assert(b);
|
||||
|
||||
if (!v)
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
if (streq8((char *) v, "1") || streq8((char *) v, "yes") || streq8((char *) v, "y") ||
|
||||
streq8((char *) v, "true") || streq8((char *) v, "t") || streq8((char *) v, "on")) {
|
||||
if (streq8(v, "1") || streq8(v, "yes") || streq8(v, "y") || streq8(v, "true") || streq8(v, "t") ||
|
||||
streq8(v, "on")) {
|
||||
*b = TRUE;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if (streq8((char *) v, "0") || streq8((char *) v, "no") || streq8((char *) v, "n") ||
|
||||
streq8((char *) v, "false") || streq8((char *) v, "f") || streq8((char *) v, "off")) {
|
||||
if (streq8(v, "0") || streq8(v, "no") || streq8(v, "n") || streq8(v, "false") || streq8(v, "f") ||
|
||||
streq8(v, "off")) {
|
||||
*b = FALSE;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -97,7 +97,7 @@ EFI_STATUS efivar_get(const EFI_GUID *vendor, const char16_t *name, char16_t **v
|
||||
assert(vendor);
|
||||
assert(name);
|
||||
|
||||
err = efivar_get_raw(vendor, name, (CHAR8**)&buf, &size);
|
||||
err = efivar_get_raw(vendor, name, (char **) &buf, &size);
|
||||
if (err != EFI_SUCCESS)
|
||||
return err;
|
||||
|
||||
@ -145,7 +145,7 @@ EFI_STATUS efivar_get_uint_string(const EFI_GUID *vendor, const char16_t *name,
|
||||
}
|
||||
|
||||
EFI_STATUS efivar_get_uint32_le(const EFI_GUID *vendor, const char16_t *name, uint32_t *ret) {
|
||||
_cleanup_freepool_ CHAR8 *buf = NULL;
|
||||
_cleanup_free_ char *buf = NULL;
|
||||
UINTN size;
|
||||
EFI_STATUS err;
|
||||
|
||||
@ -165,7 +165,7 @@ EFI_STATUS efivar_get_uint32_le(const EFI_GUID *vendor, const char16_t *name, ui
|
||||
}
|
||||
|
||||
EFI_STATUS efivar_get_uint64_le(const EFI_GUID *vendor, const char16_t *name, uint64_t *ret) {
|
||||
_cleanup_freepool_ CHAR8 *buf = NULL;
|
||||
_cleanup_free_ char *buf = NULL;
|
||||
UINTN size;
|
||||
EFI_STATUS err;
|
||||
|
||||
@ -185,8 +185,8 @@ EFI_STATUS efivar_get_uint64_le(const EFI_GUID *vendor, const char16_t *name, ui
|
||||
return err;
|
||||
}
|
||||
|
||||
EFI_STATUS efivar_get_raw(const EFI_GUID *vendor, const char16_t *name, CHAR8 **buffer, UINTN *size) {
|
||||
_cleanup_freepool_ CHAR8 *buf = NULL;
|
||||
EFI_STATUS efivar_get_raw(const EFI_GUID *vendor, const char16_t *name, char **buffer, UINTN *size) {
|
||||
_cleanup_free_ char *buf = NULL;
|
||||
UINTN l;
|
||||
EFI_STATUS err;
|
||||
|
||||
@ -210,7 +210,7 @@ EFI_STATUS efivar_get_raw(const EFI_GUID *vendor, const char16_t *name, CHAR8 **
|
||||
}
|
||||
|
||||
EFI_STATUS efivar_get_boolean_u8(const EFI_GUID *vendor, const char16_t *name, BOOLEAN *ret) {
|
||||
_cleanup_freepool_ CHAR8 *b = NULL;
|
||||
_cleanup_free_ char *b = NULL;
|
||||
UINTN size;
|
||||
EFI_STATUS err;
|
||||
|
||||
@ -241,7 +241,7 @@ void efivar_set_time_usec(const EFI_GUID *vendor, const char16_t *name, uint64_t
|
||||
efivar_set(vendor, name, str, 0);
|
||||
}
|
||||
|
||||
static INTN utf8_to_16(const CHAR8 *stra, char16_t *c) {
|
||||
static INTN utf8_to_16(const char *stra, char16_t *c) {
|
||||
char16_t unichar;
|
||||
UINTN len;
|
||||
|
||||
@ -295,7 +295,7 @@ static INTN utf8_to_16(const CHAR8 *stra, char16_t *c) {
|
||||
return len;
|
||||
}
|
||||
|
||||
char16_t *xstra_to_str(const CHAR8 *stra) {
|
||||
char16_t *xstra_to_str(const char *stra) {
|
||||
UINTN strlen;
|
||||
UINTN len;
|
||||
UINTN i;
|
||||
@ -303,7 +303,7 @@ char16_t *xstra_to_str(const CHAR8 *stra) {
|
||||
|
||||
assert(stra);
|
||||
|
||||
len = strlen8((const char *) stra);
|
||||
len = strlen8(stra);
|
||||
str = xnew(char16_t, len + 1);
|
||||
|
||||
strlen = 0;
|
||||
@ -325,7 +325,7 @@ char16_t *xstra_to_str(const CHAR8 *stra) {
|
||||
return str;
|
||||
}
|
||||
|
||||
char16_t *xstra_to_path(const CHAR8 *stra) {
|
||||
char16_t *xstra_to_path(const char *stra) {
|
||||
char16_t *str;
|
||||
UINTN strlen;
|
||||
UINTN len;
|
||||
@ -333,7 +333,7 @@ char16_t *xstra_to_path(const CHAR8 *stra) {
|
||||
|
||||
assert(stra);
|
||||
|
||||
len = strlen8((const char *) stra);
|
||||
len = strlen8(stra);
|
||||
str = xnew(char16_t, len + 2);
|
||||
|
||||
str[0] = '\\';
|
||||
@ -364,9 +364,9 @@ char16_t *xstra_to_path(const CHAR8 *stra) {
|
||||
return str;
|
||||
}
|
||||
|
||||
EFI_STATUS file_read(EFI_FILE *dir, const char16_t *name, UINTN off, UINTN size, CHAR8 **ret, UINTN *ret_size) {
|
||||
EFI_STATUS file_read(EFI_FILE *dir, const char16_t *name, UINTN off, UINTN size, char **ret, UINTN *ret_size) {
|
||||
_cleanup_(file_closep) EFI_FILE *handle = NULL;
|
||||
_cleanup_freepool_ CHAR8 *buf = NULL;
|
||||
_cleanup_free_ char *buf = NULL;
|
||||
EFI_STATUS err;
|
||||
|
||||
assert(dir);
|
||||
@ -393,7 +393,7 @@ EFI_STATUS file_read(EFI_FILE *dir, const char16_t *name, UINTN off, UINTN size,
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Allocate some extra bytes to guarantee the result is NUL-terminated for CHAR8 and char16_t strings. */
|
||||
/* Allocate some extra bytes to guarantee the result is NUL-terminated for char and char16_t strings. */
|
||||
UINTN extra = size % sizeof(char16_t) + sizeof(char16_t);
|
||||
|
||||
buf = xmalloc(size + extra);
|
||||
|
@ -69,7 +69,7 @@ static inline void *xrealloc(void *p, size_t old_size, size_t new_size) {
|
||||
#define xpool_print(fmt, ...) ((char16_t *) ASSERT_SE_PTR(PoolPrint((fmt), ##__VA_ARGS__)))
|
||||
#define xnew(type, n) ((type *) xmalloc_multiply(sizeof(type), (n)))
|
||||
|
||||
EFI_STATUS parse_boolean(const CHAR8 *v, BOOLEAN *b);
|
||||
EFI_STATUS parse_boolean(const char *v, BOOLEAN *b);
|
||||
|
||||
EFI_STATUS efivar_set(const EFI_GUID *vendor, const char16_t *name, const char16_t *value, uint32_t flags);
|
||||
EFI_STATUS efivar_set_raw(const EFI_GUID *vendor, const char16_t *name, const void *buf, UINTN size, uint32_t flags);
|
||||
@ -79,16 +79,16 @@ EFI_STATUS efivar_set_uint64_le(const EFI_GUID *vendor, const char16_t *name, ui
|
||||
void efivar_set_time_usec(const EFI_GUID *vendor, const char16_t *name, uint64_t usec);
|
||||
|
||||
EFI_STATUS efivar_get(const EFI_GUID *vendor, const char16_t *name, char16_t **value);
|
||||
EFI_STATUS efivar_get_raw(const EFI_GUID *vendor, const char16_t *name, CHAR8 **buffer, UINTN *size);
|
||||
EFI_STATUS efivar_get_raw(const EFI_GUID *vendor, const char16_t *name, char **buffer, UINTN *size);
|
||||
EFI_STATUS efivar_get_uint_string(const EFI_GUID *vendor, const char16_t *name, UINTN *i);
|
||||
EFI_STATUS efivar_get_uint32_le(const EFI_GUID *vendor, const char16_t *name, uint32_t *ret);
|
||||
EFI_STATUS efivar_get_uint64_le(const EFI_GUID *vendor, const char16_t *name, uint64_t *ret);
|
||||
EFI_STATUS efivar_get_boolean_u8(const EFI_GUID *vendor, const char16_t *name, BOOLEAN *ret);
|
||||
|
||||
char16_t *xstra_to_path(const CHAR8 *stra);
|
||||
char16_t *xstra_to_str(const CHAR8 *stra);
|
||||
char16_t *xstra_to_path(const char *stra);
|
||||
char16_t *xstra_to_str(const char *stra);
|
||||
|
||||
EFI_STATUS file_read(EFI_FILE *dir, const char16_t *name, UINTN off, UINTN size, CHAR8 **content, UINTN *content_size);
|
||||
EFI_STATUS file_read(EFI_FILE *dir, const char16_t *name, UINTN off, UINTN size, char **content, UINTN *content_size);
|
||||
|
||||
static inline void file_closep(EFI_FILE **handle) {
|
||||
if (!*handle)
|
||||
|
Loading…
Reference in New Issue
Block a user