David Thompson <[email protected]> skribis:
> From: David Thompson <[email protected]>
>
> * guix/build/syscalls.scm (clone): New procedure.
> (CLONE_NEWNS, CLONE_NEWUTS, CLONE_NEWIPC, CLONE_NEWUSER, CLONE_NEWPID,
> CLONE_NEWNET): New variables.
> * tests/syscalls.scm: Test it.
[...]
> +;; The libc interface to sys_clone is not useful for Scheme programs, so the
> +;; low-level system call is wrapped instead.
> +(define clone
> + (let* ((ptr (dynamic-func "syscall" (dynamic-link)))
> + (proc (pointer->procedure int ptr (list int int '*)))
> + ;; TODO: Handle all supported architectures
> + (syscall-id (match (utsname:machine (uname))
> + ("x86_64" 56)
> + (_ 120))))
Please add the value for at least i386, mips64el, and armv7 (grep -r
NR_clone arch/ in the kernel tree.)
> + (match (clone (logior CLONE_NEWUSER))
No need for logior.
> + (0 (primitive-exit 0))
Maybe exit with code 42 here...
> + (pid
> + ;; Check if user namespaces are different.
> + (not (equal? (readlink (user-namespace pid))
> + (readlink (user-namespace "self")))))))
... and here to a waitpid and check the status:exit-val.
OK with these changes.
Thanks,
Ludo’.