grub.cfg: search a reduced list of devs/partitions

in practise, the machines we support don't have
the option of including so many disks; 8 seems like
the most reasonable default. additionally, it's
unreasonable to expect *20 partitions*

this hardcoding is done to avoid using *, which is
slow in grub on some machines (the grub kernel always
re-enumerates the devices during every operation,
without caching any of it)

yet, the hardcoding is also slow; balance it a bit
better by searching fewer permutations, but not so few
that it would likely break a lot of setups

Signed-off-by: Leah Rowe <leah@libreboot.org>
audit2-merge1
Leah Rowe 2024-06-01 17:04:31 +01:00 committed by Leah Rowe
parent 71a17efc06
commit 36b3be95cf
1 changed files with 6 additions and 6 deletions

View File

@ -81,8 +81,8 @@ function try_user_config {
} }
function search_grub { function search_grub {
echo -n "Attempting to load grub.cfg from '${1}' devices" echo -n "Attempting to load grub.cfg from '${1}' devices"
for i in 0 1 2 3 4 5 6 7 8 9 10 11; do for i in 0 1 2 3 4 5 6 7 8; do
for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do for part in 1 2 3 4 5 6 7 8 9 10 11 12; do
if [ "${1}" != "nvme" ]; then if [ "${1}" != "nvme" ]; then
try_user_config "(${1}${i},${part})" try_user_config "(${1}${i},${part})"
else else
@ -117,8 +117,8 @@ function try_isolinux_config {
} }
function search_isolinux { function search_isolinux {
echo "\nAttempting to parse iso/sys/extlinux config from '${1}' devices" echo "\nAttempting to parse iso/sys/extlinux config from '${1}' devices"
for i in 0 1 2 3 4 5 6 7 8 9 10 11; do for i in 0 1 2 3 4 5 6 7 8; do
for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do for part in 1 2 3 4 5 6 7 8 9 10 11 12; do
if [ "${1}" != "nvme" ]; then if [ "${1}" != "nvme" ]; then
try_isolinux_config "(${1}${i},${part})" try_isolinux_config "(${1}${i},${part})"
else else
@ -167,8 +167,8 @@ menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o
unset bootdev unset bootdev
for grub_disk in ${grub_scan_disk}; do for grub_disk in ${grub_scan_disk}; do
for i in 0 1 2 3 4 5 6 7 8 9 10 11; do for i in 0 1 2 3 4 5 6 7 8; do
for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do for part in 1 2 3 4 5 6 7 8 9 10 11 12; do
if [ "${grub_disk}" = "ahci" ]; then if [ "${grub_disk}" = "ahci" ]; then
bootdev="${bootdev} (ahci${i},${part})" bootdev="${bootdev} (ahci${i},${part})"
elif [ "${grub_disk}" = "ata" ]; then elif [ "${grub_disk}" = "ata" ]; then