DriverProgramHello. c
##################################
# Include <Linux/init. h>
# Include <Linux/module. h>
Module_license ("dual BSD/GPL ");
Static int hello_init (void)
{
Printk (kern_alert "Hello, world \ n ");
Return 0;
}
Static void hello_exit (void)
{
Printk (kern_alert "Goodbye, cruel world \ n ");
}
Module_init (hello_init );
Module_exit (hello_exit );
######################################## ##
Makefile
#######################################
OBJ-M: = Hello. o
Kerneldir: =/lib/modules/$ (shell uname-R)/build
Default:
Make-C $ (kerneldir) M = $ (shell PWD) Modules
Clean:
Make-C $ (kerneldir) M = $ (shell PWD) clean
Install:
Insmod hello. Ko
Uninstall:
Rmmod hello. Ko
Clean:
Make-C $ (kerneldir) M = $ (shell PWD) clean
######################################## #######
After compilation, there is no error in insmod hello. Ko installation, but you cannot see "Hello, world". Run the dmesg command to check whether the installation is successful.
However, when rmmod hello is displayed, the error "error: removing 'hello': device or resource busy" occurs ".. Check whether the system does not compile the load control function ??? (Like impossible ). The answer is currently fruitless. Run the lsmod | grep Hello command to check if the hello driver does not exist. Dynamically load the driver so that it does not exist after the reset ....