* 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.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-09-19 09:46:06 +02:00
parent e70d6736ff
commit 53c6b7d658
2 changed files with 14 additions and 10 deletions

View file

@ -3,6 +3,14 @@
* docs/grub.texi (Networking commands): Add documentation for * docs/grub.texi (Networking commands): Add documentation for
network related commands. 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> 2013-09-19 Leif Lindholm <leif.lindholm@linaro.org>
* kern/arm/cache.S: Correct access to ilinesz/dlinesz variables. * kern/arm/cache.S: Correct access to ilinesz/dlinesz variables.

View file

@ -1140,10 +1140,13 @@ grub_util_open_dm (const char *os_dev, struct dm_tree **tree,
*node = NULL; *node = NULL;
*tree = NULL; *tree = NULL;
if ((strncmp ("/dev/mapper/", os_dev, 12) != 0)) if (stat (os_dev, &st) < 0)
return 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; return 0;
*tree = dm_tree_create (); *tree = dm_tree_create ();
@ -1154,9 +1157,6 @@ grub_util_open_dm (const char *os_dev, struct dm_tree **tree,
return 0; return 0;
} }
maj = major (st.st_rdev);
min = minor (st.st_rdev);
if (! dm_tree_add_dev (*tree, maj, min)) if (! dm_tree_add_dev (*tree, maj, min))
{ {
grub_dprintf ("hostdisk", "dm_tree_add_dev failed\n"); grub_dprintf ("hostdisk", "dm_tree_add_dev failed\n");
@ -1187,9 +1187,6 @@ get_dm_uuid (const char *os_dev)
const char *node_uuid; const char *node_uuid;
char *ret; char *ret;
if ((strncmp ("/dev/mapper/", os_dev, 12) != 0))
return NULL;
if (!grub_util_open_dm (os_dev, &tree, &node)) if (!grub_util_open_dm (os_dev, &tree, &node))
return NULL; return NULL;
@ -1942,8 +1939,7 @@ convert_system_partition_to_system_disk (const char *os_dev, struct stat *st,
} }
#ifdef HAVE_DEVICE_MAPPER #ifdef HAVE_DEVICE_MAPPER
if ((strncmp ("/dev/mapper/", path, sizeof ("/dev/mapper/") - 1) == 0) if (dm_is_dm_major (major (st->st_rdev)))
|| (strncmp ("/dev/dm-", path, sizeof ("/dev/dm-") - 1) == 0))
{ {
struct dm_tree *tree; struct dm_tree *tree;
uint32_t maj, min; uint32_t maj, min;