Patchwork system: Avoid using device paths in <menu-entry> device field.

login
register
mail settings
Submitter Chris Marusich
Date Nov. 3, 2016, 1:10 p.m.
Message ID <20161103131028.7984-2-cmmarusich@gmail.com>
Download mbox | patch
Permalink /patch/17159/
State New
Headers show

Comments

Chris Marusich - Nov. 3, 2016, 1:10 p.m.
From: Chris Marusich <cmmarusich@gmail.com>

This fixes a regression introduced by
1ef8b72a7f87afe7cffe52393d99e1b14e4770e1, in which we would incorrectly use a
device path in a label-based grub root search command, e.g. 'search --label
--set /dev/sda4'.

* gnu/system.scm (grub-device): New procedure.
(operating-system-grub.cfg, operating-system-parameters-file): Use it.
(read-boot-parameters): Handle device paths correctly.
---
 gnu/system.scm | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)
Leo Famulari - Nov. 4, 2016, 3:49 p.m.
On Thu, Nov 03, 2016 at 06:10:28AM -0700, cmmarusich@gmail.com wrote:
> From: Chris Marusich <cmmarusich@gmail.com>
> 
> This fixes a regression introduced by
> 1ef8b72a7f87afe7cffe52393d99e1b14e4770e1, in which we would incorrectly use a
> device path in a label-based grub root search command, e.g. 'search --label
> --set /dev/sda4'.
> 
> * gnu/system.scm (grub-device): New procedure.
> (operating-system-grub.cfg, operating-system-parameters-file): Use it.
> (read-boot-parameters): Handle device paths correctly.

I'm not able to test this patch, but I think we should resolve the
underlying issue before the next release.
Ludovic Courtès - Nov. 6, 2016, 4:51 p.m.
cmmarusich@gmail.com skribis:

> From: Chris Marusich <cmmarusich@gmail.com>
>
> This fixes a regression introduced by
> 1ef8b72a7f87afe7cffe52393d99e1b14e4770e1, in which we would incorrectly use a
> device path in a label-based grub root search command, e.g. 'search --label
> --set /dev/sda4'.
>
> * gnu/system.scm (grub-device): New procedure.
> (operating-system-grub.cfg, operating-system-parameters-file): Use it.
> (read-boot-parameters): Handle device paths correctly.

Good catch.  Applied, thanks!

And sorry for the delay!

Ludo’.

Patch

diff --git a/gnu/system.scm b/gnu/system.scm
index 259875d..bbda2c2 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -60,6 +60,7 @@ 
   #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-34)
   #:use-module (srfi srfi-35)
+  #:use-module (rnrs bytevectors)
   #:export (operating-system
             operating-system?
 
@@ -738,7 +739,7 @@  listed in OS.  The C library expects to find it under
                            (label label)
 
                            ;; The device where the kernel and initrd live.
-                           (device (file-system-device store-fs))
+                           (device (grub-device store-fs))
                            (device-mount-point
                             (file-system-mount-point store-fs))
 
@@ -753,6 +754,14 @@  listed in OS.  The C library expects to find it under
     (grub-configuration-file (operating-system-bootloader os) entries
                              #:old-entries old-entries)))
 
+(define (grub-device fs)
+  "Given FS, a <file-system> object, return a value suitable for use as the
+device in a <menu-entry>."
+  (case (file-system-title fs)
+    ((uuid) (file-system-device fs))
+    ((label) (file-system-device fs))
+    (else #f)))
+
 (define (operating-system-parameters-file os)
   "Return a file that describes the boot parameters of OS.  The primary use of
 this file is the reconstruction of GRUB menu entries for old configurations."
@@ -771,10 +780,7 @@  this file is the reconstruction of GRUB menu entries for old configurations."
                     #$(operating-system-kernel-arguments os))
                    (initrd #$initrd)
                    (store
-                    (device #$(case (file-system-title store)
-                                ((uuid) (file-system-device store))
-                                ((label) (file-system-device store))
-                                (else #f)))
+                    (device #$(grub-device store))
                     (mount-point #$(file-system-mount-point store))))
                 #:set-load-path? #f)))
 
@@ -836,7 +842,10 @@  this file is the reconstruction of GRUB menu entries for old configurations."
          (('store ('device device) _ ...)
           device)
          (_                                       ;the old format
-          root)))
+          ;; Root might be a device path like "/dev/sda1".
+          (if (string-prefix? "/" root)
+              #f
+              root))))
 
       (store-mount-point
        (match (assq 'store rest)