Linux - dmesg不显示printk消息

时间:2015-08-15 20:33:18

标签: linux linux-kernel linux-device-driver

所以我正在学习编写设备驱动程序并写下这个简单的:

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>

static int __init gotemp_init(void)
{
        printk(KERN_DEBUG "Hello world");
        return 0;
}

static void __exit gotemp_exit(void)
{
}

module_init(gotemp_init);
module_exit(gotemp_exit);

MODULE_AUTHOR("Abhinav Jain");
MODULE_DESCRIPTION("Simple driver");
MODULE_LICENSE("GPL");

makefile是这样的:

obj-m := hello.o

KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD       := $(shell pwd)

all:
        $(MAKE) -C $(KERNELDIR) M=$(PWD)

dmesg的输出不会打印"Hello world"。 我还尝试KERN_INFO,但结果仍然相同,尽管lsmod显示正在加载模块hello

那么为什么没有记录消息?

0 个答案:

没有答案
相关问题