From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [PATCH 07/15] build: syscalls: Add pivot-root. Date: Wed, 08 Jul 2015 14:47:44 +0200 Message-ID: <87io9ulssv.fsf@gnu.org> References: <1436188604-2813-1-git-send-email-dthompson2@worcester.edu> <1436188604-2813-7-git-send-email-dthompson2@worcester.edu> <878uasjdkd.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]:56254) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZColS-0008HL-ET for guix-devel@gnu.org; Wed, 08 Jul 2015 08:47:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZColP-0004wJ-48 for guix-devel@gnu.org; Wed, 08 Jul 2015 08:47:50 -0400 In-Reply-To: (David Thompson's message of "Tue, 7 Jul 2015 21:18:04 -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: "Thompson, David" Cc: guix-devel , David Thompson "Thompson, David" skribis: > On Tue, Jul 7, 2015 at 9:35 AM, Ludovic Court=C3=A8s wrote: >> David Thompson skribis: >> >>> From: David Thompson >>> >>> * guix/build/syscalls.scm (pivot-root): New procedure. >>> * tests/syscalls.scm: Test it. >> >> [...] >> >>> +(test-assert "pivot-root" >>> + (match (pipe) >>> + ((in . out) >>> + (match (clone (logior CLONE_NEWUSER CLONE_NEWNS)) >>> + (0 >>> + (close in) >>> + (call-with-temporary-directory >>> + (lambda (root) >>> + (let ((put-old (string-append root "/real-root"))) >>> + (mount "none" root "tmpfs") >>> + (mkdir put-old) >>> + (call-with-output-file (string-append root "/test") >>> + (lambda (port) >>> + (display "testing\n" port))) >>> + (pivot-root root put-old) >>> + ;; The test file should now be located inside the root di= rectory. >>> + (write (file-exists "/test") out) >>> + (close out)))) >>> + (primitive-exit 0)) >>> + (pid >>> + (close out) >>> + (read in)))))) >> >> Shouldn=E2=80=99t it be: >> >> (file-exists? (string-append put-old "/test")) > > No, because put-old contains the current system root directory. I > wanted to test that the file I made in the temporary directory is now > located in the new root file system. I hope this makes sense. Oh, right. (The other part was the missing question mark, as you noticed.) Ludo=E2=80=99.