[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 06/15] build: syscalls: Add setns syscall wrapper.
From: |
Thompson, David |
Subject: |
Re: [PATCH 06/15] build: syscalls: Add setns syscall wrapper. |
Date: |
Tue, 7 Jul 2015 20:57:52 -0400 |
On Tue, Jul 7, 2015 at 9:28 AM, Ludovic Courtès <address@hidden> wrote:
> David Thompson <address@hidden> skribis:
>
>> From: David Thompson <address@hidden>
>>
>> * guix/build/syscalls.scm (setns): New procedure.
>> * tests/syscalls.scm: Test it.
>
> [...]
>
>> + (lambda (fdes nstype)
>> + "Reassociate the current process with the namespace specified by FDES.
>
> “... by FDES, a file descriptor obtained by opening a /proc/PID/ns/*
> files.”
>
>> +(test-assert "setns"
>> + (match (clone (logior CLONE_NEWUSER))
>> + (0 (primitive-exit 0))
>> + (clone-pid
>> + (match (pipe)
>> + ((in . out)
>> + (match (primitive-fork)
>> + (0
>> + (close in)
>> + (call-with-input-file (user-namespace clone-pid)
>> + (lambda (port)
>> + (setns (port->fdes port) 0)))
>> + (write 'done out)
>> + (close out)
>> + (primitive-exit 0))
>> + (fork-pid
>> + (close out)
>> + ;; Wait for the child process to join the namespace.
>> + (read in)
>> + (equal? (readlink (user-namespace clone-pid))
>> + (readlink (user-namespace fork-pid))))))))))
>
> Add a waipid call for both CLONE-PID and FORK-PID to make sure nothing’s
> left behind.
>
> OK with these changes!
Done and pushed. Thanks!
- Dave
[PATCH 06/15] build: syscalls: Add setns syscall wrapper., David Thompson, 2015/07/06
[PATCH 10/15] gnu: system: Move file-system->spec to (gnu system file-systems)., David Thompson, 2015/07/06
[PATCH 09/15] gnu: system: Move <file-system-mapping> into (gnu system file-systems)., David Thompson, 2015/07/06
[PATCH 13/15] scripts: system: Add 'container' action., David Thompson, 2015/07/06
[PATCH 08/15] gnu: build: Add Linux container module., David Thompson, 2015/07/06