1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-09 01:18:19 +03:00

bootspec: implement sorting by tries left/done, to match what sd-boot does

(cherry picked from commit 35451a3204)
This commit is contained in:
Lennart Poettering 2024-07-05 09:52:58 +02:00 committed by Luca Boccassi
parent 18143edf3e
commit 3736e21341

View File

@ -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) {