John Darrington <j...@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’.