bootctl: add description and ret_slot parameters to install_boot_option()
This moves creation of the EFI boot option description out of install_boot_option and into the caller, and adds a ret_slot output parameter for capturing the assigned BootOrder slot. This allows reusing the function for installing variables with different descriptions.
This commit is contained in:
@@ -1354,12 +1354,16 @@ fallback:
|
||||
|
||||
static int install_boot_option(
|
||||
InstallContext *c,
|
||||
const char *path) {
|
||||
const char *path,
|
||||
const char *description,
|
||||
uint16_t *ret_slot) {
|
||||
|
||||
uint16_t slot;
|
||||
int r;
|
||||
|
||||
assert(c);
|
||||
assert(path);
|
||||
assert(description);
|
||||
|
||||
if (c->esp_fd < 0)
|
||||
return c->esp_fd;
|
||||
@@ -1396,12 +1400,6 @@ static int install_boot_option(
|
||||
bool existing = r > 0;
|
||||
|
||||
if (c->operation == INSTALL_NEW || !existing) {
|
||||
_cleanup_free_ char *description = NULL;
|
||||
|
||||
r = pick_efi_boot_option_description(c->esp_fd, &description);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = efi_add_boot_option(
|
||||
slot,
|
||||
description,
|
||||
@@ -1424,7 +1422,14 @@ static int install_boot_option(
|
||||
description);
|
||||
}
|
||||
|
||||
return insert_into_order(c, slot);
|
||||
r = insert_into_order(c, slot);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (ret_slot)
|
||||
*ret_slot = slot;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int are_we_installed(InstallContext *c) {
|
||||
@@ -1632,7 +1637,13 @@ static int run_install(InstallContext *c) {
|
||||
}
|
||||
|
||||
char *path = strjoina("/EFI/systemd/systemd-boot", arch, ".efi");
|
||||
return install_boot_option(c, path);
|
||||
|
||||
_cleanup_free_ char *description = NULL;
|
||||
r = pick_efi_boot_option_description(c->esp_fd, &description);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return install_boot_option(c, path, description, /* ret_slot= */ NULL);
|
||||
}
|
||||
|
||||
int verb_install(int argc, char *argv[], uintptr_t _data, void *userdata) {
|
||||
|
||||
Reference in New Issue
Block a user