grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Colin Watson
Subject: Re: Bug#550704: grub-pc - Needs to handle symlinks in /dev/mapper
Date: Fri, 28 May 2010 11:58:11 +0100
User-agent: Mutt/1.5.18 (2008-05-17)

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  <address@hidden>

        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                                       address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]