[grubby] Pick the last / device (#826537)

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

 



From: "Brian C. Lane" <bcl@xxxxxxxxxx>

When there are multiple devices mounted on /, as there can
be during a preupgrade, the last device is the one that should
match the grub.cfg entry. This was preventing preupgrade from
installing the new f17 kernel.

Related: rhbz#820340
Related: rhbz#820351
---
 grubby.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/grubby.c b/grubby.c
index b7d989d..fe8317d 100644
--- a/grubby.c
+++ b/grubby.c
@@ -1460,6 +1460,8 @@ static char *findDiskForRoot()
     buf[rc] = '\0';
     chptr = buf;
 
+    char *foundanswer = NULL;
+
     while (chptr && chptr != buf+rc) {
         devname = chptr;
 
@@ -1487,13 +1489,8 @@ static char *findDiskForRoot()
          * for '/' obviously.
          */
         if (*(++chptr) == '/' && *(++chptr) == ' ') {
-            /*
-             * Move back 2, which is the first space after the device name, set
-             * it to \0 so strdup will just get the devicename.
-             */
-            chptr -= 2;
-            *chptr = '\0';
-            return strdup(devname);
+            /* remember the last / entry in mtab */
+           foundanswer = devname;
         }
 
         /* Next line */
@@ -1502,6 +1499,13 @@ static char *findDiskForRoot()
             chptr++;
     }
 
+    /* Return the last / entry found */
+    if (foundanswer) {
+        chptr = strchr(foundanswer, ' ');
+        *chptr = '\0';
+        return strdup(foundanswer);
+    }
+
     return NULL;
 }
 
-- 
1.7.7.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux