]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/bootspec: parse 'profile' boot entry option
authorFelix Pehla <29adc1fd92@gmail.com>
Sun, 28 Sep 2025 16:50:06 +0000 (18:50 +0200)
committerFelix Pehla <29adc1fd92@gmail.com>
Mon, 29 Sep 2025 21:01:12 +0000 (23:01 +0200)
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
src/shared/bootspec.h
src/shared/varlink-io.systemd.BootControl.c

index 2054ea6fb88cbc5fc27b74ede3ca594abd7a35f3..9fa50608f5f4fd0926d72d54139175305eafe4f3 100644 (file)
@@ -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();
index 1be26d9d39f4902d827df98e526d5baa3f2acc9d..47723689a60cfaa19b70f8cb2088b085ac33b64f 100644 (file)
@@ -65,6 +65,7 @@ typedef struct BootEntry {
                 .source = (s),                  \
                 .tries_left = UINT_MAX,         \
                 .tries_done = UINT_MAX,         \
+                .profile = UINT_MAX,            \
         }
 
 typedef struct BootConfig {
index 2b990932d44f267f137307d7bdffed5d931d476d..305fac5c381d7fe3e0f7ee0ca38024c0eb69bc06 100644 (file)
@@ -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),