From 43ace6ea76b0cb4e2ba3f6486acba7dc66e2f19d Mon Sep 17 00:00:00 2001 From: David Thompson Date: Mon, 8 Jun 2015 08:43:05 -0400 Subject: build: syscalls: Add setns. * guix/build/syscalls.scm (setns): New procedure. * tests/syscalls.scm ("setns"): New test. squash: setns --- guix/build/syscalls.scm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'guix/build/syscalls.scm') diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm index cff010648a..3f0a0c92f8 100644 --- a/guix/build/syscalls.scm +++ b/guix/build/syscalls.scm @@ -54,6 +54,7 @@ (define-module (guix build syscalls) CLONE_NEWPID CLONE_NEWNET clone + setns IFF_UP IFF_BROADCAST @@ -313,6 +314,21 @@ (define clone are shared between the parent and child processes." (proc syscall-id flags %null-pointer)))) +(define setns + (let* ((ptr (dynamic-func "setns" (dynamic-link))) + (proc (pointer->procedure int ptr (list int int)))) + (lambda (fdes nstype) + "Reassociate the current process with the namespace specified by FDES, a +file descriptor obtained by opening a /proc/PID/ns/* file. NSTYPE specifies +which type of namespace the current process may be reassociated with, or 0 if +there is no such limitation." + (let ((ret (proc fdes nstype)) + (err (errno))) + (unless (zero? ret) + (throw 'system-error "setns" "~d ~d: ~A" + (list fdes nstype (strerror err)) + (list err))))))) + ;;; ;;; Packed structures. -- cgit v1.2.3