Re: Loading symbol at startup

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

 



Michael Cashwell wrote:
On Mar 24, 2008, at 10:43 AM, Carlo Bertoldi wrote:

Well, in the first module I used EXPORT_SYMBOL() to export my function, and in the second one I have a function pointer to use it.

Not exactly. You would build the second module with a function prototype for the exported function. Then you just call it normally. It's just like using a function in a shared library. You don't need a function pointer.

(If you want to use a function pointer for some other reason you can do that too. But you still need the prototype for the actual exported function and you'd assign that to your FP.)

Ok, I did that way because rummaging in kernel sources I found a file (drivers/mtd/devices/docprobe.c, kernel version 2.6.18) with those instructions.
So here what I'm doing right now in the second module:

extern void write_seq_to_store(void);
[..]
init function
{
void (*my_write) (void) = NULL;

if ( request_module("modulo_seq") < 0) {
	printk(KERN_INFO "Unable to load module modulo_seq\n");
	return -1;
}
my_write = symbol_request(write_seq_to_store);


write_seq_to_store it's implemented by modulo_seq.
You also will need to ensure that the module doing the exporting is loaded successfully before you try to use the function and that it's not used again after unloading it.

Yes. So now my problem is: where do I place the above code in the kernel, such that it's executed early in the boot process?
Thanks,
 Carlo



--
It's better to know something about everything, than everything about something.

Blaise Pascal

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux