]> 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>
Fri, 10 Oct 2025 08:31:45 +0000 (10:31 +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)

src/boot/boot.c

index fc658e49d6d3009694a5e13263ce13538e5374d0..582e17c70ad95172b9347aa9c947155a1ed2ffaf 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->path = xstrdup16(path);
@@ -1395,7 +1399,9 @@ static void boot_entry_add_type1(
         }
 
         entry->device = device;
-        entry->id = xstrdup16(file);
+
+        if (!entry->id)
+                entry->id = xstrdup16(file);
         strtolower16(entry->id);
 
         config_add_entry(config, entry);