On 09 Dec 2009, at 12:09 PM, Matze wrote:
From: Jason Nymble <jason.nymble@xxxxxxxxx>
Date: 2009/12/8
Subject: module using another module
To: kernelnewbies <kernelnewbies@xxxxxxxxxxxx> What is the correct/
recommended way for one module to "plug in to" or use
another module? e.g. if I have one module (call it A) which exports
a symbol
allowing a different module (call it B) to register (and
unregister) a
function pointer (which gets called by A if it has a valid value),
it would
be very good if A cannot unload while B is using it (registered),
and also
that B can unload without A being aware it has unregistered. The
latter can
simply be achieved by having B call the unregister function of A
when it
unloads. The former I suppose could be done via some sort of refcount
scheme, but I'm sure this type of problem has a proper correct
solution in
the Linux kernel (e.g. all the modules that use the i2c module etc.
etc.),
and I'd obviously like to avoid re-inventing the wheel (badly).
you can use modprobe for that reason. yust edit your modules.dep
file so that loading module B will automatically load module A. Then
the kernel don't let you unload A when B is still loaded.
regards,
Matthias
Is there not a way to do this in the source of module B, so that
depmod will automatically generate the modules.dep correctly? Note I
don't necessarily want A to be autoloaded if B is being loaded (though
that would obviously be nice), I just want to prevent A from being
unloaded while B is loaded. For example, if one just looks at the
output of lsmod, the "used by" column shows modules using other
modules, and the ones that are used cannot be unloaded. How is this
achieved? Perhaps it is as simple as: if module B uses any symbols
exported from module A, then module A is automatically marked as being
used by B while B is loaded, in which case one does not need to do
anything? I've briefly looked at the source of a few of the modules of
in the "used by" column, and I can't see them explicitly doing
anything to "lock" the modules that they use, so I'm thinking this
just happens automagically because they're using exported functions.
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ