]> 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)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 13 Oct 2025 08:04:47 +0000 (10:04 +0200)
When boot counter is found in the boot entry filename, strip it from the
id to match bootctl id.

Fixes #38813.

(cherry picked from commit 4301ad00ef715885be5c3bdf84c152030b7d36ff)
(cherry picked from commit e67e5145675b1849a554aeab4a32badd7d260f9f)

src/boot/boot.c

index 053a79dd460ae2859a4d1add091cf4a2ab931dc2..570fb18ce2154db7417c448bfa9f0da14ae7b256 100644 (file)
@@ -1359,6 +1359,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->path = xstrdup16(path);
@@ -1531,7 +1535,9 @@ static void boot_entry_add_type1(
                 return;
 
         entry->device = device;
-        entry->id = xstrdup16(file);
+
+        if (!entry->id)
+                entry->id = xstrdup16(file);
         strtolower16(entry->id);
 
         config_add_entry(config, entry);