]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
boot: Strip boot counter from entry id
authorDanilo Spinella <danilo.spinella@suse.com>
Thu, 11 Sep 2025 08:51:27 +0000 (10:51 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Wed, 17 Sep 2025 18:43:37 +0000 (19:43 +0100)
When boot counter is found in the boot entry filename, strip it from the
id to match bootctl id.

Fixes #38813.

src/boot/boot.c

index e1119589c9095ec75fafcda59fb2c2fa4d33bf91..eabfd6b6b2ebb1085c7d5bc8cdc2ecb5bc6ce2c9 100644 (file)
@@ -1165,6 +1165,10 @@ static void boot_entry_parse_tries(
         if (!strcaseeq16(counter, suffix))
                 return;
 
+        entry->id = xasprintf("%.*ls%ls",
+                        (int) prefix_len - 1,
+                        file,
+                        suffix);
         entry->tries_left = tries_left;
         entry->tries_done = tries_done;
         entry->directory = xstrdup16(directory);
@@ -1395,13 +1399,16 @@ static void boot_entry_add_type1(
         }
 
         entry->device = device;
-        entry->id = xstrdup16(file);
-        strtolower16(entry->id);
-
-        config_add_entry(config, entry);
 
         if (path)
                 boot_entry_parse_tries(entry, path, file, u".conf");
+
+        if (!entry->id)
+                entry->id = xstrdup16(file);
+
+        strtolower16(entry->id);
+
+        config_add_entry(config, entry);
         TAKE_PTR(entry);
 }