/* First kernel module - hello.c */
/*
--------------------------------------
Steps to be followed
#vi hello.c - Enter the given c code
#vi Makefile - Enter the following
obj-m += hello.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(shell pwd) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(shell pwd) clean
install:
make -C /lib/modules/$(shell uname -r)/build M=$(shell pwd) modules_install
#make
#insmod hello.ko
#dmesg tail -4 --> view message
#rmmod hello
#dmesg tail -4 --> view message
--------------------------------------
*/
#include <linux/kernel.h>
#include <linux/module.h >
#include <linux/init.h>
static int __init hello_init(void)
{
printk(KERN_INFO "Hello world\n");
return 0;
}
static void __exit hello_exit(void)
{
printk(KERN_INFO "Goodbye world\n");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("KERNO");
MODULE_DESCRIPTION("First kernel module");
No comments:
Post a Comment