John Darrington <j...@darrington.wattle.id.au> skribis:

> On Sun, Jan 15, 2017 at 11:24:30PM +0100, Ludovic Court??s wrote:
>      
>      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.
>      
>
> It looks fine to me.  I haven't tested it ....

Pushed with tests as 384344198dcaa97847e66d3dd82f279ede08d690.

Thanks!

Ludo’.

Reply via email to