udev 不创建符号链接

udev 不创建符号链接

我正在尝试为我的传感器设备指定一个静态名称。我打开了一个文件99-usb-serial.rules/etc/udev/rules.d写入以下规则:

KERNEL=="ttyACM0",KERNELS=="1-1",SUBSYSTEM=="tty",SUBSYSTEMS=="usb",ATTRS{idVendor}=="108c", ATTRS{idProduct}=="017b", SYMLINK+="/dev/mydevice"

这不会在 中创建任何符号链接/dev。要检查我的命令是否正确,

命令:

udevadm -info --name/dev/ttyACM0 --atribute-walk

输出:

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/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/tty/ttyACM0':
    KERNEL=="ttyACM0"
    SUBSYSTEM=="tty"
    DRIVER==""

  looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0':
    KERNELS=="1-1:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="cdc_acm"
    ATTRS{authorized}=="1"
    ATTRS{bInterfaceSubClass}=="02"
    ATTRS{bInterfaceNumber}=="00"
    ATTRS{bmCapabilities}=="2"
    ATTRS{bInterfaceClass}=="02"
    ATTRS{bNumEndpoints}=="01"
    ATTRS{bInterfaceProtocol}=="00"
    ATTRS{supports_autosuspend}=="1"
    ATTRS{bAlternateSetting}==" 0"

  looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-1':
    KERNELS=="1-1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{version}==" 2.00"
    ATTRS{devpath}=="1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{product}=="XDK Application"
    ATTRS{devnum}=="21"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{manufacturer}=="Bosch Connected Devices and Solutions GmbH"
    ATTRS{busnum}=="1"
    ATTRS{rx_lanes}=="1"
    ATTRS{tx_lanes}=="1"
    ATTRS{ltm_capable}=="no"
    ATTRS{serial}=="2496B4065B328D1E"
    ATTRS{bDeviceClass}=="02"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bMaxPower}=="500mA"
    ATTRS{bmAttributes}=="c0"
    ATTRS{urbnum}=="13"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{bNumInterfaces}==" 2"
    ATTRS{bcdDevice}=="0000"
    ATTRS{idProduct}=="017b"
    ATTRS{authorized}=="1"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{configuration}==""
    ATTRS{removable}=="removable"
    ATTRS{idVendor}=="108c"
    ATTRS{maxchild}=="0"
    ATTRS{speed}=="12"
    ATTRS{quirks}=="0x0"

  looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1':
    KERNELS=="usb1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{serial}=="0000:00:14.0"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{urbnum}=="577"
    ATTRS{version}==" 2.00"
    ATTRS{quirks}=="0x0"
    ATTRS{bcdDevice}=="0513"
    ATTRS{authorized_default}=="1"
    ATTRS{product}=="xHCI Host Controller"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{devnum}=="1"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{removable}=="unknown"
    ATTRS{interface_authorized_default}=="1"
    ATTRS{tx_lanes}=="1"
    ATTRS{configuration}==""
    ATTRS{busnum}=="1"
    ATTRS{speed}=="480"
    ATTRS{rx_lanes}=="1"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{maxchild}=="12"
    ATTRS{devpath}=="0"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{idVendor}=="1d6b"
    ATTRS{idProduct}=="0002"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bMaxPower}=="0mA"
    ATTRS{ltm_capable}=="no"
    ATTRS{authorized}=="1"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{manufacturer}=="Linux 5.13.0-28-generic xhci-hcd"
    ATTRS{bDeviceClass}=="09"

  looking at parent device '/devices/pci0000:00/0000:00:14.0':
    KERNELS=="0000:00:14.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="xhci_hcd"
    ATTRS{local_cpulist}=="0-3"
    ATTRS{driver_override}=="(null)"
    ATTRS{broken_parity_status}=="0"
    ATTRS{dbc}=="disabled"
    ATTRS{dma_mask_bits}=="64"
    ATTRS{d3cold_allowed}=="1"
    ATTRS{class}=="0x0c0330"
    ATTRS{enable}=="1"
    ATTRS{vendor}=="0x8086"
    ATTRS{revision}=="0x21"
    ATTRS{msi_bus}=="1"
    ATTRS{irq}=="125"
    ATTRS{subsystem_vendor}=="0x1043"
    ATTRS{power_state}=="D0"
    ATTRS{device}=="0x9d2f"
    ATTRS{ari_enabled}=="0"
    ATTRS{numa_node}=="-1"
    ATTRS{subsystem_device}=="0x201f"
    ATTRS{consistent_dma_mask_bits}=="64"
    ATTRS{local_cpus}=="f"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{waiting_for_supplier}=="0"

为了调试这个问题,我使用了udevadam test 命令:

sudo control --reload-rules --log-priority=debug && udevadm trigger
sudo udevadm test  $(udevadm info -q path -n /dev/ttyACM0)

输出:

This program is for debugging only, it does not run any program
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.

Load module index
Parsed configuration file /usr/lib/systemd/network/99-default.link
Parsed configuration file /usr/lib/systemd/network/73-usb-net-by-mac.link
Created link configuration context.
Reading rules file: /usr/lib/udev/rules.d/39-usbmuxd.rules
Reading rules file: /usr/lib/udev/rules.d/40-usb-media-players.rules
Reading rules file: /usr/lib/udev/rules.d/40-usb_modeswitch.rules
Reading rules file: /usr/lib/udev/rules.d/40-vm-hotadd.rules
Reading rules file: /usr/lib/udev/rules.d/50-apport.rules
Reading rules file: /usr/lib/udev/rules.d/50-firmware.rules
Reading rules file: /usr/lib/udev/rules.d/50-udev-default.rules
Reading rules file: /usr/lib/udev/rules.d/55-dm.rules
Reading rules file: /usr/lib/udev/rules.d/55-ippusbxd.rules
Reading rules file: /usr/lib/udev/rules.d/56-hpmud.rules
Reading rules file: /usr/lib/udev/rules.d/60-autosuspend-chromiumos.rules
Reading rules file: /usr/lib/udev/rules.d/60-block.rules
Reading rules file: /usr/lib/udev/rules.d/60-cdrom_id.rules
Reading rules file: /usr/lib/udev/rules.d/60-crda.rules
Reading rules file: /usr/lib/udev/rules.d/60-drm.rules
Reading rules file: /usr/lib/udev/rules.d/60-evdev.rules
Reading rules file: /usr/lib/udev/rules.d/60-fido-id.rules
Reading rules file: /usr/lib/udev/rules.d/60-input-id.rules
Reading rules file: /usr/lib/udev/rules.d/60-inputattach.rules
Reading rules file: /usr/lib/udev/rules.d/60-libfprint-2.rules
Reading rules file: /usr/lib/udev/rules.d/60-libgphoto2-6.rules
Reading rules file: /usr/lib/udev/rules.d/60-libsane.rules
Reading rules file: /usr/lib/udev/rules.d/60-pcmcia.rules
Reading rules file: /usr/lib/udev/rules.d/60-persistent-alsa.rules
Reading rules file: /usr/lib/udev/rules.d/60-persistent-input.rules
Reading rules file: /usr/lib/udev/rules.d/60-persistent-storage-dm.rules
Reading rules file: /usr/lib/udev/rules.d/60-persistent-storage-tape.rules
Reading rules file: /usr/lib/udev/rules.d/60-persistent-storage.rules
Reading rules file: /usr/lib/udev/rules.d/60-persistent-v4l.rules
Reading rules file: /usr/lib/udev/rules.d/60-sensor.rules
Reading rules file: /usr/lib/udev/rules.d/60-serial.rules
Reading rules file: /usr/lib/udev/rules.d/60-tpm-udev.rules
Reading rules file: /usr/lib/udev/rules.d/61-autosuspend-manual.rules
Reading rules file: /usr/lib/udev/rules.d/61-gdm.rules
Reading rules file: /usr/lib/udev/rules.d/61-gnome-settings-daemon-rfkill.rules
Reading rules file: /usr/lib/udev/rules.d/61-persistent-storage-android.rules
Reading rules file: /usr/lib/udev/rules.d/64-btrfs.rules
Reading rules file: /usr/lib/udev/rules.d/64-xorg-xkb.rules
Reading rules file: /usr/lib/udev/rules.d/65-libwacom.rules
Reading rules file: /usr/lib/udev/rules.d/66-snapd-autoimport.rules
Reading rules file: /usr/lib/udev/rules.d/69-cd-sensors.rules
Reading rules file: /usr/lib/udev/rules.d/69-libmtp.rules
Reading rules file: /usr/lib/udev/rules.d/69-wacom.rules
Reading rules file: /usr/lib/udev/rules.d/70-joystick.rules
Reading rules file: /usr/lib/udev/rules.d/70-mouse.rules
Reading rules file: /usr/lib/udev/rules.d/70-power-switch.rules
Reading rules file: /usr/lib/udev/rules.d/70-printers.rules
Reading rules file: /etc/udev/rules.d/70-snap.snap-store.rules
Reading rules file: /etc/udev/rules.d/70-snap.snapd.rules
Reading rules file: /usr/lib/udev/rules.d/70-spice-vdagentd.rules
Reading rules file: /usr/lib/udev/rules.d/70-touchpad.rules
Reading rules file: /usr/lib/udev/rules.d/70-u2f.rules
Reading rules file: /usr/lib/udev/rules.d/70-uaccess.rules
Reading rules file: /usr/lib/udev/rules.d/71-nvidia.rules
Reading rules file: /usr/lib/udev/rules.d/71-power-switch-proliant.rules
Reading rules file: /usr/lib/udev/rules.d/71-seat.rules
Reading rules file: /usr/lib/udev/rules.d/71-u-d-c-gpu-detection.rules
Reading rules file: /usr/lib/udev/rules.d/73-seat-late.rules
Reading rules file: /usr/lib/udev/rules.d/73-special-net-names.rules
Reading rules file: /usr/lib/udev/rules.d/75-net-description.rules
Reading rules file: /usr/lib/udev/rules.d/75-probe_mtd.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-cinterion-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-dell-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-dlink-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-ericsson-mbm.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-fibocom-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-haier-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-huawei-net-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-longcheer-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-mtk-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-nokia-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-pcmcia-device-blacklist.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-qdl-device-blacklist.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-quectel-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-sierra.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-simtech-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-telit-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-tplink-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-ublox-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-usb-device-blacklist.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-usb-serial-adapters-greylist.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-x22x-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-zte-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/78-graphics-card.rules
Reading rules file: /usr/lib/udev/rules.d/78-sound-card.rules
Reading rules file: /usr/lib/udev/rules.d/80-debian-compat.rules
Reading rules file: /usr/lib/udev/rules.d/80-drivers.rules
Reading rules file: /usr/lib/udev/rules.d/80-iio-sensor-proxy.rules
Reading rules file: /usr/lib/udev/rules.d/80-libinput-device-groups.rules
Reading rules file: /usr/lib/udev/rules.d/80-mm-candidate.rules
Reading rules file: /usr/lib/udev/rules.d/80-net-setup-link.rules
Reading rules file: /usr/lib/udev/rules.d/80-udisks2.rules
Reading rules file: /usr/lib/udev/rules.d/81-net-dhcp.rules
Reading rules file: /usr/lib/udev/rules.d/84-nm-drivers.rules
Reading rules file: /usr/lib/udev/rules.d/85-brltty.rules
Reading rules file: /usr/lib/udev/rules.d/85-hdparm.rules
Reading rules file: /usr/lib/udev/rules.d/85-hplj10xx.rules
Reading rules file: /usr/lib/udev/rules.d/85-nm-unmanaged.rules
Reading rules file: /usr/lib/udev/rules.d/85-regulatory.rules
Reading rules file: /usr/lib/udev/rules.d/90-alsa-restore.rules
Reading rules file: /usr/lib/udev/rules.d/90-bolt.rules
Reading rules file: /usr/lib/udev/rules.d/90-console-setup.rules
Reading rules file: /usr/lib/udev/rules.d/90-fwupd-devices.rules
Reading rules file: /usr/lib/udev/rules.d/90-libgpod.rules
Reading rules file: /usr/lib/udev/rules.d/90-libinput-fuzz-override.rules
Reading rules file: /usr/lib/udev/rules.d/90-nm-thunderbolt.rules
Reading rules file: /usr/lib/udev/rules.d/90-pulseaudio.rules
Reading rules file: /usr/lib/udev/rules.d/95-cd-devices.rules
Reading rules file: /usr/lib/udev/rules.d/95-dm-notify.rules
Reading rules file: /usr/lib/udev/rules.d/95-upower-csr.rules
Reading rules file: /usr/lib/udev/rules.d/95-upower-hid.rules
Reading rules file: /usr/lib/udev/rules.d/95-upower-hidpp.rules
Reading rules file: /usr/lib/udev/rules.d/95-upower-wup.rules
Reading rules file: /usr/lib/udev/rules.d/96-e2scrub.rules
Reading rules file: /usr/lib/udev/rules.d/97-hid2hci.rules
Reading rules file: /usr/lib/udev/rules.d/99-systemd.rules
Configuration file /etc/udev/rules.d/99-usb-serial.rules is marked world-writable. Please remove world writability permission bits. Proceeding anyway.
Reading rules file: /etc/udev/rules.d/99-usb-serial.rules
Invalid inotify descriptor.
DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/tty/ttyACM0
DEVNAME=/dev/ttyACM0
MAJOR=166
MINOR=0
ACTION=add
SUBSYSTEM=tty
ID_BUS=usb
ID_VENDOR_ID=108c
ID_MODEL_ID=017b
ID_PCI_CLASS_FROM_DATABASE=Serial bus controller
ID_PCI_SUBCLASS_FROM_DATABASE=USB controller
ID_PCI_INTERFACE_FROM_DATABASE=XHCI
ID_VENDOR_FROM_DATABASE=Robert Bosch GmbH
ID_MODEL_FROM_DATABASE=Sunrise Point-LP USB 3.0 xHCI Controller
ID_VENDOR=Bosch_Connected_Devices_and_Solutions_GmbH
ID_VENDOR_ENC=Bosch\x20Connected\x20Devices\x20and\x20Solutions\x20GmbH
ID_MODEL=XDK_Application
ID_MODEL_ENC=XDK\x20Application
ID_REVISION=0000
ID_SERIAL=Bosch_Connected_Devices_and_Solutions_GmbH_XDK_Application_2496B4065B328D1E
ID_SERIAL_SHORT=2496B4065B328D1E
ID_TYPE=generic
ID_USB_INTERFACES=:020200:0a0000:
ID_USB_INTERFACE_NUM=00
ID_USB_DRIVER=cdc_acm
ID_USB_CLASS_FROM_DATABASE=Communications
ID_PATH=pci-0000:00:14.0-usb-0:1:1.0
ID_PATH_TAG=pci-0000_00_14_0-usb-0_1_1_0
DEVLINKS=/dev/serial/by-path/pci-0000:00:14.0-usb-0:1:1.0 /dev/serial/by-id/usb-Bosch_Connected_Devices_and_Solutions_GmbH_XDK_Application_2496B4065B328D1E-if00 /dev//dev/mydevice
ID_MM_CANDIDATE=1
TAGS=:systemd:
USEC_INITIALIZED=6250133716
Unload module index
Unloaded link configuration context.

我猜问题似乎出在这里:

Reading rules file: /etc/udev/rules.d/99-usb-serial.rules
Invalid inotify descriptor

但我不知道如何解决这个问题。其他答案似乎没有帮助。

答案1

已创建 simlink,但由于以下原因,它正在创建另一个dev文件夹devSYMLINK+="/dev/mydevice"

因此,只需删除/dev即可SYMLINKdev SYMLINK+="mydevice"

答案2

规则应该是:

KERNEL=="ttyACM*", ... , SYMLINK+="ttyUSB%n", MODE:="0666"

希望这可以帮助。

相关内容