guix-devel
[Top][All Lists]
Advanced

[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



reply via email to

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