* grub-core/kern/emu/getroot.c (grub_util_get_grub_dev) [__linux__]:

Preserve partition number in mdadm code path.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-03-30 16:37:10 +02:00
parent c871b1c6d0
commit 56445fb2b4
2 changed files with 23 additions and 0 deletions

View file

@ -1,3 +1,8 @@
2011-03-30 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/emu/getroot.c (grub_util_get_grub_dev) [__linux__]:
Preserve partition number in mdadm code path.
2011-03-30 Vladimir Serbinenko <phcoder@gmail.com> 2011-03-30 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_get_grub_dev): Add * grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_get_grub_dev): Add

View file

@ -808,12 +808,30 @@ grub_util_get_grub_dev (const char *os_dev)
if (mdadm_name) if (mdadm_name)
{ {
char *newname; 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); newname = xasprintf ("/dev/md/%s", mdadm_name);
if (stat (newname, &st) == 0) if (stat (newname, &st) == 0)
{ {
free (grub_dev); free (grub_dev);
grub_dev = xasprintf ("md/%s", mdadm_name); grub_dev = xasprintf ("md/%s", mdadm_name);
} }
done:
free (newname); free (newname);
free (mdadm_name); free (mdadm_name);
} }