[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] gnu: Mark /gnu/store as needed for boot.

From: Ludovic Courtès
Subject: Re: [PATCH] gnu: Mark /gnu/store as needed for boot.
Date: Sun, 15 Jan 2017 23:24:30 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

John Darrington <address@hidden> 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)
             (not (memq 'bind-mount (file-system-flags fs))))))


--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 
                                         (file2 (string-tokenize file2 
                                (match file1
                                  ((head1 tail1 ...)
                                   (match file2
                                     ((head2 tail2 ...)
                                      (and (string=? head1 head2)
                                           (loop tail1 tail2)))
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.


If that’s fine with you I can commit this.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]