From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [PATCH] gnu: Mark /gnu/store as needed for boot. Date: Sun, 15 Jan 2017 23:24:30 +0100 Message-ID: <87shokdkrl.fsf@gnu.org> References: <1484164902-10160-1-git-send-email-jmd@gnu.org> <877f5xjpmk.fsf@gnu.org> <20170115063226.GA20478@jocasta.intra> 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]:44013) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cStE4-0002Ja-PD for guix-devel@gnu.org; Sun, 15 Jan 2017 17:24:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cStE1-0007EN-LG for guix-devel@gnu.org; Sun, 15 Jan 2017 17:24:36 -0500 In-Reply-To: <20170115063226.GA20478@jocasta.intra> (John Darrington's message of "Sun, 15 Jan 2017 07:32:27 +0100") 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" To: John Darrington Cc: guix-devel@gnu.org, John Darrington John Darrington skribis: > On Sat, Jan 14, 2017 at 10:30:43PM +0100, Ludovic Court??s wrote: >=20=20=20=20=20=20 > > * gnu/system/file-systems.scm (all-subpaths): New procedure. > > (file-system-needed-for-boot?): Use it to check for ancestors > > of %store-directory. >=20=20=20=20=20=20 > I guess the idea is to have ???needed-for-boot???? automatically set= for > users who store /gnu or /gnu/store on a separate partition, right? > > Correct. >=20=20=20=20=20=20 > The problem is that we need to exclude bind mounts, as done in > ???store-file-system??? in (gnu system). > > Thanks for pointing that out. >=20=20=20=20=20=20 > What about: >=20=20=20=20=20=20 > (define (file-system-needed-for-boot? fs) > (or (%file-system-needed-for-boot? fs) > (and (string-prefix? (file-system-mount-point fs) (%store-di= rectory)) > (not (memq 'bind-mount (file-system-flags fs)))))) >=20=20=20=20=20=20 > > Perhaps I am misunderstanding something, but > > (string-prefix? (file-system-mount-point fs) (%store-directory)) >=20=20=20=20=20=20 > will erroneously return #t when (file-system-mount-point fs) evaluates > to "/gn" and (%store-directory) to "/gnu/store". Will it not??? > > That is why I wrote a procedure to fix that problem. Good point. Then maybe this: (define (file-system-needed-for-boot? fs) (or (%file-system-needed-for-boot? fs) (and (file-prefix? (file-system-needed-for-boot? fs) (%store-directory)) (not (memq 'bind-mount (file-system-flags fs)))))) with: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> (define (file-prefix? file1 file2) (define not-slash (char-set-complement (char-set #\/))) (and (string-prefix? "/" file1) (let loop ((file1 (string-tokenize file1 not-slash)) (file2 (string-tokenize file2 not-slash))) (match file1 (() #t) ((head1 tail1 ...) (match file2 ((head2 tail2 ...) (and (string=3D? head1 head2) (loop tail1 tail2))) (() #f))))))) scheme@(guile-user)> (file-prefix? "/gn" "/gnu/store") $13 =3D #f scheme@(guile-user)> (file-prefix? "/gnu/store/foo" "/gnu/store") $14 =3D #f scheme@(guile-user)> (file-prefix? "/gnu/store" "/gnu/store") $15 =3D #t scheme@(guile-user)> (file-prefix? "/gnu" "/gnu/store") $16 =3D #t scheme@(guile-user)> (file-prefix? "/" "/gnu/store") $17 =3D #t --8<---------------cut here---------------end--------------->8--- This seems more natural to me than computing the set of prefixes like =E2=80=98all-subpaths=E2=80=99 does. WDYT? If that=E2=80=99s fine with you I can commit this. Thanks! Ludo=E2=80=99.