根据udev机制创建video camera设备节点软链接

一、列出设备所有属性,用来编写udev规则

# udevadm info -a -n [device name]

[device name] 替换为系统中存在的设备,比如 /dev/sda/dev/ttyUSB0

如果你不知道设备名,你也可以列出某个系统路径的属性:

-a :所有属性

-n:后面跟设备节点node

查看video设备节点所有属性

# udevadm info -a -n /dev/video16
root:/ # udevadm info -a -n /dev/video16

Udevadm info 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 '/devices/platform/soc/e6ef4000.video/video4linux/video16':
    KERNEL=="video16"
    SUBSYSTEM=="video4linux"
    DRIVER==""
    ATTR{dev_debug}=="0"
    ATTR{index}=="2"
    ATTR{name}=="VIN4 output"

  looking at parent device '/devices/platform/soc/e6ef4000.video':
    KERNELS=="e6ef4000.video"
    SUBSYSTEMS=="platform"
    DRIVERS=="rcar-vin"
    ATTRS{driver_override}=="(null)"
    ATTRS{modalias}=="of:NvideoT<NULL>Crenesas,vin-r8a7795"

  looking at parent device '/devices/platform/soc':
    KERNELS=="soc"
    SUBSYSTEMS=="platform"
    DRIVERS==""
    ATTRS{driver_override}=="(null)"
    ATTRS{modalias}=="of:NsocT<NULL>Csimple-bus"

  looking at parent device '/devices/platform':
    KERNELS=="platform"
    SUBSYSTEMS==""
    DRIVERS==""

二、根据规则,在/etc/udev/rules/目录下创建规则66-video-camera.rules

# There are a number of modifiers that are allowed to be used in some
# of the different fields. They provide the following subsitutions:
#
# %n the "kernel number" of the device.
#    For example, 'sda3' has a "kernel number" of '3'
# %e the smallest number for that name which does not matches an existing node
# %k the kernel name for the device
# %M the kernel major number for the device
# %m the kernel minor number for the device
# %b the bus id for the device
# %c the string returned by the PROGRAM
# %s{filename} the content of a sysfs attribute
# %% the '%' char itself
#

ACTION=="add", KERNEL=="video*", KERNELS=="e6ef4000.video",DRIVERS=="rcar-vin",SYMLINK="video-camera"

 

三、查看创建软链接节点

root:/ # root@ivi-c229-vm-linux:/ # ls /dev/video-camera -l
lrwxrwxrwx    1 root     inet             7 Jan  1  1970 /dev/video-camera -> video16
root:/ # 

 

参考文章:https://wiki.archlinux.org/index.php/Udev_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值