From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Thompson, David" Subject: Re: [PATCH 05/15] build: syscalls: Add clone syscall wrapper. Date: Tue, 7 Jul 2015 20:28:16 -0400 Message-ID: References: <1436188604-2813-1-git-send-email-dthompson2@worcester.edu> <1436188604-2813-5-git-send-email-dthompson2@worcester.edu> <87r3okje4c.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34256) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCdDp-0000Bj-5D for guix-devel@gnu.org; Tue, 07 Jul 2015 20:28:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCdDl-0007GT-3t for guix-devel@gnu.org; Tue, 07 Jul 2015 20:28:21 -0400 Received: from mail-la0-f54.google.com ([209.85.215.54]:32861) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCdDk-0007Fs-T7 for guix-devel@gnu.org; Tue, 07 Jul 2015 20:28:17 -0400 Received: by laar3 with SMTP id r3so215258990laa.0 for ; Tue, 07 Jul 2015 17:28:16 -0700 (PDT) In-Reply-To: <87r3okje4c.fsf@gnu.org> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: =?UTF-8?Q?Ludovic_Court=C3=A8s?= Cc: guix-devel , David Thompson On Tue, Jul 7, 2015 at 9:23 AM, Ludovic Court=C3=A8s wrote: > David Thompson skribis: > >> From: David Thompson >> >> * 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, s= o 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.) Done. I should mention that Mark really doesn't like this, and rightfully so. How can we make this more portable in the future? >> + (match (clone (logior CLONE_NEWUSER)) > > No need for logior. I ended up needing it because I had to add the SIGCHLD flag. :) >> + (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. Done and pushed. Thanks! - Dave