]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
handle DM-RAID disks in convert_system_partition_to_system_disk
authorColin Watson <cjwatson@ubuntu.com>
Sun, 31 Jan 2010 19:37:37 +0000 (19:37 +0000)
committerColin Watson <cjwatson@ubuntu.com>
Sun, 31 Jan 2010 19:37:37 +0000 (19:37 +0000)
ChangeLog.dmraid-probe
util/hostdisk.c

index 505cf7ba4b08404699035e0840305dcff8cc3b36..c52436bb56d26a87975c553a5d8b17f49f4c0e6f 100644 (file)
@@ -1,4 +1,4 @@
-2010-01-26  Colin Watson  <cjwatson@ubuntu.com>
+2010-01-31  Colin Watson  <cjwatson@ubuntu.com>
 
        * configure.ac: Check for Linux device-mapper support.
 
index 309e112bf72ef211446836990882ee28eca36371..464977978ccce48ee3bda36e18080f9f0843f99d 100644 (file)
@@ -937,7 +937,7 @@ convert_system_partition_to_system_disk (const char *os_dev, struct stat *st)
          uint32_t maj, min;
          struct dm_tree_node *node, *child;
          void *handle;
-         const char *node_uuid, *child_uuid, *child_name;
+         const char *node_uuid, *mapper_name, *child_uuid, *child_name;
 
          if (! tree)
            tree = dm_tree_create ();
@@ -975,6 +975,7 @@ convert_system_partition_to_system_disk (const char *os_dev, struct stat *st)
            }
 
          handle = NULL;
+         mapper_name = NULL;
          /* Counter-intuitively, device-mapper refers to the disk-like
             device containing a DM-RAID partition device as a "child" of
             the partition device.  */
@@ -982,27 +983,39 @@ convert_system_partition_to_system_disk (const char *os_dev, struct stat *st)
          if (! child)
            {
              grub_dprintf ("hostdisk", "%s has no DM children\n", path);
-             return NULL;
+             goto devmapper_out;
            }
          child_uuid = dm_tree_node_get_uuid (child);
          if (! child_uuid)
            {
              grub_dprintf ("hostdisk", "%s child has no DM uuid\n", path);
-             return NULL;
+             goto devmapper_out;
            }
          else if (strncmp (child_uuid, "DMRAID-", 7) != 0)
            {
              grub_dprintf ("hostdisk", "%s child is not DM-RAID\n", path);
-             return NULL;
+             goto devmapper_out;
            }
          child_name = dm_tree_node_get_name (child);
          if (! child_name)
            {
              grub_dprintf ("hostdisk", "%s child has no DM name\n", path);
-             return NULL;
+             goto devmapper_out;
            }
+         mapper_name = child_name;
 
-         return xasprintf ("/dev/mapper/%s", child_name);
+devmapper_out:
+         if (! mapper_name)
+           {
+             /* This is a DM-RAID disk, not a partition.  */
+             mapper_name = dm_tree_node_get_name (node);
+             if (! mapper_name)
+               {
+                 grub_dprintf ("hostdisk", "%s has no DM name\n", path);
+                 return NULL;
+               }
+           }
+         return xasprintf ("/dev/mapper/%s", mapper_name);
        }
 #endif /* HAVE_DEVICE_MAPPER */
     }