Subject: bug#41143: closed (Re: [PATCH v3 1/2] mapped-devices: Allow target to be list of strings.)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 25 Nov 2020 23:10:02 +0000

Your bug report

#41143: [PATCH 1/2] Add 'lvm-device-mapping'

which was filed against the guix-patches package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
41143: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=41143
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: [PATCH v3 1/2] mapped-devices: Allow target to be list of strings.
From: Ludovic Courtès <[email-masked]>
To: Mikhail Tsykalov <[email-masked]>
Cc: [email-masked]
Date: Thu, 26 Nov 2020 00:09:32 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi Mikhail,

Mikhail Tsykalov <[email-masked]> skribis:

> * gnu/system/mapped-devices.scm (<mapped-device>): Rename constructor to
> %mapped-device.
> [target]: Remove field.
> [targets]: New field. Adjust users.
> (mapped-device-compatibility-helper, mapped-device): New macros.
> (mapped-device-target): New deprecated procedure.

[...]

> * gnu/system/mapped-devices.scm (lvm-device-mapping, open-lvm-device,
> close-lvm-device): New variables.
>
> * gnu/tests/install.scm (%lvm-separate-home-os,
> %lvm-separate-home-os-source, %lvm-separate-home-installation-script,
> %test-lvm-separate-home-os): New variables.
>
> * gnu/system/linux-initrd.scm (raw-initrd): Add (srfi srfi-1) to initrd expression.

Pushed as a9a2fdaabcc78e7a54d9a6bcfa4ee3de308e9a90!

Sorry for the delay, the release process took longer than one could hope
for.  :-)

I added a news entry so users will learn about it upon ‘guix pull’.

Thank you!

Ludo’.

Subject: [PATCH 1/2] mapped-devices: Allow target to be list of strings
From: tsmish <[email-masked]>
To: [email-masked]
Date: Sat, 9 May 2020 01:12:43 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

(let ...) stuff should be in function, but I don't know in which
module it should go.
Code is somewhat untested, proceed with caution.

---
 gnu/services/base.scm         |  5 ++++-
 gnu/system.scm                | 13 ++++++++-----
 gnu/system/mapped-devices.scm |  2 +-
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 0c154d1c4e..3d09e8220c 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -408,7 +408,10 @@ FILE-SYSTEM."
 (define (mapped-device->shepherd-service-name md)
   "Return the symbol that denotes the shepherd service of MD, a
<mapped-device>."
   (symbol-append 'device-mapping-
-                 (string->symbol (mapped-device-target md))))
+                 (string->symbol (string-join
+                                  (let ((t (mapped-device-target md)))
+                                    (if (list? t) t (list t)))
+                                  "-"))))

 (define dependency->shepherd-service-name
   (match-lambda
diff --git a/gnu/system.scm b/gnu/system.scm
index 01baa248a2..75632c5e8a 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -390,9 +390,10 @@ marked as 'needed-for-boot'."
     (let ((device (file-system-device fs)))
       (if (string? device)                        ;title is 'device
           (filter (lambda (md)
-                    (string=? (string-append "/dev/mapper/"
-                                             (mapped-device-target md))
-                              device))
+                    (any (cut string=? device <>)
+                         (map (cut string-append "/dev/mapper" <>)
+                              (let ((t (mapped-device-target md)))
+                                (if (list? t) t (list t))))))
                   (operating-system-mapped-devices os))
           '())))

@@ -412,11 +413,13 @@ marked as 'needed-for-boot'."

 (define (mapped-device-users device file-systems)
   "Return the subset of FILE-SYSTEMS that use DEVICE."
-  (let ((target (string-append "/dev/mapper/" (mapped-device-target device))))
+  (let ((targets (map (cut string-append "/dev/mapper/" <>)
+                      (let ((t (mapped-device-target device)))
+                        (if (list? t) t (list t))))))
     (filter (lambda (fs)
               (or (member device (file-system-dependencies fs))
                   (and (string? (file-system-device fs))
-                       (string=? (file-system-device fs) target))))
+                       (any (cut string=? (file-system-device fs) <>)
targets))))
             file-systems)))

 (define (operating-system-user-mapped-devices os)
diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm
index 7c58f876a3..3339e509e0 100644
--- a/gnu/system/mapped-devices.scm
+++ b/gnu/system/mapped-devices.scm
@@ -72,7 +72,7 @@
   make-mapped-device
   mapped-device?
   (source    mapped-device-source)                ;string | list of strings
-  (target    mapped-device-target)                ;string
+  (target    mapped-device-target)                ;string | list of strings
   (type      mapped-device-type)                  ;<mapped-device-kind>
   (location  mapped-device-location
              (default (current-source-location)) (innate)))
-- 
2.26.2