From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id EE60FaNgAmfaCQEAe85BDQ:P1 (envelope-from ) for ; Sun, 06 Oct 2024 10:04:19 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id EE60FaNgAmfaCQEAe85BDQ (envelope-from ) for ; Sun, 06 Oct 2024 12:04:19 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=KiunWfB3; dkim=fail ("body hash did not verify") header.d=egregore.fun header.s=fujo header.b=WFUTiuAk; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=egregore.fun (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1728209059; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=W9UJANEqeHFn66bUFZ97lOgkcqp7KAO7eyF2VZNN1n8=; b=Ag5LtET0P7M/0YwyzUIqyIZrO510HxRv4+VVyU6JvRMRsioz+FeC2l/NrzgpQc04uYVoFl x8fxIr7Ke5x5RNNyH3iSCthKs5FUj5OFnrPkHdnGbAl3WBo3igZt6hz2XCVsI9ONzydt9g xpVuhxEdkEU2tQm7GkHO5r3YLGV6kSAPdYorXJcC9cr5lGDXVJd31IhJkQu/+Y/IOqTGZv dv/4/+B+KWY4S6aOsJlQLinxPTn8S37gZzYf/yUC7Th/kIYDJo1KI+bGfSycgA2nHZgMp5 Fp6GcKeZinjj88hisKNDxDqyYMhR2+SC3BvcNVfcH7fX4LGUtj7Ux76K+Hm1Qg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1728209059; a=rsa-sha256; cv=none; b=OobelxpA5aeGcvXY/T1zPICB0VH43nN3DG3VenAjOydXFH2j9b0ZrkYRgcO7ZOTMUYbAze 2VBzQcOCJhm1tz/v7Jnixpme3bAVQVgTIgyA0MxPWMjnpsXqYOy4U4tsRojsJRcaqIygsH evNyn4huAsHxNfyQMvTInVxv4MDFhC9Y0+TLSahOUjjJwY6y4IUH2TCYS3DBTJhXkbY6tl XyNTmCqa1vhshDPOYX4AWy/rQwzzRbYim3zXE0Q+BEblSDx6otFZaxwHg2RarmIhAWsSul IUHQVnYn6u+T+hkI2QVr0ZDerejkN3IsqodglCRkv7Zk3jy2GqUQNP+VM7Spzw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=KiunWfB3; dkim=fail ("body hash did not verify") header.d=egregore.fun header.s=fujo header.b=WFUTiuAk; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=egregore.fun (policy=none) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 97998516AF for ; Sun, 06 Oct 2024 12:04:18 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sxNox-0007CW-QE; Sun, 06 Oct 2024 05:45:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sxNou-0007Ba-PI for guix-patches@gnu.org; Sun, 06 Oct 2024 05:44:56 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sxNou-0004zq-HL for guix-patches@gnu.org; Sun, 06 Oct 2024 05:44:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=5lrmfn2esld5af0pvbw5lj1OtT1ysVDQkV4VxYXInpw=; b=KiunWfB3d4GFUCPoQlLwuHM1sjlFqOhm5wq0dn7SLhpO6PkOBRIsTQQeS82D2ey9M0JghPF4GKBMuYXLzms1sNluTmWCGKDXqQthRgGWMBRLNSEe0c6yKQUP9DxTAtflsJq1A80YSmRPLlrtZsWCXu1SvJ3Gk9suVGEt5VyIuPxnOO8ZTIh+UmcGS8eBkzNG8eQvXZu1QuL/vda+QoTNyHsH71q65//CsKhLTpQfxNvLybqQ1C3XV7icQlB/agNrgKrRskFZgi2clwvmPjAfhRJvuQ5BgtlbaLWbV+6WnqEZXI7YXMQ/jJ0NOalccIhhiV8Cpc/mE9d4f5TPhkiPGg==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sxNp0-0005WB-6T for guix-patches@gnu.org; Sun, 06 Oct 2024 05:45:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#73654] [PATCH] gnu: luks-device-mapping-with-options: Add allow-discards? argument. Resent-From: Sisiutl Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 06 Oct 2024 09:45:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 73654 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 73654@debbugs.gnu.org Cc: Sisiutl X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.172820785021129 (code B ref -1); Sun, 06 Oct 2024 09:45:01 +0000 Received: (at submit) by debbugs.gnu.org; 6 Oct 2024 09:44:10 +0000 Received: from localhost ([127.0.0.1]:40192 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sxNoA-0005Uj-2Q for submit@debbugs.gnu.org; Sun, 06 Oct 2024 05:44:10 -0400 Received: from lists.gnu.org ([209.51.188.17]:58064) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sxNo8-0005Ub-P2 for submit@debbugs.gnu.org; Sun, 06 Oct 2024 05:44:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sxNnz-00076J-1j for guix-patches@gnu.org; Sun, 06 Oct 2024 05:43:59 -0400 Received: from 2a02-8428-4716-0c01-eecc-61c0-3286-ff35.rev.sfr.net ([2a02:8428:4716:c01:eecc:61c0:3286:ff35] helo=fujo.egregore.fun) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sxNnu-0004uw-JF for guix-patches@gnu.org; Sun, 06 Oct 2024 05:43:57 -0400 Received: from localhost (2a02-8428-4716-0c01-69f4-ade7-72a4-dc0f.rev.sfr.net [IPv6:2a02:8428:4716:c01:69f4:ade7:72a4:dc0f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) (Authenticated sender: sisiutl@egregore.fun) by fujo.egregore.fun (Postfix) with ESMTPSA id 6128C673C2; Sun, 6 Oct 2024 11:42:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=egregore.fun; s=fujo; t=1728207769; bh=5lrmfn2esld5af0pvbw5lj1OtT1ysVDQkV4VxYXInpw=; h=From:To:Cc:Subject:Date; b=WFUTiuAkFL1hnIKS+NXglFD/oUQvVU3+qZR2S1q8mVBjd428DKcNVKGpVy0XLgSEY kYcjIrOeyyykYBJr3vR6h2UyULBPtvq0qMqoE1L6txyOwauxmNIMkf6lq2Hr3pWSqe 98bPSvlvd6VIQAEwAYgMJ5j+NgSDZkmxp5H3gOmA= From: Sisiutl Date: Sun, 6 Oct 2024 11:42:28 +0200 Message-ID: <20241006094239.7157-1-sisiutl@egregore.fun> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a02:8428:4716:c01:eecc:61c0:3286:ff35; envelope-from=sisiutl@egregore.fun; helo=fujo.egregore.fun X-Spam_score_int: 67 X-Spam_score: 6.7 X-Spam_bar: ++++++ X-Spam_report: (6.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.499, FROM_SUSPICIOUS_NTLD_FP=1.999, PDS_OTHER_BAD_TLD=1.999, RCVD_IN_PBL=3.335, RDNS_DYNAMIC=0.982, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: reject X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: 7.14 X-Spam-Score: 7.14 X-Migadu-Queue-Id: 97998516AF X-Migadu-Scanner: mx13.migadu.com X-TUID: N6T9ZabcCDj2 * 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