最近在嵌入式Linux板子上调试USB声卡,使用mdev创建设备节点时默认直接在 /dev/目录下创建, 如
- controlC0 pcmC0D0c seq sequencer2
- mixer pcmC0D0p sequencer timer
但是用户空间的程序alsa-lib, alsa-utils都是去 /dev/snd/目录下找这些设备节点, 怎么能让mdev把设备节点创建在子目录下呢?
在busybox源代码的 doc/mdev.txt 文档里面找到以下说明:
- You can rename/move device nodes by using the next optional field.
- <device regex> <uid>:<gid> <permissions> [=path]
- So if you want to place the device node into a subdirectory, make sure the path
- has a trailing /. If you want to rename the device node, just place the name.
- hda 0:3 660 =drives/
- This will move "hda" into the drives/ subdirectory.
- hdb 0:3 660 =cdrom
- This will rename "hdb" to "cdrom".
-
- Similarly, ">path" renames/moves the device but it also creates
- a direct symlink /dev/DEVNAME to the renamed/moved device.
所以, 我们只要在 /etc/mdev.conf配置文件里面加入几行就可以了:
- controlC[0-9] 0:0 0660 =snd/
- pcm.* 0:0 0660 =snd/
- seq.* 0:0 0660 =snd/
- mix.* 0:0 0660 =snd/
- timer 0:0 0660 =snd/
这样再运行mdev, ALSA相关的设备节点就都创建在 /dev/snd/ 目录下了。
后记: 内核里面 struct class 里面的 devnode 项跟设备节点所在目录好像也有关系, 有空再研究一下。
阅读(530) | 评论(0) | 转发(0) |