Starting with a hello world kernel module

This commit is contained in:
Sankar சங்கர் 2013-03-10 20:25:26 +05:30
parent 6924003b81
commit 9cbdc4cc9f
2 changed files with 34 additions and 0 deletions

8
Makefile Normal file
View File

@ -0,0 +1,8 @@
obj-m := simplefs.o
simplefs-objs := simple.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

26
simple.c Normal file
View File

@ -0,0 +1,26 @@
/*
* A Simple Filesystem for the Linux Kernel.
*
* Initial author: Sankar P <sankar.curiosity@gmail.com>
* License: Creative Commons Zero License - http://creativecommons.org/publicdomain/zero/1.0/
*/
#include <linux/init.h>
#include <linux/module.h>
static int simplefs_init(void)
{
printk(KERN_ALERT "Hello World\n");
return 0;
}
static void simplefs_exit(void)
{
printk(KERN_ALERT "Goodbye World\n");
}
module_init(simplefs_init);
module_exit(simplefs_exit);
MODULE_LICENSE("CC0");
MODULE_AUTHOR("Sankar P");