grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Software RAID (fakeraid) support for Linux device mapper


From: Raphael Bossek
Subject: Re: [PATCH] Software RAID (fakeraid) support for Linux device mapper
Date: Thu, 5 Aug 2010 10:34:48 +0200

Hi GRUB-developers,

here an update of my patch which apply clean with Colin's Debian
1.98+20100804 release.
Coments are welcome in hope my modification will be applied upstream
because I've to do this for my confing each time Colin release a new
version of grub2 for Debian ;-)

--->8--->8--->8--->8--->8--->8--->8---
diff -r 1de1becf5f1b include/grub/emu/misc.h
--- a/include/grub/emu/misc.h   Thu Aug 05 10:27:19 2010 +0200
+++ b/include/grub/emu/misc.h   Thu Aug 05 10:29:04 2010 +0200
@@ -36,6 +36,7 @@
 #else
 # define DEFAULT_DIRECTORY     "/boot/grub"
 #endif
+int device_is_mapped (const char *dev);

 #define DEFAULT_DEVICE_MAP     DEFAULT_DIRECTORY "/device.map"

diff -r 1de1becf5f1b kern/emu/getroot.c
--- a/kern/emu/getroot.c        Thu Aug 05 10:27:19 2010 +0200
+++ b/kern/emu/getroot.c        Thu Aug 05 10:29:04 2010 +0200
@@ -147,9 +147,6 @@
       free (ret);
       ret = NULL;

-      if (major != 0)
-       continue; /* not a virtual device */
-
       sep = strstr (buf + count, " - ");
       if (!sep)
        continue;
@@ -164,6 +161,9 @@
       if (!S_ISBLK (st.st_mode))
        continue; /* not a block device */

+      if (major != 0 && ! device_is_mapped (device))
+       continue; /* not a virtual device */
+
       ret = strdup (device);
     }

diff -r 1de1becf5f1b kern/emu/hostdisk.c
--- a/kern/emu/hostdisk.c       Thu Aug 05 10:27:19 2010 +0200
+++ b/kern/emu/hostdisk.c       Thu Aug 05 10:29:04 2010 +0200
@@ -316,19 +316,6 @@
   return GRUB_ERR_NONE;
 }

-#ifdef HAVE_DEVICE_MAPPER
-static int
-device_is_mapped (const char *dev)
-{
-  struct stat st;
-
-  if (stat (dev, &st) < 0)
-    return 0;
-
-  return dm_is_dm_major (major (st.st_rdev));
-}
-#endif /* HAVE_DEVICE_MAPPER */
-
 #if defined(__linux__) || defined(__CYGWIN__) || defined(__NetBSD__)
 static grub_disk_addr_t
 find_partition_start (const char *dev)
@@ -342,7 +329,7 @@
 # endif /* !defined(__NetBSD__) */

 # ifdef HAVE_DEVICE_MAPPER
-  if (grub_device_mapper_supported () && device_is_mapped (dev)) {
+  if (device_is_mapped (dev)) {
     struct dm_task *task = NULL;
     grub_uint64_t start, length;
     char *target_type, *params, *space;
@@ -1145,7 +1132,7 @@

 #ifdef HAVE_DEVICE_MAPPER
       /* If this is a DM-RAID device.  */
-      if ((strncmp ("mapper/", p, 7) == 0))
+      if (device_is_mapped (path))
        {
          static struct dm_tree *tree = NULL;
          uint32_t maj, min;
diff -r 1de1becf5f1b kern/emu/misc.c
--- a/kern/emu/misc.c   Thu Aug 05 10:27:19 2010 +0200
+++ b/kern/emu/misc.c   Thu Aug 05 10:29:04 2010 +0200
@@ -551,3 +551,21 @@
   return supported;
 }
 #endif /* HAVE_DEVICE_MAPPER */
+
+int
+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 */
+}
---8<---8<---8<---8<---8<---8<---8<---8<---

Greetings,
Raphael

Attachment: bossekr-fakeraid.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]