From 260ba823e64338141173d754728fff8bb639876c Mon Sep 17 00:00:00 2001 From: jeroen Date: Thu, 17 May 2007 23:23:03 +0000 Subject: [PATCH] 2007-05-18 Jeroen Dekkers * util/getroot.c (grub_util_get_grub_dev): Support partitionable arrays. * disk/raid.c (grub_raid_open): Likewise. --- ChangeLog | 6 ++++++ disk/raid.c | 5 ++--- util/getroot.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 63f58985e..c453fc36e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-05-18 Jeroen Dekkers + + * util/getroot.c (grub_util_get_grub_dev): Support partitionable + arrays. + * disk/raid.c (grub_raid_open): Likewise. + 2007-05-17 Jeroen Dekkers * util/biosdisk.c (linux_find_partition): Allocate real_dev on the diff --git a/disk/raid.c b/disk/raid.c index 52d2f0cd0..2965f10e9 100644 --- a/disk/raid.c +++ b/disk/raid.c @@ -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; diff --git a/util/getroot.c b/util/getroot.c index 47ca8f9ca..94e20ad23 100644 --- a/util/getroot.c +++ b/util/getroot.c @@ -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; }