2008-07-25 Robert Millan <rmh@aybabtu.com>

* util/getroot.c (find_root_device): Skip devices that match
        /dev/dm-[0-9].  This lets the real device be found for any type of
        abstraction (LVM, EVMS, RAID..).
        (grub_guess_root_device): Do not traverse /dev/mapper (for LVM)
        and /dev/evms (for EVMS) before traversing /dev.  If a /dev/dm-[0-9]
        device is found first, find_root_device() will now skip it.
This commit is contained in:
robertmh 2008-07-25 19:05:06 +00:00
parent 51cc519338
commit 9051607e1e
2 changed files with 20 additions and 14 deletions

View file

@ -1,3 +1,12 @@
2008-07-25 Robert Millan <rmh@aybabtu.com>
* util/getroot.c (find_root_device): Skip devices that match
/dev/dm-[0-9]. This lets the real device be found for any type of
abstraction (LVM, EVMS, RAID..).
(grub_guess_root_device): Do not traverse /dev/mapper (for LVM)
and /dev/evms (for EVMS) before traversing /dev. If a /dev/dm-[0-9]
device is found first, find_root_device() will now skip it.
2008-07-24 Pavel Roskin <proski@gnu.org>
* include/grub/types.h: Use __builtin_bswap32() and

View file

@ -229,6 +229,17 @@ find_root_device (const char *dir, dev_t dev)
if (S_ISBLK (st.st_mode) && st.st_rdev == dev)
{
#ifdef __linux__
/* Skip useless device names like /dev/dm-0, which prevent us from
finding /dev/mapper/*, /dev/evms/*, /dev/md*, etc. */
if (ent->d_name[0] == 'd' &&
ent->d_name[1] == 'm' &&
ent->d_name[2] == '-' &&
ent->d_name[3] >= '0' &&
ent->d_name[3] <= '9')
continue;
#endif
/* Found! */
char *res;
char *cwd;
@ -358,20 +369,6 @@ grub_guess_root_device (const char *dir)
if (stat (dir, &st) < 0)
grub_util_error ("Cannot stat `%s'", dir);
#ifdef __linux__
/* We first try to find the device in the /dev/mapper directory. If
we don't do this, we get useless device names like /dev/dm-0 for
LVM. */
os_dev = find_root_device ("/dev/mapper", st.st_dev);
if (os_dev)
return os_dev;
/* The same applies to /dev/evms directory (for EVMS volumes). */
os_dev = find_root_device ("/dev/evms", st.st_dev);
if (os_dev)
return os_dev;
#endif
#ifdef __CYGWIN__
/* Cygwin specific function. */
os_dev = find_cygwin_root_device (dir, st.st_dev);