692a778
--- a/util/getroot.c	2010-03-06 20:51:37.000000000 +0000
692a778
+++ b/util/getroot.c	2010-05-28 18:23:19.892788564 +0100
692a778
@@ -180,7 +180,8 @@ grub_get_prefix (const char *dir)
692a778
 
692a778
 static char *
692a778
 find_root_device (const char *dir __attribute__ ((unused)),
692a778
-                  dev_t dev __attribute__ ((unused)))
692a778
+                  dev_t dev __attribute__ ((unused))
692a778
+                  int depth __attribute__ ((unused)))
692a778
 {
692a778
   return 0;
692a778
 }
692a778
@@ -188,7 +189,7 @@ find_root_device (const char *dir __attr
692a778
 #elif ! defined(__CYGWIN__)
692a778
 
692a778
 static char *
692a778
-find_root_device (const char *dir, dev_t dev)
692a778
+find_root_device (const char *dir, dev_t dev, int depth)
692a778
 {
692a778
   DIR *dp;
692a778
   char *saved_cwd;
692a778
@@ -222,16 +223,27 @@ find_root_device (const char *dir, dev_t
692a778
 	/* Ignore any error.  */
692a778
 	continue;
692a778
 
692a778
-      if (S_ISLNK (st.st_mode))
692a778
+      if (S_ISLNK (st.st_mode)) {
692a778
+#ifdef __linux__
692a778
+	/* If we're in /dev/mapper, follow symbolic links. */
692a778
+	if (depth == 1 && strcmp(dir, "mapper") == 0) {
692a778
+		if (stat(ent->d_name, &st) == -1)
692a778
+		  continue;
692a778
+		if (S_ISDIR (st.st_mode))
692a778
+		  continue;
692a778
+	}
692a778
+#else
692a778
 	/* Don't follow symbolic links.  */
692a778
 	continue;
692a778
+#endif
692a778
+      }
692a778
 
692a778
       if (S_ISDIR (st.st_mode))
692a778
 	{
692a778
 	  /* Find it recursively.  */
692a778
 	  char *res;
692a778
 
692a778
-	  res = find_root_device (ent->d_name, dev);
692a778
+	  res = find_root_device (ent->d_name, dev, depth + 1);
692a778
 
692a778
 	  if (res)
692a778
 	    {
692a778
@@ -454,7 +466,7 @@ grub_guess_root_device (const char *dir)
692a778
 #else
692a778
 
692a778
   /* This might be truly slow, but is there any better way?  */
692a778
-  os_dev = find_root_device ("/dev", st.st_dev);
692a778
+  os_dev = find_root_device ("/dev", st.st_dev, 0);
692a778
 #endif
692a778
 #endif /* !__GNU__ */
692a778