偶已经找到原因,但是是邮件的,懒得翻译了,各位见谅。
还有几个link给大家参考:http://www.chinaunix.net/jh/4/892777.html
http://www.deansys.com/doc/ldd3/ch14s05.html
http://www.deansys.com/doc/ldd3/ch14s07.html
I have found the reason. After editing udev rules, there is still some work to do in modules. It is mentioned in Linux Device Driver Chapter14. There should be a file "dev" in /sys/class for udev to make /dev entity. Like below: [email=root@freescale]root@[/email] /sys/class$ ll /sys/class/scull/scull1/
-r--r--r-- 1 root root 4096 Jan 1 05:12 dev
lrwxrwxrwx 1 root root 0 Jan 1 05:12 subsystem -> ../../../class/scull
--w------- 1 root root 4096 Jan 1 05:12 uevent
[email=root@freescale]root@[/email] /sys/class/scull/scull1$ cat dev
244:1
This "dev" file determine udev to create the major and minor number of a /dev node. And now there is a /dev node. [email=root@freescale]root@[/email] /sys/class/scull/scull1$ ll /dev/scull1
crw-rw---- 1 root root 244, 1 Jan 1 05:12 /dev/scull1
To make sure there is "dev" info. The main work is: 1) In module init function, static struct class *scull_class; //global int scull_init_module(void){ .......... scull_class = class_create(THIS_MODULE, "scull");
if(IS_ERR(scull_class)){
printk(KERN_ERR "error creating scull class .\n");
goto fail;
}
class_device_create(scull_class, NULL, MKDEV(scull_major, 1), NULL, "scull%d", 1);
............. } The code will create a dir /sys/class/scull, then udev can use it to make a /dev node. 2) In module cleanup function,
void scull_cleanup_module(void){
...
class_device_destroy(scull_class, MKDEV(scull_major, 1));
class_destroy(scull_class);
...
}
This work can replace "mknod" manually. |