summaryrefslogtreecommitdiff
path: root/guix/build/syscalls.scm
diff options
context:
space:
mode:
authorDavid Thompson <davet@gnu.org>2015-06-25 20:17:46 -0400
committerDavid Thompson <dthompson2@worcester.edu>2015-07-07 21:16:25 -0400
commitdf3ce5c123929b690672cfc6adb3323a8033ec44 (patch)
treebec7dc9274a352899b17b876e3adcb1eabc300d7 /guix/build/syscalls.scm
parent43ace6ea76b0cb4e2ba3f6486acba7dc66e2f19d (diff)
downloadguix-patches-df3ce5c123929b690672cfc6adb3323a8033ec44.tar
guix-patches-df3ce5c123929b690672cfc6adb3323a8033ec44.tar.gz
build: syscalls: Add pivot-root.
* guix/build/syscalls.scm (pivot-root): New procedure. * tests/syscalls.scm ("pivot-root"): New test.
Diffstat (limited to 'guix/build/syscalls.scm')
-rw-r--r--guix/build/syscalls.scm15
1 files changed, 15 insertions, 0 deletions
diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
index 3f0a0c92f8..dcca5fc339 100644
--- a/guix/build/syscalls.scm
+++ b/guix/build/syscalls.scm
@@ -46,6 +46,7 @@
swapoff
processes
mkdtemp!
+ pivot-root
CLONE_NEWNS
CLONE_NEWUTS
@@ -329,6 +330,20 @@ there is no such limitation."
(list fdes nstype (strerror err))
(list err)))))))
+(define pivot-root
+ (let* ((ptr (dynamic-func "pivot_root" (dynamic-link)))
+ (proc (pointer->procedure int ptr (list '* '*))))
+ (lambda (new-root put-old)
+ "Change the root file system to NEW-ROOT and move the current root file
+system to PUT-OLD."
+ (let ((ret (proc (string->pointer new-root)
+ (string->pointer put-old)))
+ (err (errno)))
+ (unless (zero? ret)
+ (throw 'system-error "pivot_root" "~S ~S: ~A"
+ (list new-root put-old (strerror err))
+ (list err)))))))
+
;;;
;;; Packed structures.