]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* util/getroot.c (grub_util_open_dm): Check major rather than the name
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Thu, 19 Sep 2013 07:46:06 +0000 (09:46 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Thu, 19 Sep 2013 07:46:06 +0000 (09:46 +0200)
to determine if device is handled by devmapper.
(convert_system_partition_to_system_disk): Likewise.
(get_dm_uuid): Don't check explicitly if device is mapped, it's
already done in grub_util_open_dm.

ChangeLog
util/getroot.c

index c81df3c469e4ac53788b2971d99e623d7e7b9851..708c57e04e475913c705879530a85070cd66cb56 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,14 @@
        * docs/grub.texi (Networking commands): Add documentation for
        network related commands.
 
+2013-09-19  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * util/getroot.c (grub_util_open_dm): Check major rather than the name
+       to determine if device is handled by devmapper.
+       (convert_system_partition_to_system_disk): Likewise.
+       (get_dm_uuid): Don't check explicitly if device is mapped, it's
+       already done in grub_util_open_dm.
+
 2013-09-19  Leif Lindholm  <leif.lindholm@linaro.org>
 
        * kern/arm/cache.S: Correct access to ilinesz/dlinesz variables.
index 2865355e7dc115c7be13f9866ca1e2af5b9566e1..88bbf6afc8c868fe283cc6edc8c754f1e0f70050 100644 (file)
@@ -1140,10 +1140,13 @@ grub_util_open_dm (const char *os_dev, struct dm_tree **tree,
   *node = NULL;
   *tree = NULL;
 
-  if ((strncmp ("/dev/mapper/", os_dev, 12) != 0))
+  if (stat (os_dev, &st) < 0)
     return 0;
 
-  if (stat (os_dev, &st) < 0)
+  maj = major (st.st_rdev);
+  min = minor (st.st_rdev);
+
+  if (!dm_is_dm_major (maj))
     return 0;
 
   *tree = dm_tree_create ();
@@ -1154,9 +1157,6 @@ grub_util_open_dm (const char *os_dev, struct dm_tree **tree,
       return 0;
     }
 
-  maj = major (st.st_rdev);
-  min = minor (st.st_rdev);
-
   if (! dm_tree_add_dev (*tree, maj, min))
     {
       grub_dprintf ("hostdisk", "dm_tree_add_dev failed\n");
@@ -1187,9 +1187,6 @@ get_dm_uuid (const char *os_dev)
   const char *node_uuid;
   char *ret;
 
-  if ((strncmp ("/dev/mapper/", os_dev, 12) != 0))
-    return NULL;
-  
   if (!grub_util_open_dm (os_dev, &tree, &node))
     return NULL;
 
@@ -1942,8 +1939,7 @@ convert_system_partition_to_system_disk (const char *os_dev, struct stat *st,
        }
 
 #ifdef HAVE_DEVICE_MAPPER
-      if ((strncmp ("/dev/mapper/", path, sizeof ("/dev/mapper/") - 1) == 0)
-         || (strncmp ("/dev/dm-", path, sizeof ("/dev/dm-") - 1) == 0))
+      if (dm_is_dm_major (major (st->st_rdev)))
        {
          struct dm_tree *tree;
          uint32_t maj, min;