I developed two simple modules to the kernel. Now i want to define a function in one module and after that use it in the other.
How i can do that?
Just define the function and caller in the other module without problems?
Kernel modules are pieces of code that can be loaded and unloaded into the kernel upon demand. They extend the functionality of the kernel without the need to reboot the system. A module can be configured as built-in or loadable.
Because the GNU C Library which you are familiar with is implemented for user mode, not kernel mode. The kernel cannot access a userspace API (which might invoke a syscall to the Linux kernel).
A kernel module is a program which can loaded into or unloaded from the kernel upon demand, without necessarily recompiling it (the kernel) or rebooting the system, and is intended to enhance the functionality of the kernel.
The lsmod command displays the loadable kernel modules that are currently loaded.
Define it in module1.c
:
#include <linux/module.h>
int fun(void);
EXPORT_SYMBOL(fun);
int fun(void)
{
/* ... */
}
And use it in module2.c
:
extern int fun(void);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With