|
|
d3c3ab |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
d3c3ab |
From: Daniel Axtens <dja@axtens.net>
|
|
|
d3c3ab |
Date: Thu, 24 Mar 2022 14:34:32 +1100
|
|
|
d3c3ab |
Subject: [PATCH] powerpc: prefix detection: support device names with commas
|
|
|
d3c3ab |
|
|
|
d3c3ab |
Frustratingly, the device name itself can contain an embedded comma:
|
|
|
d3c3ab |
e.g /pci@800000020000015/pci1014,034A@0/sas/disk@5000c50098a0ee8b
|
|
|
d3c3ab |
|
|
|
d3c3ab |
So my previous approach was wrong: we cannot rely upon the presence
|
|
|
d3c3ab |
of a comma to say that a partition has been specified!
|
|
|
d3c3ab |
|
|
|
d3c3ab |
It turns out for prefixes like (,gpt2)/grub2 we really want to make
|
|
|
d3c3ab |
up a full (device,partition)/patch prefix, because root discovery code
|
|
|
d3c3ab |
in 10_linux will reset the root variable and use search to fill it again.
|
|
|
d3c3ab |
If you have run grub-install, you probably don't have search built in,
|
|
|
d3c3ab |
and if you don't have prefix containing (device,partition), grub will
|
|
|
d3c3ab |
construct ($root)$prefix/powerpc-ieee1275/search.mod - but because $root
|
|
|
d3c3ab |
has just been changed, this will no longer work, and the boot will fail!
|
|
|
d3c3ab |
|
|
|
d3c3ab |
Retain the gist of the logic, but instead of looking for a comma, look for
|
|
|
d3c3ab |
a leading '('. This matches the earlier code better anyway.
|
|
|
d3c3ab |
|
|
|
d3c3ab |
There's certainly a better fix to be had. But any time you chose to build
|
|
|
d3c3ab |
with a bare prefix like '/grub2', you're almost certainly going to build in
|
|
|
d3c3ab |
search anyway, so this will do.
|
|
|
d3c3ab |
|
|
|
d3c3ab |
Signed-off-by: Daniel Axtens <dja@axtens.net>
|
|
|
d3c3ab |
---
|
|
|
d3c3ab |
grub-core/kern/main.c | 27 +++++++++++++++++++++------
|
|
|
d3c3ab |
1 file changed, 21 insertions(+), 6 deletions(-)
|
|
|
d3c3ab |
|
|
|
d3c3ab |
diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c
|
|
|
fd0330 |
index 993b8a8598..e94a2f78fb 100644
|
|
|
d3c3ab |
--- a/grub-core/kern/main.c
|
|
|
d3c3ab |
+++ b/grub-core/kern/main.c
|
|
|
d3c3ab |
@@ -242,14 +242,29 @@ grub_set_prefix_and_root (void)
|
|
|
d3c3ab |
what sorts of paths represent disks with partition tables and those
|
|
|
d3c3ab |
without partition tables.
|
|
|
d3c3ab |
|
|
|
d3c3ab |
- So we act unless there is a comma in the device, which would indicate
|
|
|
d3c3ab |
- a partition has already been specified.
|
|
|
d3c3ab |
+ - Frustratingly, the device name itself can contain an embedded comma:
|
|
|
d3c3ab |
+ /pci@800000020000015/pci1014,034A@0/sas/disk@5000c50098a0ee8b
|
|
|
d3c3ab |
+ So we cannot even rely upon the presence of a comma to say that a
|
|
|
d3c3ab |
+ partition has been specified!
|
|
|
d3c3ab |
|
|
|
d3c3ab |
- (If we only have a path, the code in normal to discover config files
|
|
|
d3c3ab |
- will try both without partitions and then with any partitions so we
|
|
|
d3c3ab |
- will cover both CDs and HDs.)
|
|
|
d3c3ab |
+ If we only have a path in $prefix, the code in normal to discover
|
|
|
d3c3ab |
+ config files will try all disks, both without partitions and then with
|
|
|
d3c3ab |
+ any partitions so we will cover both CDs and HDs.
|
|
|
d3c3ab |
+
|
|
|
d3c3ab |
+ However, it doesn't then set the prefix to be something like
|
|
|
d3c3ab |
+ (discovered partition)/path, and so it is fragile against runtime
|
|
|
d3c3ab |
+ changes to $root. For example some of the stuff done in 10_linux to
|
|
|
d3c3ab |
+ reload $root sets root differently and then uses search to find it
|
|
|
d3c3ab |
+ again. If the search module is not built in, when we change root, grub
|
|
|
d3c3ab |
+ will look in (new root)/path/powerpc-ieee1275, that won't work, and we
|
|
|
d3c3ab |
+ will not be able to load the search module and the boot will fail.
|
|
|
d3c3ab |
+
|
|
|
d3c3ab |
+ This is particularly likely to hit us in the grub-install
|
|
|
d3c3ab |
+ (,msdos2)/grub2 case, so we act unless the supplied prefix starts with
|
|
|
d3c3ab |
+ '(', which would likely indicate a partition has already been
|
|
|
d3c3ab |
+ specified.
|
|
|
d3c3ab |
*/
|
|
|
d3c3ab |
- if (grub_strchr (device, ',') == NULL)
|
|
|
d3c3ab |
+ if (prefix && prefix[0] != '(')
|
|
|
d3c3ab |
grub_env_set ("prefix", path);
|
|
|
d3c3ab |
else
|
|
|
d3c3ab |
#endif
|