guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

06/13: build: syscalls: Add pivot-root.


From: David Thompson
Subject: 06/13: build: syscalls: Add pivot-root.
Date: Fri, 26 Jun 2015 00:27:34 +0000

davexunit pushed a commit to branch wip-container
in repository guix.

commit 831a6f5d26b329c37f1abb1e67ae4a8c33cc6f10
Author: David Thompson <address@hidden>
Date:   Thu Jun 25 20:17:46 2015 -0400

    build: syscalls: Add pivot-root.
    
    * guix/build/syscalls.scm (pivot-root): New procedure.
---
 guix/build/syscalls.scm |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
index b6e60c9..1e2afb8 100644
--- a/guix/build/syscalls.scm
+++ b/guix/build/syscalls.scm
@@ -45,6 +45,7 @@
             swapon
             swapoff
             processes
+            pivot-root
 
             CLONE_NEWNS
             CLONE_NEWUTS
@@ -276,6 +277,20 @@ user-land process."
                     (scandir "/proc"))
         <))
 
+(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)))))))
+
 ;; Linux clone flags, from linux/sched.h
 (define CLONE_NEWNS   #x00020000)
 (define CLONE_NEWUTS  #x04000000)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]