April 2005
Intermediate to advanced
344 pages
11h 59m
English
To compile the preceding source code, create the following makefile:
obj-m += hello_world.o
Compile by running make:
[notoot]$ make -C /usr/src/linux-`uname -r` SUBDIRS=$PWD modules
make: Entering directory `/usr/src/linux-2.6.8
CC [M] /tmp/lkms/hello_world.o
Building modules, stage 2.
MODPOST
CC /tmp/lkms/hello_world.mod.o
LD [M] /tmp/lkms/hello_world.ko
make: Leaving directory `/usr/src/linux-2.6.8Run the insmod tool to load the module:
[root]# insmod ./hello_world.ko
Hello World!List loaded LKMs using the lsmod tool:
[root]# lsmod
Module Size Used by
helloworld 2432 0Remove the module by using the rmmod
tool:
[root]# rmmod hello_world
Good Bye!Read now
Unlock full access