Template Information

Trang

Makefile

Thứ Bảy, 4 tháng 6, 2011 / 20:26

You can test the module with the insmod and rmmod utilities, as shown below. Note
that only the superuser can load and unload a module.
% make
make[1]: Entering directory `/usr/src/linux-2.6.10'
CC [M] /home/ldd3/src/misc-modules/hello.o
Building modules, stage 2.
MODPOST
CC /home/ldd3/src/misc-modules/hello.mod.o
LD [M] /home/ldd3/src/misc-modules/hello.ko
make[1]: Leaving directory `/usr/src/linux-2.6.10'
% su
root# insmod ./hello.ko
Hello, world
root# rmmod hello
Goodbye cruel world
root#
Please note once again that, for the above sequence of commands to work, you must
have a properly configured and built kernel tree in a place where the makefile is able
to find it (/usr/src/linux-2.6.10 in the example shown). We get into the details of how
modules are built in the section “Compiling and Loading.”
According to the mechanism your system uses to deliver the message lines, your output
may be different. In particular, the previous screen dump was taken from a text
console; if you are running insmod and rmmod from a terminal emulator running
under the window system, you won’t see anything on your screen. The message goes
to one of the system log files, such as /var/log/messages (the name of the actual file varies between Linux distributions).

0 nhận xét:

Đăng nhận xét