udev使用

参考
file:///Z:/qt-everywhere/marvell/download/udev-142/docs/writing_udev_rules/index.html
和man

http://www.ibm.com/developerworks/cn/linux/l-cn-udev/index.html

http://www.linuxsky.org/doc/admin/200710/139.html

https://wiki.archlinux.org/index.php/Map_Custom_Device_Entries_with_udev

http://blog.csdn.net/lizzywu/article/details/5985405

http://my.chinaunix.net/space.php?uid=22915173&do=blog&id=68329

https://wiki.archlinux.org/index.php/Udev_%28%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87%29

udevadm info options
    Queries the udev database for device information stored in the udev database. It can also query the properties of a
    device from its sysfs representation to help creating udev rules that match this device.

    --query=type
        Query the database for specified type of device data. It needs the --path or --name to identify the specified device.
        Valid queries are: name, symlink, path, property, all.

    --path=devpath
        The devpath of the device to query.

    --name=file
        The name of the device node or a symlink to query

    --root
        The udev root directory: /dev. If used in conjunction with a name or symlink query, the query returns the absolute
        path including the root directory.

    --attribute-walk
        Print all sysfs properties of the specified device that can be used in udev rules to match the specified device. It
        prints all devices along the chain, up to the root of sysfs that can be used in udev rules.

    --device-id-of-file=file
        Print major/minor numbers of the underlying device, where the file lives on.

    --export-db
        Export the content of the udev database.

    --version
        Print version.

    --help
        Print help text.

查询设备的devpath

/dev # udevadm info -q path -n /dev/event0
/devices/platform/ehci_marvell.70059/usb1/1-1/1-1.1/1-1.1:1.0/input/input3/event0

/dev # udevadm info -a -p $(udevadm info -q path -n /dev/event0)

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/ehci_marvell.70059/usb1/1-1/1-1.1/1-1.1:1.0/input/input3/event0':
    KERNEL=="event0"
    SUBSYSTEM=="input"
    DRIVER==""

  looking at parent device '/devices/platform/ehci_marvell.70059/usb1/1-1/1-1.1/1-1.1:1.0/input/input3':
    KERNELS=="input3"
    SUBSYSTEMS=="input"
    DRIVERS==""
    ATTRS{name}=="Dell Dell USB Keyboard"
    ATTRS{phys}=="usb-ehci_marvell.70059-1.1/input0"
    ATTRS{uniq}==""
    ATTRS{modalias}=="input:b0003v413Cp2105e0110-e0,1,4,11,14,k71,72,73,74,75,77,79,7A,7B,7C,7D,7E,7F,80,81,82,83,84,85,86,87,88,89,8A,8C,8E,96,98,9E,9F,A1,A3,A4,A5,A6,AD,B0,B1,B2,B3,B4,B7,B8,B9,BA,BB,BC,BD,BE,BF,C0,C1,C2,F0,ram4,l0,1,2,sfw"

  looking at parent device '/devices/platform/ehci_marvell.70059/usb1/1-1/1-1.1/1-1.1:1.0':
    KERNELS=="1-1.1:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="usbhid"
    ATTRS{bInterfaceNumber}=="00"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bNumEndpoints}=="01"
    ATTRS{bInterfaceClass}=="03"
    ATTRS{bInterfaceSubClass}=="01"
    ATTRS{bInterfaceProtocol}=="01"
    ATTRS{modalias}=="usb:v413Cp2105d0352dc00dsc00dp00ic03isc01ip01"
    ATTRS{supports_autosuspend}=="1"
    ATTRS{interface}=="EP1 Interrupt"

  looking at parent device '/devices/platform/ehci_marvell.70059/usb1/1-1/1-1.1':
    KERNELS=="1-1.1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}=="Dell USB Keyboard"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bmAttributes}=="a0"
    ATTRS{bMaxPower}==" 70mA"
    ATTRS{urbnum}=="20"
    ATTRS{idVendor}=="413c"
    ATTRS{idProduct}=="2105"
    ATTRS{bcdDevice}=="0352"
    ATTRS{bDeviceClass}=="00"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bMaxPacketSize0}=="8"
    ATTRS{speed}=="1.5"
    ATTRS{busnum}=="1"
    ATTRS{devnum}=="5"
    ATTRS{version}==" 1.10"
    ATTRS{maxchild}=="0"
    ATTRS{quirks}=="0x1"
    ATTRS{authorized}=="1"
    ATTRS{manufacturer}=="Dell"
    ATTRS{product}=="Dell USB Keyboard"

  looking at parent device '/devices/platform/ehci_marvell.70059/usb1/1-1':
    KERNELS=="1-1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}==""
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bMaxPower}=="  2mA"
    ATTRS{urbnum}=="65"
    ATTRS{idVendor}=="0424"
    ATTRS{idProduct}=="2514"
    ATTRS{bcdDevice}=="0000"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="02"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{speed}=="480"
    ATTRS{busnum}=="1"
    ATTRS{devnum}=="2"
    ATTRS{version}==" 2.00"
    ATTRS{maxchild}=="4"
    ATTRS{quirks}=="0x1"
    ATTRS{authorized}=="1"

  looking at parent device '/devices/platform/ehci_marvell.70059/usb1':
    KERNELS=="usb1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}==""
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bMaxPower}=="  0mA"
    ATTRS{urbnum}=="28"
    ATTRS{idVendor}=="1d6b"
    ATTRS{idProduct}=="0002"
    ATTRS{bcdDevice}=="0206"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{speed}=="480"
    ATTRS{busnum}=="1"
    ATTRS{devnum}=="1"
    ATTRS{version}==" 2.00"
    ATTRS{maxchild}=="1"
    ATTRS{quirks}=="0x1"
    ATTRS{authorized}=="1"
    ATTRS{manufacturer}=="Linux 2.6.31.8 ehci_hcd"
    ATTRS{product}=="Marvell Orion EHCI"
    ATTRS{serial}=="ehci_marvell.70059"
    ATTRS{authorized_default}=="1"

  looking at parent device '/devices/platform/ehci_marvell.70059':
    KERNELS=="ehci_marvell.70059"
    SUBSYSTEMS=="platform"
    DRIVERS=="ehci_marvell"
    ATTRS{modalias}=="platform:ehci_marvell"

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

原文地址:https://www.cnblogs.com/cute/p/2100495.html