If you have learned about the Linux kernel, then you should have a certain understanding of the printk function, then for those who have not touched the printk function, printk () how to Use it? The following small series explains the use of printk() through an example, so that everyone can have a deeper understanding.
Example:
New hello.c
#include "linux /kernel.h"
#include "linux /module.h
int init_module(void)
<
printk(KERN_INFO “Welcome.. . . .n”);
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO “Bye.....\ ”);
}
Then write the Makefile in the same directory:
obj-m := hello.o
all:
make -C /lib /modules/$(shell uname -r)/build M=$(shell pwd)
clean:
-rm *.o *.ko Mod* mod* *.mod.c
Enter the terminal and switch to the corresponding directory
Execute make
After compiling, you will get hello.ko//hello.ko is the compiled module
Execute sudo insmod hello.ko //Load module
Execute lsmod to view the currently loaded module, if hello.ko already Carrier, then executing the lsmod after the output of the function can be seen already loaded good hello.ko
can be performed dmesg view the printk (), then you can see the printed available for purchase .. This information is actually stored in the /var/log/syslog file. You can also see the output information Welcom. .
After the test is completed, execute the sudo rmmod hello uninstall module.
The above is the method of using printk() in Linux. This article is just an example to explain the usage of the printk function. You can find out more about printk() usage online.
Some Linux users do not know how to set the read access of the .net iis metabase, then how to solve
Some users may have a better understanding of Ubuntu 12.04 via VNC Remote Desktop, but this method o
In order to speed up Fedora startup speed, some will change Fedora startup default, will start into
In the copying of Linux files, the copying speed is very slow when there are many files. So, is ther
Linux ssh connection prompts The authenticity of how to remove?
How to use AWK regular expressions under Linux system
How to analyze Nginx logs in Linux system
How to deal with the dead loop of user state process under Linux
Linux refuses foreign IP access steps
How to set the Grub2 password in Ubuntu
Linux mydumper error libmysqlclient_16 not defined how to do?
Linux cancels the SSH login password
How to restart Tomcat regularly on Linux system
How to crack the login password To solve the problem of forgetting the password
With genuine Windows7 Ultrabook Instant Change Phone
Enhance security by modifying the registry under Windows 2000
How WinXP creates PPPoE connections
How to limit the network speed by setting the Win8 NIC rate?
Win7 system can not install Java how to do
6 pictures without brain operation. There is no need to reinstall the system!