[CODE] #include #include #include #include #include MODULE_LICENSE("GPL"); MODULE_AUTHOR("mq110"); static void print_string(char *str) { struct tty_struct *my_tty; my_tty = current->signal->tty; if (my_tty != NULL) { my_tty->driver->write(my_tty,0,str,strlen(str)); my_tty->driver->write(my_tty,0,"\015\013",2); } } static int __init print_string_init(void) ...
printk中ERN_DEBUG 级别: /var/log下没有 message文件,dmesg也看不到其输出 printk中ERN_DEBUG 级别输出到那? btw:KERN_INFO级别用dmesg能显示出来
内核本身支持串口,同时启动的时候加上了参数console=ttyS0。 系统是2.4.22的,当前是有时能打印到串口,有时又不能? 另外,就是希望打印信息的时候,立即打印出来。譬如我第一行是打印信息的代码,第二行代码就可能导致Oops。这个时候要保证在Oops之前,能把第一行的信息打印出来。 请各位指点一下。
[code] #include #include #include #include #include #include #include #include #include #define MY_FILE "/root/LogFile" char buf[128]; struct file *file = NULL; static int __init init(void) { mm_segment_t old_fs; printk("Hello, I'm the module that intends to write messages to file.\n"); if(file == NULL) file = filp_open(MY_FILE, O_RDWR | O_APPEND |...
在写hello模块时,使用的printk语句是: printk(KERN_ALERT "hello, world\n"); 但在insmod模块是,在终端上却没输出,情况如下: [jrq@Fedora hello]$ sudo insmod hello.ko //按理说这句话后,应该有Hello, world输出 [jrq@Fedora hello]$ sudo rmmod hello.ko ///应该输出Goodbye, cruel world [jrq@Fedora hello]$ dmesg ...... Hello, world Goodbye, cruel world [jrq@Fedora hello]$ cat /proc/sys/kernel/print...
文件hello.c代码如下:
#include
例子用的是《Linux设备驱动开发详解》里面提供的virtualbox里面的helloworld的例子,执行insmod ./hello.ko 和 rmmod hello都看不到输出,把优先级改成 KERN_EMERG,KERN_ALERT,KERN_CRIT... KERN_DEBUG make clean再make后等等都不行,并且在/var/log/messages里面也看的不全,比如我把优先级从0到7,每个都编译后insmod试一遍,观察/var/log/messages,里面只有优先级是2,3,6的,其它优先级的都没有,奇怪???