From: ludo@gnu.org (Ludovic Courtès)
To: John Darrington <john@darrington.wattle.id.au>
Cc: guix-devel@gnu.org, John Darrington <jmd@gnu.org>
Subject: Re: [PATCH] gnu: Mark /gnu/store as needed for boot.
Date: Sun, 15 Jan 2017 23:24:30 +0100 [thread overview]
Message-ID: <87shokdkrl.fsf@gnu.org> (raw)
In-Reply-To: <20170115063226.GA20478@jocasta.intra> (John Darrington's message of "Sun, 15 Jan 2017 07:32:27 +0100")
John Darrington <john@darrington.wattle.id.au> skribis:
> On Sat, Jan 14, 2017 at 10:30:43PM +0100, Ludovic Court??s wrote:
>
> > * gnu/system/file-systems.scm (all-subpaths): New procedure.
> > (file-system-needed-for-boot?): Use it to check for ancestors
> > of %store-directory.
>
> 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.
>
> The problem is that we need to exclude bind mounts, as done in
> ???store-file-system??? in (gnu system).
>
> Thanks for pointing that out.
>
> What about:
>
> (define (file-system-needed-for-boot? fs)
> (or (%file-system-needed-for-boot? fs)
> (and (string-prefix? (file-system-mount-point fs) (%store-directory))
> (not (memq 'bind-mount (file-system-flags fs))))))
>
>
> Perhaps I am misunderstanding something, but
>
> (string-prefix? (file-system-mount-point fs) (%store-directory))
>
> 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=? head1 head2)
(loop tail1 tail2)))
(()
#f)))))))
scheme@(guile-user)> (file-prefix? "/gn" "/gnu/store")
$13 = #f
scheme@(guile-user)> (file-prefix? "/gnu/store/foo" "/gnu/store")
$14 = #f
scheme@(guile-user)> (file-prefix? "/gnu/store" "/gnu/store")
$15 = #t
scheme@(guile-user)> (file-prefix? "/gnu" "/gnu/store")
$16 = #t
scheme@(guile-user)> (file-prefix? "/" "/gnu/store")
$17 = #t
--8<---------------cut here---------------end--------------->8---
This seems more natural to me than computing the set of prefixes like
‘all-subpaths’ does.
WDYT?
If that’s fine with you I can commit this.
Thanks!
Ludo’.
next prev parent reply other threads:[~2017-01-15 22:24 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-11 20:01 [PATCH] gnu: Mark /gnu/store as needed for boot John Darrington
2017-01-13 8:59 ` Chris Marusich
2017-01-13 11:01 ` John Darrington
2017-01-14 21:30 ` Ludovic Courtès
2017-01-15 6:32 ` John Darrington
2017-01-15 9:53 ` David Craven
2017-01-15 11:18 ` John Darrington
2017-01-15 22:24 ` Ludovic Courtès [this message]
2017-01-16 12:46 ` John Darrington
2017-01-16 22:28 ` Ludovic Courtès
2017-01-17 22:52 ` ABI break! Ludovic Courtès
2017-01-18 6:17 ` John Darrington
2017-01-18 10:56 ` David Craven
2017-01-18 21:25 ` Ludovic Courtès
-- strict thread matches above, loose matches on Subject: below --
2017-01-11 17:48 [PATCH] gnu: Mark /gnu/store as needed for boot John Darrington
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87shokdkrl.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=guix-devel@gnu.org \
--cc=jmd@gnu.org \
--cc=john@darrington.wattle.id.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.