How to add my own module?
Hi I've tried this on my ubuntu 9.04 :
#include <linux/module.h>
#include <linux/config.h>
#include <linux/init.h>
static int __init mymodule_init(void)
{
printk ("My module worked!\n");
return 0;
}
static void __exit mymodule_exit(void)
{
printk ("Unloading my module.\n");
return;
}
module_init(mymodule_init);
module_exit(mymodule_exit);
MODULE_LICENSE("GPL");
and saved this file as module_1.c
and tried to compile this by $gcc module_1.c
but it gives me following error(s) :
expectedd ) bofore _init
expected declaration specifiers or ‘...’ before string constant
Can any on e please help me ??
ALSO ...
from this ...
How to ??
- generate and edit the makefile in the same directory?
- Compile this module
--> please explain, what to understand by
"# make -C [top directory of your kernel source] SUBDIRS=$PWD modules"
- Load the module (is it ? # insmod ./mymodule.o)
- And how to make the kernel to call my this newly created module?
Will my current kernel modules be affected by this?
Last edited by aarsh; 04-27-2010 at 07:57 PM.
|