From 5fb90fa3194d998a971b21e4a643670ae5903f85 Mon Sep 17 00:00:00 2001 From: Felix Pehla <29adc1fd92@gmail.com> Date: Sun, 28 Sep 2025 18:50:06 +0200 Subject: [PATCH] shared/bootspec: parse 'profile' boot entry option Commit 1e9c9773b994f2f703a5aa5ba80961e90be3a892 makes sd-boot recognize a 'profile' option in a boot loader entry but bootctl and other components parsing said config do not know about it. This commit makes the option get parsed correctly and displays it too. --- src/shared/bootspec.c | 6 ++++++ src/shared/bootspec.h | 1 + src/shared/varlink-io.systemd.BootControl.c | 1 + 3 files changed, 8 insertions(+) diff --git a/src/shared/bootspec.c b/src/shared/bootspec.c index 2054ea6fb88..9fa50608f5f 100644 --- a/src/shared/bootspec.c +++ b/src/shared/bootspec.c @@ -406,6 +406,8 @@ static int boot_entry_load_type1( r = parse_path_one(tmp.path, line, field, &tmp.efi, p); else if (streq(field, "uki")) r = parse_path_one(tmp.path, line, field, &tmp.uki, p); + else if (streq(field, "profile")) + r = safe_atou_full(p, 10, &tmp.profile); else if (streq(field, "initrd")) r = parse_path_strv(tmp.path, line, field, &tmp.initrd, p); else if (streq(field, "devicetree")) @@ -1631,6 +1633,7 @@ int boot_config_augment_from_loader( .reported_by_loader = true, .tries_left = UINT_MAX, .tries_done = UINT_MAX, + .profile = UINT_MAX, .global_addons = &no_addons, }; } @@ -1901,6 +1904,8 @@ int show_boot_entry( boot_entry_file_list("efi", e->root, e->efi, &status); if (e->uki) boot_entry_file_list("uki", e->root, e->uki, &status); + if (e->profile != UINT_MAX) + printf(" profile: %u\n", e->profile); STRV_FOREACH(s, e->initrd) boot_entry_file_list(s == e->initrd ? "initrd" : NULL, @@ -1963,6 +1968,7 @@ int boot_entry_to_json(const BootConfig *c, size_t i, sd_json_variant **ret) { SD_JSON_BUILD_PAIR_CONDITION(!!e->kernel, "linux", SD_JSON_BUILD_STRING(e->kernel)), SD_JSON_BUILD_PAIR_CONDITION(!!e->efi, "efi", SD_JSON_BUILD_STRING(e->efi)), SD_JSON_BUILD_PAIR_CONDITION(!!e->uki, "uki", SD_JSON_BUILD_STRING(e->uki)), + SD_JSON_BUILD_PAIR_CONDITION(e->profile != UINT_MAX, "profile", SD_JSON_BUILD_UNSIGNED(e->profile)), SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(e->initrd), "initrd", SD_JSON_BUILD_STRV(e->initrd))); if (r < 0) return log_oom(); diff --git a/src/shared/bootspec.h b/src/shared/bootspec.h index 1be26d9d39f..47723689a60 100644 --- a/src/shared/bootspec.h +++ b/src/shared/bootspec.h @@ -65,6 +65,7 @@ typedef struct BootEntry { .source = (s), \ .tries_left = UINT_MAX, \ .tries_done = UINT_MAX, \ + .profile = UINT_MAX, \ } typedef struct BootConfig { diff --git a/src/shared/varlink-io.systemd.BootControl.c b/src/shared/varlink-io.systemd.BootControl.c index 2b990932d44..305fac5c381 100644 --- a/src/shared/varlink-io.systemd.BootControl.c +++ b/src/shared/varlink-io.systemd.BootControl.c @@ -48,6 +48,7 @@ static SD_VARLINK_DEFINE_STRUCT_TYPE( SD_VARLINK_DEFINE_FIELD(linux, SD_VARLINK_STRING, SD_VARLINK_NULLABLE), SD_VARLINK_DEFINE_FIELD(efi, SD_VARLINK_STRING, SD_VARLINK_NULLABLE), SD_VARLINK_DEFINE_FIELD(uki, SD_VARLINK_STRING, SD_VARLINK_NULLABLE), + SD_VARLINK_DEFINE_FIELD(profile, SD_VARLINK_INT, SD_VARLINK_NULLABLE), SD_VARLINK_DEFINE_FIELD(initrd, SD_VARLINK_STRING, SD_VARLINK_NULLABLE|SD_VARLINK_ARRAY), SD_VARLINK_DEFINE_FIELD(devicetree, SD_VARLINK_STRING, SD_VARLINK_NULLABLE), SD_VARLINK_DEFINE_FIELD(devicetreeOverlay, SD_VARLINK_STRING, SD_VARLINK_NULLABLE|SD_VARLINK_ARRAY),