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 ....


J'

-- 
Avoid eavesdropping.  Send strong encrypted email.
PGP Public key ID: 1024D/2DE827B3 
fingerprint = 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
See http://sks-keyservers.net or any PGP keyserver for public key.

Attachment: signature.asc
Description: Digital signature

Reply via email to