modprobe: break dependency loop by checking if module is loaded
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Wed, 11 Jan 2012 20:29:55 +0000 (18:29 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Wed, 11 Jan 2012 20:29:55 +0000 (18:29 -0200)
commitaf0ff2f22ac189ce9f51b597711aee5c178b0378
treeae6478a9b4a41b6722506d01f5c069fa70f4d431
parent21e14d36f127b27d445ff11223a0eff7b63d815b
modprobe: break dependency loop by checking if module is loaded

modprobe doesn't have support for handling dependency loop. That happens
with poorly written softdeps that can introduce a loop. We must deal
with them like it's being done in libkmod.

However, we can break a dependency loop when the dependency was already
inserted. This commit fixes this issue, that happens in the following
scenario:

dependencies:
-------------

modA:
modB: modA
modC: modA

config:

softdep modA post: modB modC

This creates the following loop:

modA
    inserted ok
    handle post-soft-deps of modA -> modB modC
        modB
            handle dependencies of modB -> modA
                modA is already inserted
                    handle post-soft-deps of modA -> modB modC

And so on and so forth.

Now we break the loop by checking if module is already inserted, before
handling it. Thus this gives us:

modA
    inserted ok
    handle post-soft-deps of modA -> modB modC
        modB
            handle dependencies of modB -> modA
                modA is already inserted
            inserted ok
        modC
            handle dependencies of modC -> modA
                modA is already inserted
            inserted ok
tools/kmod-modprobe.c