亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪問(wèn)板塊 發(fā)新帖
查看: 3526 | 回復(fù): 2
打印 上一主題 下一主題

如何利用udev為自己的驅(qū)動(dòng)分配/dev下面的節(jié)點(diǎn)? [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2008-06-05 15:28 |只看該作者 |倒序?yàn)g覽
我使用了<<linux設(shè)備驅(qū)動(dòng)>>的scull.ko, #insmod scull.ko后, 會(huì)有一個(gè)"/sys/module/scull"出現(xiàn),
想利用udev的自動(dòng)機(jī)制來(lái)生成/dev的節(jié)點(diǎn), 編輯udev的規(guī)則,放入/etc/udev/rules.d/01-scull.rules,該文件內(nèi)容為:

KERNEL=="scull",       NAME="%k0", SYMLINK+="usbhd0"

但是當(dāng)我insmod scull.ko時(shí),在/dev目錄下并沒(méi)有生成/dev/scull0 節(jié)點(diǎn),好像該機(jī)制沒(méi)用,我不知道是不是哪里沒(méi)有設(shè)置好,請(qǐng)教大家的解答!
謝謝!

用udevinfo得到的信息:
# udevinfo -a -p /sys/module/scull/

Udevinfo starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/module/scull':
    KERNEL=="scull"
    SUBSYSTEM=="module"
    DRIVER==""
    ATTR{initstate}=="live"
    ATTR{refcnt}=="0"

論壇徽章:
0
2 [報(bào)告]
發(fā)表于 2008-06-05 19:06 |只看該作者
偶已經(jīng)找到原因,但是是郵件的,懶得翻譯了,各位見(jiàn)諒。
還有幾個(gè)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.

論壇徽章:
0
3 [報(bào)告]
發(fā)表于 2008-06-12 14:28 |只看該作者
不好意思,這個(gè)只是在驅(qū)動(dòng)代碼里面就把dev node創(chuàng)建好了,udev rules還沒(méi)有起作用
KERNEL=="scull",       NAME="%k0", SYMLINK+="usbhd0"
本來(lái)應(yīng)該創(chuàng)建scull0這個(gè)節(jié)點(diǎn),但實(shí)際上/dev 下面只有scull1這個(gè)節(jié)點(diǎn),因?yàn)槭怯蛇@行代碼創(chuàng)建的:
class_device_create(scull_class, NULL, MKDEV(scull_major, 1), NULL, "scull%d", 1);

為什么scull0不能創(chuàng)建出來(lái),就算scull0因?yàn)楹蛃cull1沖突不能創(chuàng)建,為什么符號(hào)鏈接usbhd0也創(chuàng)建不了?
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過(guò)ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP