Bug#550704: grub-pc - Needs to handle symlinks in /dev/mapper

Colin Watson cjwatson at ubuntu.com
Fri May 28 10:58:11 UTC 2010


I'm not interested (any more) in deciding whether I think it's more
correct for entries under /dev/mapper to be symlinks or real block
devices (and indeed recent versions of udev do seem to be moving towards
the former).  This isn't something on which it's important for GRUB to
take a stance one way or the other; we should just work with both.
Fortunately this is quite straightforward.  Here's a patch, which I've
also pushed as a bzr branch to people/cjwatson/mapper-symlink.

2010-05-28  Colin Watson  <cjwatson at ubuntu.com>

	Make grub-probe work with symbolic links under /dev/mapper as well
	as with real block devices.  The Linux world seems to be (at best)
	in transition here, and GRUB shouldn't get caught in the middle.

	* kern/emu/getroot.c (find_root_device): Follow symbolic links under
	/dev/mapper.

=== modified file 'kern/emu/getroot.c'
--- kern/emu/getroot.c	2010-05-06 03:15:39 +0000
+++ kern/emu/getroot.c	2010-05-28 10:51:50 +0000
@@ -126,9 +126,20 @@ find_root_device (const char *dir, dev_t
 	/* Ignore any error.  */
 	continue;
 
-      if (S_ISLNK (st.st_mode))
-	/* Don't follow symbolic links.  */
+      if (S_ISLNK (st.st_mode)) {
+#ifdef __linux__
+	if (strcmp (dir, "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
+	     we can get them.  */
+	  if (stat (ent->d_name, &st) < 0)
+	    continue;
+	} else
+#endif /* __linux__ */
+	/* Don't follow other symbolic links.  */
 	continue;
+      }
 
       if (S_ISDIR (st.st_mode))
 	{

-- 
Colin Watson                                       [cjwatson at ubuntu.com]





More information about the Pkg-grub-devel mailing list