From: Clayton Craft Date: Thu, 30 Apr 2026 00:10:05 +0000 (-0700) Subject: bootctl: add description and ret_slot parameters to install_boot_option() X-Git-Tag: v261-rc1~24^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bb520fd6a578263cf6394733a5f316d0255a787a;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/bootctl/bootctl-install.c b/src/bootctl/bootctl-install.c index 4478f78eb35..db5d982a583 100644 --- a/src/bootctl/bootctl-install.c +++ b/src/bootctl/bootctl-install.c @@ -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) {