]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2008-07-25 Robert Millan <rmh@aybabtu.com>
authorrobertmh <robertmh@localhost>
Fri, 25 Jul 2008 19:05:06 +0000 (19:05 +0000)
committerrobertmh <robertmh@localhost>
Fri, 25 Jul 2008 19:05:06 +0000 (19:05 +0000)
        * 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.

ChangeLog
util/getroot.c

index 12a4027bb8b3a72cd44ffc6df6d23a861439022d..09e2225c4c71f6e7bb2addc4fddcf54e6154fcc7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
index 1202a5c8b5951896d2bf6752def68ce6af71b884..744d5effd336f59d5ca19a26b844c77488effe21 100644 (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);