Don't stat devices unless we have to.
* grub-core/kern/emu/getroot.c (grub_find_device): Recognize dir == /dev/mapper. (grub_guess_root_device): Use already known os_dev if possible. * grub-core/kern/emu/hostdisk.c (convert_system_partition_to_system_disk): Scan only in /dev/mapper if device is known to be a dm one. Also-By: Colin Watson <cjwatson@ubuntu.com>
This commit is contained in:
parent
f35fa3a664
commit
f767c929f2
3 changed files with 34 additions and 14 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2011-05-21 Colin Watson <cjwatson@ubuntu.com>
|
||||
2011-05-21 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Don't stat devices unless we have to.
|
||||
|
||||
* grub-core/kern/emu/getroot.c (grub_find_device): Recognize
|
||||
dir == /dev/mapper.
|
||||
(grub_guess_root_device): Use already known os_dev if possible.
|
||||
* grub-core/kern/emu/hostdisk.c
|
||||
(convert_system_partition_to_system_disk): Scan only in /dev/mapper
|
||||
if device is known to be a dm one.
|
||||
|
||||
2011-05-20 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* util/grub-mkconfig.in: Export GRUB_CMDLINE_LINUX_XEN_REPLACE and
|
||||
|
|
|
@ -358,7 +358,7 @@ grub_find_device (const char *dir, dev_t dev)
|
|||
|
||||
if (S_ISLNK (st.st_mode)) {
|
||||
#ifdef __linux__
|
||||
if (strcmp (dir, "mapper") == 0) {
|
||||
if (strcmp (dir, "mapper") == 0 || strcmp (dir, "/dev/mapper") == 0) {
|
||||
/* Follow symbolic links under /dev/mapper/; the canonical name
|
||||
may be something like /dev/dm-0, but the names under
|
||||
/dev/mapper/ are more human-readable and so we prefer them if
|
||||
|
@ -609,20 +609,27 @@ grub_guess_root_device (const char *dir)
|
|||
|
||||
if (os_dev)
|
||||
{
|
||||
if (stat (os_dev, &st) >= 0)
|
||||
dev = st.st_rdev;
|
||||
else
|
||||
grub_util_error ("cannot stat `%s'", os_dev);
|
||||
free (os_dev);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (stat (dir, &st) >= 0)
|
||||
dev = st.st_dev;
|
||||
else
|
||||
grub_util_error ("cannot stat `%s'", dir);
|
||||
char *tmp = os_dev;
|
||||
os_dev = canonicalize_file_name (os_dev);
|
||||
free (tmp);
|
||||
}
|
||||
|
||||
if (os_dev)
|
||||
{
|
||||
if (strncmp (os_dev, "/dev/dm-", sizeof ("/dev/dm-") - 1) != 0)
|
||||
return os_dev;
|
||||
if (stat (os_dev, &st) < 0)
|
||||
grub_util_error ("cannot stat `%s'", os_dev);
|
||||
free (os_dev);
|
||||
dev = st.st_rdev;
|
||||
return grub_find_device ("/dev/mapper", dev);
|
||||
}
|
||||
|
||||
if (stat (dir, &st) < 0)
|
||||
grub_util_error ("cannot stat `%s'", dir);
|
||||
|
||||
dev = st.st_dev;
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
/* Cygwin specific function. */
|
||||
os_dev = grub_find_device (dir, dev);
|
||||
|
|
|
@ -1408,7 +1408,8 @@ convert_system_partition_to_system_disk (const char *os_dev, struct stat *st)
|
|||
if (tree)
|
||||
dm_tree_free (tree);
|
||||
free (path);
|
||||
char *ret = grub_find_device (NULL, (major << 8) | minor);
|
||||
char *ret = grub_find_device ("/dev/mapper",
|
||||
(major << 8) | minor);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue