Results 1 to 4 of 4
Hope someone can help...
Have very strange problem...
Basically I have a very simple "hello world" kernel module.
file is
Code:
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
MODULE_DESCRIPTION("MyKernelMod");
MODULE_AUTHOR("Me");
MODULE_LICENSE("GPL");
...
- 07-12-2007 #1Just Joined!
- Join Date
- Jul 2007
- Posts
- 2
problem with kernel module
Hope someone can help...
Have very strange problem...
Basically I have a very simple "hello world" kernel module.
file is
I build it through the "make -C <kernel_src> -M=$(PWD) modules"Code:#include <linux/init.h> #include <linux/module.h> #include <linux/kernel.h> MODULE_DESCRIPTION("MyKernelMod"); MODULE_AUTHOR("Me"); MODULE_LICENSE("GPL"); static int initMyModule(void) { printk("Loading MyModule\n"); return 0; } static void closeMyModule(void) { printk("Closing MyModule\n"); } module_init(initMyModule); module_exit(closeMyModule);
the insmod the module.
But the init doesn't work - I don't see in /proc/kmsg, console or syslog
"Loading MyModule" but rmmod does!!!
Any ideas where to begin to look?
TIA
RikD
- 07-12-2007 #2Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
You can check if your module is loaded, with (assuming your module name is hello.ko):
RegardsCode:lsmod | grep hello
- 07-13-2007 #3Just Joined!
- Join Date
- Jul 2007
- Posts
- 2
Module appears to load
lsmod shows the module is there.
But am curious as to why the initMyModule() code hasn't been executed, or what would make the system skip it?
- 07-13-2007 #4Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
You haven't specify a priority in your printk() statement, try (without a comma between the priority and the message):
and:Code:printk(KERN_INFO "Loading MyModule\n");
You can find the priorities in "kernel.h".Code:printk(KERN_INFO "Closing MyModule\n");
Regards


Reply With Quote