LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices



Reply
 
Search this Thread
Old 07-30-2012, 12:12 AM   #1
SIG_SEGV
Member
 
Registered: Jul 2012
Location: Banglore, INDIA
Distribution: Fedora-Core
Posts: 70

Rep: Reputation: 11
"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....???
 
Old 07-31-2012, 04:59 AM   #2
business_kid
Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 6,625

Rep: Reputation: 585Reputation: 585Reputation: 585Reputation: 585Reputation: 585Reputation: 585
sudo rmmod -f ?
 
Old 07-31-2012, 05:47 AM   #3
SIG_SEGV
Member
 
Registered: Jul 2012
Location: Banglore, INDIA
Distribution: Fedora-Core
Posts: 70

Original Poster
Rep: Reputation: 11
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)....???"
 
Old 07-31-2012, 10:17 AM   #4
business_kid
Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 6,625

Rep: Reputation: 585Reputation: 585Reputation: 585Reputation: 585Reputation: 585Reputation: 585
It should be obvious - rescue allocated resources, etc.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
insmod hello.ko: -1 Invalid module format ("vermagic" and "uname -r" are the same!) courteous Linux - Kernel 8 02-17-2011 12:09 AM
insmod: getting "KIlled" message while inserting kernel module linuxkiddie Linux - Newbie 3 05-18-2010 11:46 AM
rmmod results in "bad file descriptor" wpbgent Linux - Newbie 1 07-29-2008 10:57 AM
K3b: - Howto re-dock "Directories" and "Contents" windows back into the main window? hagies Linux - Software 4 04-26-2006 09:38 AM
Compiling a kernel module results in "insmod" version mvega Linux - General 2 07-30-2003 10:03 AM


All times are GMT -5. The time now is 10:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration