summaryrefslogtreecommitdiff
path: root/gnu/system/mapped-devices.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2016-04-17 17:59:58 +0200
committerLudovic Courtès <ludo@gnu.org>2016-04-18 01:24:06 +0200
commit374f14c265224048b065f2c177f80718b905201b (patch)
treeacf70c717b4b7404e9c815e7717b67465b316031 /gnu/system/mapped-devices.scm
parent060d62a740fc1932a3be505534feff099b59ac9f (diff)
system: Move 'luks-device-mapping' to (gnu system mapped-devices).
* gnu/system.scm (open-luks-device, close-luks-device) (luks-device-mapping): Move to... * gnu/system/mapped-devices.scm: ... here. New file.
Diffstat (limited to 'gnu/system/mapped-devices.scm')
-rw-r--r--gnu/system/mapped-devices.scm29
1 files changed, 28 insertions, 1 deletions
diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm
index 81afb91f86..dd8e432688 100644
--- a/gnu/system/mapped-devices.scm
+++ b/gnu/system/mapped-devices.scm
@@ -17,7 +17,9 @@
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu system mapped-devices)
+ #:use-module (guix gexp)
#:use-module (guix records)
+ #:autoload (gnu packages cryptsetup) (cryptsetup)
#:export (mapped-device
mapped-device?
mapped-device-source
@@ -27,7 +29,9 @@
mapped-device-kind
mapped-device-kind?
mapped-device-kind-open
- mapped-device-kind-close))
+ mapped-device-kind-close
+
+ luks-device-mapping))
;;; Commentary:
;;;
@@ -50,4 +54,27 @@
(close mapped-device-kind-close ;source target -> gexp
(default (const #~(const #f)))))
+
+;;;
+;;; Common device mappings.
+;;;
+
+(define (open-luks-device source target)
+ "Return a gexp that maps SOURCE to TARGET as a LUKS device, using
+'cryptsetup'."
+ #~(zero? (system* (string-append #$cryptsetup "/sbin/cryptsetup")
+ "open" "--type" "luks"
+ #$source #$target)))
+
+(define (close-luks-device source target)
+ "Return a gexp that closes TARGET, a LUKS device."
+ #~(zero? (system* (string-append #$cryptsetup "/sbin/cryptsetup")
+ "close" #$target)))
+
+(define luks-device-mapping
+ ;; The type of LUKS mapped devices.
+ (mapped-device-kind
+ (open open-luks-device)
+ (close close-luks-device)))
+
;;; mapped-devices.scm ends here