Question: Create a Kernel Module simple. 1.Compile kernel module simple.c $make Note: if the compiling succeeds, several files are produced. 2.Load Kernel Module $sudo insmod simple.ko
Create a Kernel Module simple.
1.Compile kernel module simple.c $make Note: if the compiling succeeds, several files are produced.
2.Load Kernel Module $sudo insmod simple.ko (Check out contents in kernel log buffer.) $dmesg
3.Remove Kernel Module $sudo rmmod simple (Check out contents in kernel log buffer.) $dmesg
| simple.c #include #include #include /* This cis called when the module is loaded. */int simple_init(void) { printk(KERN_INFO "Loading Modulen"); return 0;} /* This function is called when the module is removed. */ void simple_exit(void) { printk(KERN_INFO "Removing Modulen"); } |
| Makefile obj-m += 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 Note: Makefile should be in the same directory as simple.c |
Screen shot of dmesg after adding and removing the simple module
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
