Kernel Module Compilation
20135206 at Jia Xin
?
Basic knowledge:
Module Constructors:
Initializes the function that is called when the kernel module is loaded by executing a insmod or modprobe instruction. The function prototype must be Module_init (), the function pointer inside the parentheses
Module destructor:
The function that is called when the rmmod instruction is executed to unload the module. Function prototype is module_exit ()
Module License Statement:
The function prototype is Module_license (), which tells the kernel which license the program uses, otherwise it will prompt the module to contaminate the kernel when it is loaded. The GPL is generally written.
Write a simple code first
Write makefile
Execute with Make
A lot of files appear after make
Loading modules
sudo insmod Printname.ko
Test module
DMESG See kernel information
Uninstalling the module
sudo rmmod printname
?
The next step is to write more complex code that implements the function of outputting the current process information and the ability to implement the read Process chain list, which shows only the output process
2.2 Kernel Module compilation