diff --git a/ChangeLog b/ChangeLog index c81df3c46..708c57e04 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,14 @@ * docs/grub.texi (Networking commands): Add documentation for network related commands. +2013-09-19 Vladimir Serbinenko + + * 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 * kern/arm/cache.S: Correct access to ilinesz/dlinesz variables. diff --git a/util/getroot.c b/util/getroot.c index 2865355e7..88bbf6afc 100644 --- a/util/getroot.c +++ b/util/getroot.c @@ -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;