From 56445fb2b459f3dce2b7dc8b70cf9db90aae9d88 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 30 Mar 2011 16:37:10 +0200 Subject: [PATCH] * grub-core/kern/emu/getroot.c (grub_util_get_grub_dev) [__linux__]: Preserve partition number in mdadm code path. --- ChangeLog | 5 +++++ grub-core/kern/emu/getroot.c | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/ChangeLog b/ChangeLog index b93141df6..0afcadf68 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-03-30 Vladimir Serbinenko + + * grub-core/kern/emu/getroot.c (grub_util_get_grub_dev) [__linux__]: + Preserve partition number in mdadm code path. + 2011-03-30 Vladimir Serbinenko * grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_get_grub_dev): Add diff --git a/grub-core/kern/emu/getroot.c b/grub-core/kern/emu/getroot.c index 1d87442d9..ae066d2f8 100644 --- a/grub-core/kern/emu/getroot.c +++ b/grub-core/kern/emu/getroot.c @@ -808,12 +808,30 @@ grub_util_get_grub_dev (const char *os_dev) if (mdadm_name) { char *newname; + char *q; + + for (q = os_dev + strlen (os_dev) - 1; q >= os_dev && isdigit (*q); + q--); + + if (q >= os_dev && *q == 'p') + { + newname = xasprintf ("/dev/md/%sp%s", mdadm_name, q + 1); + if (stat (newname, &st) == 0) + { + free (grub_dev); + grub_dev = xasprintf ("md/%s,%s", mdadm_name, q + 1); + goto done; + } + free (newname); + } newname = xasprintf ("/dev/md/%s", mdadm_name); if (stat (newname, &st) == 0) { free (grub_dev); grub_dev = xasprintf ("md/%s", mdadm_name); } + + done: free (newname); free (mdadm_name); }