summaryrefslogtreecommitdiff
path: root/gnu/system
diff options
context:
space:
mode:
authorAndreas Enge <andreas@enge.fr>2016-07-28 11:08:55 +0200
committerAndreas Enge <andreas@enge.fr>2016-07-28 11:08:55 +0200
commite309c7561043361afe63cc9435e620323f870a61 (patch)
treecd6fe073ba840bb68f446933ece44b45d8eb5ec7 /gnu/system
parent1bb163b0dd07c8f2cfd7e91f1e428075cd3d5ed2 (diff)
parente335b82c4eba13fe873db2d680d399469931c10f (diff)
downloadgnu-guix-e309c7561043361afe63cc9435e620323f870a61.tar
gnu-guix-e309c7561043361afe63cc9435e620323f870a61.tar.gz
Merge remote-tracking branch 'origin/master' into core-updates
Diffstat (limited to 'gnu/system')
-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 732f73cc4b..d0a9f0288f 100644
--- a/gnu/system/mapped-devices.scm
+++ b/gnu/system/mapped-devices.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2016 Andreas Enge <andreas@enge.fr>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -22,6 +23,7 @@
#:use-module (gnu services)
#:use-module (gnu services shepherd)
#:autoload (gnu packages cryptsetup) (cryptsetup)
+ #:autoload (gnu packages linux) (mdadm)
#:use-module (srfi srfi-1)
#:use-module (ice-9 match)
#:export (mapped-device
@@ -38,7 +40,8 @@
device-mapping-service-type
device-mapping-service
- luks-device-mapping))
+ luks-device-mapping
+ raid-device-mapping))
;;; Commentary:
;;;
@@ -127,4 +130,28 @@
(open open-luks-device)
(close close-luks-device)))
+(define (open-raid-device source target)
+ "Return a gexp that assembles SOURCE (a list of devices) to the RAID device
+TARGET, using 'mdadm'."
+ #~(let ((every (@ (srfi srfi-1) every)))
+ (let loop ()
+ (unless (every file-exists? '#$source)
+ (format #t "waiting a bit...~%")
+ (sleep 1)
+ (loop)))
+ (zero? (system* (string-append #$mdadm "/sbin/mdadm")
+ "--assemble" #$target
+ #$@source))))
+
+(define (close-raid-device source target)
+ "Return a gexp that stops the RAID device TARGET."
+ #~(zero? (system* (string-append #$mdadm "/sbin/mdadm")
+ "--stop" #$target)))
+
+(define raid-device-mapping
+ ;; The type of RAID mapped devices.
+ (mapped-device-kind
+ (open open-raid-device)
+ (close close-raid-device)))
+
;;; mapped-devices.scm ends here