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