summaryrefslogtreecommitdiffstats
path: root/src/shared
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2024-07-05 09:52:58 +0200
committerLennart Poettering <lennart@poettering.net>2024-07-12 06:30:22 +0200
commit35451a32043504013eed5725c8be46b36ccdf71a (patch)
treefe34474bc6624d7dde862ecb6cd8eebd00b27214 /src/shared
parentboot: compare filename suffixes without case (diff)
downloadsystemd-35451a32043504013eed5725c8be46b36ccdf71a.tar.xz
systemd-35451a32043504013eed5725c8be46b36ccdf71a.zip
bootspec: implement sorting by tries left/done, to match what sd-boot does
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/bootspec.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/shared/bootspec.c b/src/shared/bootspec.c
index 05b1d04506..e7aace151b 100644
--- a/src/shared/bootspec.c
+++ b/src/shared/bootspec.c
@@ -505,6 +505,12 @@ static int boot_entry_compare(const BootEntry *a, const BootEntry *b) {
assert(a);
assert(b);
+ /* This mimics a function of the same name in src/boot/efi/sd-boot.c */
+
+ r = CMP(a->tries_left == 0, b->tries_left == 0);
+ if (r != 0)
+ return r;
+
r = CMP(!a->sort_key, !b->sort_key);
if (r != 0)
return r;
@@ -523,7 +529,18 @@ static int boot_entry_compare(const BootEntry *a, const BootEntry *b) {
return r;
}
- return -strverscmp_improved(a->id, b->id);
+ r = -strverscmp_improved(a->id, b->id);
+ if (r != 0)
+ return r;
+
+ if (a->tries_left != UINT_MAX || b->tries_left != UINT_MAX)
+ return 0;
+
+ r = -CMP(a->tries_left, b->tries_left);
+ if (r != 0)
+ return r;
+
+ return CMP(a->tries_done, b->tries_done);
}
static int config_check_inode_relevant_and_unseen(BootConfig *config, int fd, const char *fname) {