Hi Ludo, On Sat, 26 Jan 2019 15:10:27 +0100 Ludovic Courtès wrote: > Danny Milosavljevic skribis: > > > scheme> (module-soft-dependencies "/tmp/vfio.ko") > > $2 = (("post" . "vfio_iommu_spapr_tce") ("post" . "vfio_iommu_type1")) > > That’s probably not the best interface. :-) > > Perhaps it should return two values: the list of modules to be loaded > before (“pre”), followed by the list of modules to be loaded after > (“post”). I had thought about it - but for our use case it makes it slower and more complicated. I still have the previous version (see below). Moreover, it did the wrong thing for multiple 'softdep sections. I guess I can use an external grouper routine (something like a hypothetical group-by-first - does it exist?) on the result of module-soft-dependencies. But at that point the caller can call it himself :-> We could hard-code "pre" and "post" as the two only possible sections (and kmod does), but that would make it break in the future even though we don't care about the sections, just the module names. Complicated version: (define (module-soft-dependencies file) "Return the list of soft dependencies of module FILE." (define (add-to-first-acons value alist) (match alist (((k . v) . b) (cons (cons k (cons value v)) b)))) (define (parse-softdep text) (let loop ((value '()) (tokens (string-tokenize text not-softdep-whitespace)) (section #f)) (write tokens) (newline) (match tokens ((token _ ...) (if (string=? (string-take-right token 1) ":") ; section (loop (acons (string-drop-right token 1) '() value) (cdr tokens) (string-trim-both token)) (loop (add-to-first-acons token value) (cdr tokens) section))) (() value)))) (let ((info (modinfo-section-contents file))) (filter-map (match-lambda (('softdep . value) (parse-softdep value)) (_ #f)) (modinfo-section-contents file))))