Install dependencies:
yum install gcc kernel-devel
Create module source file:
/* * goku.c - The simplest kernel module. */ #include <linux/module.h> /* Needed by all modules */ #include <linux/kernel.h> /* Needed for KERN_INFO */ MODULE_LICENSE("GPL"); int init_module(void) { printk(KERN_INFO "Dragon Ball GT...\n"); /* * A non 0 return means init_module failed; module can't be loaded. */ return 0; } void cleanup_module(void) { printk(KERN_INFO "Goku SSJ4 es la mejor transformacion...\n"); }
Create the make file:
obj-m += goku.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
Compile the module:
make
Test your module:
lsmod|grep goku sudo insmod goku.ko lsmod|grep goku
Great!… but what does? Check:
sudo dmesg
You will see in the output:
[ 7347.651869] Dragon Ball GT...
Unload the module:
sudo rmmod hello.ko lsmod|grep hello
Check:
sudo dmesg
You will see in the output:
[ 7459.206258] Goku SSJ4 es la mejor transformacion...