woo*_*ody 8 linux kernel kernel-module linux-kernel
我的操作系统Ubuntu 12.04.我写了这个内核模块,我使用insmod和rmmod命令,但/ var/log消息中没有任何内容.我该如何解决这个问题?
/*
* hello-1.c - The simplest kernel module.
*/
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */
int init_module(void)
{
printk(KERN_INFO "Hello world 1.\n");
/*
* A non 0 return means init_module failed; module can't be loaded.
*/
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Goodbye world 1.\n");
}
Run Code Online (Sandbox Code Playgroud)
检查syslog守护进程是否正在运行,因为如果我是正确的,这是将 printk 消息从内核环/日志消息缓冲区复制到/var/log/messages的进程。printk 消息可以使用dmesg实用程序/命令查看,或者消息将位于 /var/log/messages 中。如果设置了正确的日志级别,则 printk 消息将立即显示在控制台上,无需使用 dmesg 或无需签入 /var/log/messages。printk 调试消息也可以是/var/log/syslog的一部分。