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

Bug#477090: grub-installer: no support for dmraid and multipath for grub2



clone 477090 -1
retitle -1 support for multipath
reassign -1 grub2
thanks

On Sun, Apr 20, 2008 at 11:09:28PM +0200, Frans Pop wrote:
> 
> grub-installer should also support setting up dmraid and multipath when 
> grub2 is selected.

The attached patch should add support for multipath.  However, I can't
test it myself.

If someone can confirm it works, I'll get it applied in upstream.

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What good is a phone call… if you are unable to speak?
(as seen on /.)
diff -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/util/biosdisk.c ./util/biosdisk.c
--- ../grub2/util/biosdisk.c	2008-05-31 11:42:33.000000000 +0200
+++ ./util/biosdisk.c	2008-06-01 16:40:22.000000000 +0200
@@ -210,7 +210,7 @@ linux_find_partition (char *dev, unsigne
 {
   size_t len = strlen (dev);
   const char *format;
-  char *p;
+  char *p = NULL;
   int i;
   char real_dev[PATH_MAX];
 
@@ -221,17 +221,22 @@ linux_find_partition (char *dev, unsigne
       p = real_dev + len - 4;
       format = "part%d";
     }
+  else if (strncmp (real_dev + 5, "mapper/mpath", sizeof ("mapper/mpath") - 1) == 0)
+    {
+      format = "-part%d";
+    }
   else if (real_dev[len - 1] >= '0' && real_dev[len - 1] <= '9')
     {
-      p = real_dev + len;
       format = "p%d";
     }
   else
     {
-      p = real_dev + len;
       format = "%d";
     }
 
+  if (! p)
+    p = real_dev + len;
+
   for (i = 1; i < 10000; i++)
     {
       int fd;
@@ -646,6 +651,17 @@ get_os_disk (const char *os_dev)
 	  return path;
 	}
       
+      /* If this is a Multipath disk.  */
+      if (strncmp ("mapper/mpath", p, sizeof ("mapper/mpath") - 1) == 0)
+	{
+	  /* /dev/mapper/mpath[0-9]+(-part[0-9]+)? */
+	  p = strchr (p, '-');
+	  if (p)
+	    *p = '\0';
+
+	  return path;
+	}
+      
       /* If this is a MultiMediaCard (MMC).  */
       if (strncmp ("mmcblk", p, sizeof ("mmcblk") - 1) == 0)
 	{
diff -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/util/grub-mkdevicemap.c ./util/grub-mkdevicemap.c
--- ../grub2/util/grub-mkdevicemap.c	2008-05-29 15:02:13.000000000 +0200
+++ ./util/grub-mkdevicemap.c	2008-06-01 16:44:47.000000000 +0200
@@ -297,6 +297,12 @@ get_cciss_disk_name (char *name, int con
 }
 
 static void
+get_multipath_disk_name (char *name, int drive)
+{
+  sprintf (name, "/dev/mapper/mpath%d", drive);
+}
+
+static void
 get_mmc_disk_name (char *name, int unit)
 {
   sprintf (name, "/dev/mmcblk%d", unit);
@@ -620,6 +626,22 @@ make_device_map (const char *device_map,
 	}
     }
 
+  /* Multipath.  */
+  for (i = 0; i < 10; i++)
+    {
+      char name[24];
+      
+      get_multipath_disk_name (name, i);
+      if (check_device (name))
+	{
+	  char *p;
+	  p = grub_util_get_disk_name (num_hd, name);
+	  fprintf (fp, "(%s)\t%s\n", p, name);
+	  free (p);
+	  num_hd++;
+	}
+    }
+
  finish:
 #endif /* __linux__ */
 

Reply to: