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); }