Linux driver manual loading insmod manual uninstall rmmod
Test Environment fedora10
Linux Device Driver Version 3:
/*************************************** ******/
Hello. 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
PWD: = $ (shell PWD)
ALL:
$ (Make)-C $ (kerneldir) M = $ (PWD)
Save the file and compile it using the make command.
# Make
# Insmod hello. Ko
# Rmmod hello. Ko
In my test environment, the following information is not displayed in/var/log/messages. So far, the compilation is successful.
Mar 27 17:01:30 localhost kernel: Hello, world
Mar 27 17:01:36 localhost kernel: Goodbye, cruel world