From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [PATCH 05/15] build: syscalls: Add clone syscall wrapper. Date: Tue, 07 Jul 2015 15:23:15 +0200 Message-ID: <87r3okje4c.fsf@gnu.org> References: <1436188604-2813-1-git-send-email-dthompson2@worcester.edu> <1436188604-2813-5-git-send-email-dthompson2@worcester.edu> 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]:55699) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCSqI-0001NX-9G for guix-devel@gnu.org; Tue, 07 Jul 2015 09:23:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCSqE-0002ZY-8t for guix-devel@gnu.org; Tue, 07 Jul 2015 09:23:22 -0400 In-Reply-To: <1436188604-2813-5-git-send-email-dthompson2@worcester.edu> (David Thompson's message of "Mon, 6 Jul 2015 09:16:34 -0400") 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: David Thompson Cc: guix-devel@gnu.org, David Thompson 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, 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=E2=80=99.