aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2022-05-26 00:58:21 +0200
committerDaniel Kiper <daniel.kiper@oracle.com>2022-06-07 13:31:33 +0200
commite981b0a248ba62683ff574863656d7b0aae7fa12 (patch)
tree78931d23c2a0dfe073eeed865d65ef779919efd0
parentd46e65328ec7ca660063f623283be0874c7321e9 (diff)
downloadgrub-e981b0a248ba62683ff574863656d7b0aae7fa12.tar.gz
osdep/hurd/getroot: Use "part:" qualifier
When using userland drivers such as rumpdisk, we'd rather make ext2fs use parted-based libstore partitioning support. That can be used for kernelland drivers as well, so we can just make GRUB always use the "part:" qualifier to switch ext2fs to it. grub_util_find_hurd_root_device() then has to understand this syntax and translate it into the /dev/ entry name. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
-rw-r--r--grub-core/osdep/hurd/getroot.c18
-rw-r--r--util/grub.d/10_hurd.in4
2 files changed, 17 insertions, 5 deletions
diff --git a/grub-core/osdep/hurd/getroot.c b/grub-core/osdep/hurd/getroot.c
index 69af72206..af31f2c47 100644
--- a/grub-core/osdep/hurd/getroot.c
+++ b/grub-core/osdep/hurd/getroot.c
@@ -109,6 +109,16 @@ grub_util_find_hurd_root_device (const char *path)
grub_util_error (_("translator `%s' for path `%s' is given only options, "
"cannot find device part"), argz, path);
+ int part = -1;
+ if (strncmp (name, "part:", sizeof ("part:") - 1) == 0)
+ {
+ char *next = strchr (name + sizeof ("part:") - 1, ':');
+ if (next)
+ {
+ part = atoi (name + sizeof ("part:") - 1);
+ name = next + 1;
+ }
+ }
if (strncmp (name, "device:", sizeof ("device:") - 1) == 0)
{
char *dev_name = name + sizeof ("device:") - 1;
@@ -127,10 +137,10 @@ grub_util_find_hurd_root_device (const char *path)
dev_name = next_name + 1;
}
- size = sizeof ("/dev/") - 1 + strlen (dev_name) + 1;
- ret = xmalloc (size);
- next = stpncpy (ret, "/dev/", size);
- stpncpy (next, dev_name, size - (next - ret));
+ if (part >= 0)
+ ret = xasprintf("/dev/%ss%u", dev_name, part);
+ else
+ ret = xasprintf("/dev/%s", dev_name);
}
else if (!strncmp (name, "file:", sizeof ("file:") - 1))
ret = strdup (name + sizeof ("file:") - 1);
diff --git a/util/grub.d/10_hurd.in b/util/grub.d/10_hurd.in
index 2ab3a97e6..2fafa4e59 100644
--- a/util/grub.d/10_hurd.in
+++ b/util/grub.d/10_hurd.in
@@ -128,9 +128,11 @@ EOF
else
opts=
fi
+ device=device:${GRUB_DEVICE#/dev/}
+ device=$(echo "$device" | sed -e 's/^device:\(.*[0-9]\+\)s\([0-9]\+\)$/part:\2:device:\1'/)
sed "s/^/$submenu_indentation/" << EOF
echo '$(echo "$message" | grub_quote)'
- multiboot ${kernel} root=device:${GRUB_DEVICE#/dev/} $opts ${GRUB_CMDLINE_GNUMACH}
+ multiboot ${kernel} root=$device $opts ${GRUB_CMDLINE_GNUMACH}
EOF
if [ x$type != xrecovery ] ; then