aboutsummaryrefslogtreecommitdiff
path: root/gnu/services/base.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-11-10 22:25:39 +0100
committerLudovic Courtès <ludo@gnu.org>2014-11-10 22:42:14 +0100
commitd6e2a622c49184390d362abf97ca1c56498cfd6a (patch)
tree83543c98a446ad7d67eac35952542af4b6ab1b1f /gnu/services/base.scm
parentccea821befc96a2c5e0c64b1a18eef0f31abe0a7 (diff)
downloadguix-d6e2a622c49184390d362abf97ca1c56498cfd6a.tar
guix-d6e2a622c49184390d362abf97ca1c56498cfd6a.tar.gz
services: Add 'user-unmount-service' as an essential service.
* gnu/services/base.scm (user-unmount-service): New procedure. * gnu/system.scm (essential-services): Use it. * gnu/system/install.scm (cow-store-service): Mention it in comment.
Diffstat (limited to 'gnu/services/base.scm')
-rw-r--r--gnu/services/base.scm28
1 files changed, 28 insertions, 0 deletions
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index abf8ae99ac..0c45d54d17 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -38,6 +38,7 @@
#:use-module (ice-9 format)
#:export (root-file-system-service
file-system-service
+ user-unmount-service
device-mapping-service
swap-service
user-processes-service
@@ -145,6 +146,33 @@ names such as device-mapping services."
(umount #$target)
#f))))))
+(define (user-unmount-service known-mount-points)
+ "Return a service whose sole purpose is to unmount file systems not listed
+in KNOWN-MOUNT-POINTS when it is stopped."
+ (with-monad %store-monad
+ (return
+ (service
+ (documentation "Unmount manually-mounted file systems.")
+ (provision '(user-unmount))
+ (start #~(const #t))
+ (stop #~(lambda args
+ (define (known? mount-point)
+ (member mount-point
+ (cons* "/proc" "/sys"
+ '#$known-mount-points)))
+
+ (for-each (lambda (mount-point)
+ (format #t "unmounting '~a'...~%" mount-point)
+ (catch 'system-error
+ (lambda ()
+ (umount mount-point))
+ (lambda args
+ (let ((errno (system-error-errno args)))
+ (format #t "failed to unmount '~a': ~a~%"
+ mount-point (strerror errno))))))
+ (filter (negate known?) (mount-points)))
+ #f))))))
+
(define %do-not-kill-file
;; Name of the file listing PIDs of processes that must survive when halting
;; the system. Typical example is user-space file systems.