Sample C programe file can be used :
Hello.c
#include <linux/kernel.h>
#include <linux/module.h>
static int __init hello_init(void)
{
printk("The LDD\n");
printk(KERN_ALERT "Hello world\n ");
return 0;
}
static void __exit hello_exit(void)
{
printk("Bye LDD\n");
printk(KERN_ALERT "Good bye\n");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_DESCRIPTION("example: Hello LDD");
MODULE_LICENSE("Dual BSD/GPL");
Sample Makefile file can be used :
bash-3.2# cat Makefile
obj-m := hello.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
rm -rf *.ko *.mod.* .*.cmd *.o .tmp* modules.order Module.symvers
next "make" command helps to build sample
Lod the module into kernel :
/sbin/insmod hello.ko
logs help to verifies modules are loaded :
tail /var/log/messages
Virtual file Live details:
cat /proc/modules
/sbin/insmod hello.ko
logs help to verifies modules are loaded :
tail /var/log/messages
Virtual file Live details:
cat /proc/modules
Thank you for watching post please Like or comment your input review and follow my page.