From 4b0782664739170dc3688a55e667a56146128e78 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 8 Jan 2011 16:33:49 +0100 Subject: [PATCH] partitioned mdraid support (untested) --- grub-core/kern/emu/getroot.c | 2 +- grub-core/kern/emu/hostdisk.c | 15 ++++++++++----- include/grub/emu/misc.h | 2 ++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/grub-core/kern/emu/getroot.c b/grub-core/kern/emu/getroot.c index a99bee9a4..0035c734a 100644 --- a/grub-core/kern/emu/getroot.c +++ b/grub-core/kern/emu/getroot.c @@ -639,7 +639,7 @@ grub_util_get_dev_abstraction (const char *os_dev __attribute__((unused))) return GRUB_DEV_ABSTRACTION_LVM; /* Check for RAID. */ - if (!strncmp (os_dev, "/dev/md", 7)) + if (!strncmp (os_dev, "/dev/md", 7) && ! grub_util_device_is_mapped (os_dev)) return GRUB_DEV_ABSTRACTION_RAID; #endif diff --git a/grub-core/kern/emu/hostdisk.c b/grub-core/kern/emu/hostdisk.c index ee3cc0a36..eb84d0220 100644 --- a/grub-core/kern/emu/hostdisk.c +++ b/grub-core/kern/emu/hostdisk.c @@ -325,18 +325,23 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk) return GRUB_ERR_NONE; } -#ifdef HAVE_DEVICE_MAPPER -static int -device_is_mapped (const char *dev) +int +grub_util_device_is_mapped (const char *dev) { +#ifdef HAVE_DEVICE_MAPPER struct stat st; + if (!grub_device_mapper_supported ()) + return 0; + if (stat (dev, &st) < 0) return 0; return dm_is_dm_major (major (st.st_rdev)); -} +#else + return 0; #endif /* HAVE_DEVICE_MAPPER */ +} #if defined(__linux__) || defined(__CYGWIN__) || defined(HAVE_DIOCGDINFO) static grub_disk_addr_t @@ -351,7 +356,7 @@ find_partition_start (const char *dev) # endif /* !defined(HAVE_DIOCGDINFO) */ # ifdef HAVE_DEVICE_MAPPER - if (grub_device_mapper_supported () && device_is_mapped (dev)) { + if (grub_util_device_is_mapped (dev)) { struct dm_task *task = NULL; grub_uint64_t start, length; char *target_type, *params, *space; diff --git a/include/grub/emu/misc.h b/include/grub/emu/misc.h index ef0d18300..03909e025 100644 --- a/include/grub/emu/misc.h +++ b/include/grub/emu/misc.h @@ -54,6 +54,8 @@ void grub_find_zpool_from_dir (const char *dir, char *grub_make_system_path_relative_to_its_root (const char *path) __attribute__ ((warn_unused_result)); +int +grub_util_device_is_mapped (const char *dev); void * EXPORT_FUNC(xmalloc) (grub_size_t size) __attribute__ ((warn_unused_result)); void * EXPORT_FUNC(xrealloc) (void *ptr, grub_size_t size) __attribute__ ((warn_unused_result));