"insmod inserted the LKM into the kernel, But rmmod not removing it back"
I am learning Kernel module programming and so have tried for the simple example.
#include <asm/current.h> #include <linux/sched.h> #include <linux/module.h> MODULE_LICENSE("Dual BSD/GPL"); static void pro_init(void) { printk (KERN_ALERT "The process is \"%s\" (pid %i)\n",current->comm, current->pid); } static void pro_exit(void) { printk (KERN_ALERT "The process has exited\n"); } module_init(pro_init); module_exit(pro_exit); The program worked with no problems. But when i removed off the last 2 lines of kernel_macros, recompiled the module and inserted it back to the kernel, The module was successfully inserted. lsmod shows the inserted module. Now when i try to unlink the module by 'rmmod' it says 'device/resource busy'. How come the kernel now is in need of clean_up (module_exit) macro where it didn't bother of 'module_init' macro when i used insmod to insert the module....??? |
sudo rmmod -f ?
|
No, I have actually found the solution for the problem. It was 'my program lacked with a cleanup module (module_exit(--)) in the end. But my question is.......
"How come the kernel now is in need of clean_up (module_exit) macro. Because it didn't bother of 'module_init' macro when i used insmod to insert the module without (module_init)....???" |
It should be obvious - rescue allocated resources, etc.
|
All times are GMT -5. The time now is 03:54 AM. |