GNU bug report logs - #73654
[PATCH] gnu: luks-device-mapping-with-options: Add allow-discards? argument.

Previous Next

Package: guix-patches;

Reported by: Sisiutl <sisiutl <at> egregore.fun>

Date: Sun, 6 Oct 2024 09:45:01 UTC

Severity: normal

Tags: moreinfo, patch

Done: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Sisiutl <sisiutl <at> egregore.fun>
Subject: bug#73654: closed (Re: bug#73654: [PATCH] gnu: luks-device-mapping-with-options:
 Add allow-discards? argument.)
Date: Sat, 22 Mar 2025 15:03:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#73654: [PATCH] gnu: luks-device-mapping-with-options: Add allow-discards? argument.

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 73654 <at> debbugs.gnu.org.

-- 
73654: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=73654
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: Tomas Volf <~@wolfsden.cz>
Cc: 73654-done <at> debbugs.gnu.org, sisiutl <at> egregore.fun, ludo <at> gnu.org,
 soeren <at> soeren-tempel.net, hako <at> ultrarare.space
Subject: Re: bug#73654: [PATCH] gnu: luks-device-mapping-with-options: Add
 allow-discards? argument.
Date: Sun, 23 Mar 2025 00:02:10 +0900
Hello,

Pushed as commit 7aa855b05b.

-- 
Thanks,
Maxim

[Message part 3 (message/rfc822, inline)]
From: Sisiutl <sisiutl <at> egregore.fun>
To: guix-patches <at> gnu.org
Cc: Sisiutl <sisiutl <at> egregore.fun>
Subject: [PATCH] gnu: luks-device-mapping-with-options: Add allow-discards?
 argument.
Date: Sun,  6 Oct 2024 11:42:28 +0200
* gnu/system/mapped-devices.scm (luks-device-mapping-with-options): Add allow-discards? argument.

Change-Id: I0a43c13570a223d17698c7fe9ef4607e587bb8d0
---
 gnu/system/mapped-devices.scm | 36 +++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm
index 931c371425..674e8708a4 100644
--- a/gnu/system/mapped-devices.scm
+++ b/gnu/system/mapped-devices.scm
@@ -189,12 +189,12 @@ (define missing
              (&error-location
               (location (source-properties->location location))))))))
 
-
+
 ;;;
 ;;; Common device mappings.
 ;;;
 
-(define* (open-luks-device source targets #:key key-file)
+(define* (open-luks-device source targets #:key key-file allow-discards?)
   "Return a gexp that maps SOURCE to TARGET as a LUKS device, using
 'cryptsetup'."
   (with-imported-modules (source-module-closure
@@ -234,17 +234,19 @@ (define* (open-luks-device source targets #:key key-file)
                                             (loop (- tries-left 1))))))
                           (error "LUKS partition not found" source))
                       source)))
-             ;; We want to fallback to the password unlock if the keyfile fails.
-             (or (and keyfile
-                      (zero? (system*/tty
-                              #$(file-append cryptsetup-static "/sbin/cryptsetup")
-                              "open" "--type" "luks"
-                              "--key-file" keyfile
-                              partition #$target)))
-                 (zero? (system*/tty
-                         #$(file-append cryptsetup-static "/sbin/cryptsetup")
-                         "open" "--type" "luks"
-                         partition #$target)))))))))
+             (let* ((cryptsetup-flags (list "open" "--type" "luks" partition #$target))
+                    (cryptsetup-flags (if allow-discards?
+                                          (cons "--allow-discards" cryptsetup-flags)
+                                          cryptsetup-flags)))
+               ;; We want to fallback to the password unlock if the keyfile fails.
+               (or (and keyfile
+                        (zero? (apply system*/tty
+                                      #$(file-append cryptsetup-static "/sbin/cryptsetup")
+                                      "--key-file" keyfile
+                                      cryptsetup-flags)))
+                   (zero? (apply system*/tty
+                                 #$(file-append cryptsetup-static "/sbin/cryptsetup")
+                                 cryptsetup-flags))))))))))
 
 (define (close-luks-device source targets)
   "Return a gexp that closes TARGET, a LUKS device."
@@ -286,13 +288,15 @@ (define luks-device-mapping
               ((gnu build file-systems)
                #:select (find-partition-by-luks-uuid system*/tty))))))
 
-(define* (luks-device-mapping-with-options #:key key-file)
+(define* (luks-device-mapping-with-options #:key key-file allow-discards?)
   "Return a luks-device-mapping object with open modified to pass the arguments
 into the open-luks-device procedure."
   (mapped-device-kind
    (inherit luks-device-mapping)
-   (open (λ (source targets) (open-luks-device source targets
-                                               #:key-file key-file)))))
+   (open (λ (source targets)
+           (open-luks-device source targets
+                             #:key-file key-file
+                             #:allow-discards? allow-discards?)))))
 
 (define (open-raid-device sources targets)
   "Return a gexp that assembles SOURCES (a list of devices) to the RAID device
-- 
2.46.0




This bug report was last modified 120 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.