Re: help needed with EXPORT_SYMBOL

From: Jan Engelhardt
Date: Mon Aug 23 2010 - 09:32:17 EST


On Monday 2010-08-23 15:17, Peter Zijlstra wrote:

>On Mon, 2010-08-23 at 07:48 -0400, Brian Gerst wrote:
>>
>> Use an exported function pointer in the main kernel as a hook that the
>> module sets when it is loaded. Note, you must use module_get and
>> module_put around the call to the module to prevent it from unloading
>> while in use.
>
>Please don't do any such thing, its impossible to use correctly.
>
>Suppose there are two modular users, A and B.

Though in case there is just a single user it can work out.
Just like bridge.c, and the bunch of nf_nat_*.c. :-)
Though yeah. Bad bad.

This is starting to sound pretty much like an XY problem: XY problem:
You want to do X, but don't know how. You think you can solve it using
Y, but don't know how to do that, either. You ask about Y, which is a
strange thing to want to do. Just ask about X.

(And then there is still the "good idea to do X in the first place"
thing.) Like what's so important to have as a module when you can build
it in, given that the caller is built-in (obj-y) itself.

>module_init()
>{
> old_fptr = fptr;
> fptr = A_func;
>}
>
>Then you load A, load B and unload A, then guess what happens?
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/