2007-05-18 Jeroen Dekkers <jeroen@dekkers.cx>

* util/getroot.c (grub_util_get_grub_dev): Support partitionable
	arrays.
	* disk/raid.c (grub_raid_open): Likewise.
This commit is contained in:
jeroen 2007-05-17 23:23:03 +00:00
parent 1ecb6cf2b4
commit 260ba823e6
3 changed files with 56 additions and 7 deletions

View file

@ -1,3 +1,9 @@
2007-05-18 Jeroen Dekkers <jeroen@dekkers.cx>
* util/getroot.c (grub_util_get_grub_dev): Support partitionable
arrays.
* disk/raid.c (grub_raid_open): Likewise.
2007-05-17 Jeroen Dekkers <jeroen@dekkers.cx>
* util/biosdisk.c (linux_find_partition): Allocate real_dev on the

View file

@ -1,7 +1,7 @@
/* raid.c - module to read RAID arrays. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2006 Free Software Foundation, Inc.
* Copyright (C) 2006, 2007 Free Software Foundation, Inc.
*
* GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -83,8 +83,7 @@ grub_raid_open (const char *name, grub_disk_t disk)
if (!array)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Unknown device");
/* FIXME: superblock version 1 supports partitions. */
disk->has_partitions = 0;
disk->has_partitions = 1;
disk->id = array->number;
disk->data = array;

View file

@ -256,11 +256,55 @@ grub_util_get_grub_dev (const char *os_dev)
/* Check for RAID. */
if (!strncmp (os_dev, "/dev/md", 7))
{
char *p, *grub_dev = xmalloc (8);
const char *p;
char *grub_dev = xmalloc (20);
if (os_dev[7] == '_' && os_dev[8] == 'd')
{
/* This a partitionable RAID device of the form /dev/md_dNNpMM. */
int i;
grub_dev[0] = 'm';
grub_dev[1] = 'd';
i = 2;
p = os_dev + 9;
while (*p >= '0' && *p <= '9')
{
grub_dev[i] = *p;
i++;
p++;
}
if (*p == '\0')
grub_dev[i] = '\0';
else if (*p == 'p')
{
p++;
grub_dev[i] = ',';
i++;
while (*p >= '0' && *p <= '9')
{
grub_dev[i] = *p;
i++;
p++;
}
grub_dev[i] = '\0';
}
else
grub_util_error ("Unknown kind of RAID device `%s'", os_dev);
}
else if (os_dev[7] >= '0' && os_dev[7] <= '9')
{
p = os_dev + 5;
memcpy (grub_dev, p, 7);
grub_dev[7] = '\0';
}
else
grub_util_error ("Unknown kind of RAID device `%s'", os_dev);
p = strchr (os_dev, 'm');
memcpy (grub_dev, p, 7);
grub_dev[7] = '\0';
return grub_dev;
}