sd-boot: fix menu ordering with boot counting
systemd-boot selects the last valid entry by default, not the first. Fixes: #15256
This commit is contained in:
parent
2d2d75047e
commit
e6190e2882
|
@ -101,9 +101,9 @@ Here's an example walkthrough of how this all fits together.
|
||||||
|
|
||||||
6. If this boot also fails, on the next boot the boot loader will see the
|
6. If this boot also fails, on the next boot the boot loader will see the
|
||||||
tag `+0-3`, i.e. the counter reached zero. At this point the entry will be
|
tag `+0-3`, i.e. the counter reached zero. At this point the entry will be
|
||||||
considered "bad", and ordered to the end of the list of entries. The next
|
considered "bad", and ordered to the beginning of the list of entries. The
|
||||||
newest boot entry is now tried, i.e. the system automatically reverted back
|
next newest boot entry is now tried, i.e. the system automatically reverted
|
||||||
to an earlier version.
|
back to an earlier version.
|
||||||
|
|
||||||
The above describes the walkthrough when the selected boot entry continuously
|
The above describes the walkthrough when the selected boot entry continuously
|
||||||
fails. Let's have a look at an alternative ending to this walkthrough. In this
|
fails. Let's have a look at an alternative ending to this walkthrough. In this
|
||||||
|
|
|
@ -476,10 +476,10 @@
|
||||||
considered 'good' from then on.</para>
|
considered 'good' from then on.</para>
|
||||||
|
|
||||||
<para>The boot menu takes the 'tries left' counter into account when sorting the menu entries: entries in 'bad'
|
<para>The boot menu takes the 'tries left' counter into account when sorting the menu entries: entries in 'bad'
|
||||||
state are ordered at the end of the list, and entries in 'good' or 'indeterminate' at the beginning. The user can
|
state are ordered at the beginning of the list, and entries in 'good' or 'indeterminate' at the end. The user can
|
||||||
freely choose to boot any entry of the menu, including those already marked 'bad'. If the menu entry to boot is
|
freely choose to boot any entry of the menu, including those already marked 'bad'. If the menu entry to boot is
|
||||||
automatically determined, this means that 'good' or 'indeterminate' entries are generally preferred (as the top item of
|
automatically determined, this means that 'good' or 'indeterminate' entries are generally preferred (as the bottom
|
||||||
the menu is the one booted by default), and 'bad' entries will only be considered if there are no 'good' or
|
item of the menu is the one booted by default), and 'bad' entries will only be considered if there are no 'good' or
|
||||||
'indeterminate' entries left.</para>
|
'indeterminate' entries left.</para>
|
||||||
|
|
||||||
<para>The <citerefentry><refentrytitle>kernel-install</refentrytitle><manvolnum>8</manvolnum></citerefentry> kernel
|
<para>The <citerefentry><refentrytitle>kernel-install</refentrytitle><manvolnum>8</manvolnum></citerefentry> kernel
|
||||||
|
|
|
@ -1519,11 +1519,11 @@ static VOID config_load_entries(
|
||||||
static INTN config_entry_compare(ConfigEntry *a, ConfigEntry *b) {
|
static INTN config_entry_compare(ConfigEntry *a, ConfigEntry *b) {
|
||||||
INTN r;
|
INTN r;
|
||||||
|
|
||||||
/* Order entries that have no tries left to the end of the list */
|
/* Order entries that have no tries left to the beginning of the list */
|
||||||
if (a->tries_left != 0 && b->tries_left == 0)
|
if (a->tries_left != 0 && b->tries_left == 0)
|
||||||
return -1;
|
|
||||||
if (a->tries_left == 0 && b->tries_left != 0)
|
|
||||||
return 1;
|
return 1;
|
||||||
|
if (a->tries_left == 0 && b->tries_left != 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
r = str_verscmp(a->id, b->id);
|
r = str_verscmp(a->id, b->id);
|
||||||
if (r != 0)
|
if (r != 0)
|
||||||
|
@ -1533,17 +1533,17 @@ static INTN config_entry_compare(ConfigEntry *a, ConfigEntry *b) {
|
||||||
b->tries_left == (UINTN) -1)
|
b->tries_left == (UINTN) -1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* If both items have boot counting, and otherwise are identical, put the entry with more tries left first */
|
/* If both items have boot counting, and otherwise are identical, put the entry with more tries left last */
|
||||||
if (a->tries_left > b->tries_left)
|
if (a->tries_left > b->tries_left)
|
||||||
return -1;
|
|
||||||
if (a->tries_left < b->tries_left)
|
|
||||||
return 1;
|
return 1;
|
||||||
|
if (a->tries_left < b->tries_left)
|
||||||
|
return -1;
|
||||||
|
|
||||||
/* If they have the same number of tries left, then let the one win which was tried fewer times so far */
|
/* If they have the same number of tries left, then let the one win which was tried fewer times so far */
|
||||||
if (a->tries_done < b->tries_done)
|
if (a->tries_done < b->tries_done)
|
||||||
return -1;
|
|
||||||
if (a->tries_done > b->tries_done)
|
|
||||||
return 1;
|
return 1;
|
||||||
|
if (a->tries_done > b->tries_done)
|
||||||
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue