[Top][All Lists]

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

[bug#34195] [PATCH v2] linux-modules: Add modules-soft-dependencies.

From: Danny Milosavljevic
Subject: [bug#34195] [PATCH v2] linux-modules: Add modules-soft-dependencies.
Date: Sat, 26 Jan 2019 16:00:36 +0100

Hi Ludo,

On Sat, 26 Jan 2019 15:10:27 +0100
Ludovic Courtès <address@hidden> wrote:

> Danny Milosavljevic <address@hidden> 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

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)
      (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)))

  (let ((info (modinfo-section-contents file)))
    (filter-map (match-lambda
                 (('softdep . value)
                  (parse-softdep value))
                 (_ #f))
                (modinfo-section-contents file))))

Attachment: pgp2MjHr7pENm.pgp
Description: OpenPGP digital signature

reply via email to

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