ubuntu udev规则在"udevadm test“中有效,但在”udevadm trigger“中无效

nfeuvbwi  于 2023-02-03  发布在  其他
关注(0)|答案(2)|浏览(266)

我有一个基于this question创建的4端口USB-RS232集线器的udev规则:
SUBSYSTEMS=="usb", DRIVERS=="usb", ATTRS{serial}=="A4018BU0", SYMLINK+="ttyLumagen"
它没有像预期的那样创建符号链接,所以我尝试了debug,它似乎工作:

% sudo udevadm info --query=path --name=/dev/ttyUSB0
/devices/pci0000:00/0000:00:14.0/usb3/3-9/3-9.1/3-9.1:1.0/ttyUSB0/tty/ttyUSB0
% sudo udevadm test /devices/pci0000:00/0000:00:14.0/usb3/3-9/3-9.1/3-9.1:1.0/ttyUSB0/tty/ttyUSB0
calling: test
version 204
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.

=== trie on-disk ===
tool version:          204
file size:         5661386 bytes
header size             80 bytes
strings            1265626 bytes
nodes              4395680 bytes
load module index
read rules file: /lib/udev/rules.d/40-crda.rules
read rules file: /lib/udev/rules.d/40-gnupg.rules
read rules file: /lib/udev/rules.d/40-hyperv-hotadd.rules
read rules file: /lib/udev/rules.d/42-usb-hid-pm.rules
read rules file: /lib/udev/rules.d/50-firmware.rules
read rules file: /lib/udev/rules.d/50-udev-default.rules
read rules file: /lib/udev/rules.d/55-dm.rules
read rules file: /lib/udev/rules.d/60-cdrom_id.rules
read rules file: /lib/udev/rules.d/60-keyboard.rules
read rules file: /lib/udev/rules.d/60-persistent-alsa.rules
read rules file: /lib/udev/rules.d/60-persistent-input.rules
read rules file: /lib/udev/rules.d/60-persistent-serial.rules
read rules file: /lib/udev/rules.d/60-persistent-storage-dm.rules
read rules file: /lib/udev/rules.d/60-persistent-storage-tape.rules
read rules file: /lib/udev/rules.d/60-persistent-storage.rules
read rules file: /lib/udev/rules.d/60-persistent-v4l.rules
read rules file: /lib/udev/rules.d/60-zvol.rules
read rules file: /lib/udev/rules.d/61-accelerometer.rules
read rules file: /lib/udev/rules.d/64-btrfs.rules
read rules file: /lib/udev/rules.d/64-md-raid.rules
read rules file: /lib/udev/rules.d/69-vdev.rules
read rules file: /lib/udev/rules.d/70-power-switch.rules
read rules file: /lib/udev/rules.d/70-uaccess.rules
read rules file: /lib/udev/rules.d/71-biosdevname.rules
read rules file: /lib/udev/rules.d/71-seat.rules
read rules file: /lib/udev/rules.d/73-idrac.rules
read rules file: /lib/udev/rules.d/73-seat-late.rules
read rules file: /lib/udev/rules.d/75-net-description.rules
read rules file: /lib/udev/rules.d/75-persistent-net-generator.rules
read rules file: /lib/udev/rules.d/75-probe_mtd.rules
read rules file: /lib/udev/rules.d/75-tty-description.rules
read rules file: /lib/udev/rules.d/78-graphics-card.rules
read rules file: /lib/udev/rules.d/78-sound-card.rules
read rules file: /lib/udev/rules.d/80-drivers.rules
read rules file: /lib/udev/rules.d/85-hdparm.rules
read rules file: /lib/udev/rules.d/85-keyboard-configuration.rules
read rules file: /lib/udev/rules.d/85-regulatory.rules
read rules file: /lib/udev/rules.d/95-udev-late.rules
read rules file: /etc/udev/rules.d/flirc.rules
read rules file: /etc/udev/rules.d/serialports.rules
read rules file: /etc/udev/rules.d/tivoslide.rules
rules contain 24576 bytes tokens (2048 * 12 bytes), 12172 bytes strings
1941 strings (23630 bytes), 1266 de-duplicated (12134 bytes), 676 trie nodes used
GROUP 20 /lib/udev/rules.d/50-udev-default.rules:19
IMPORT builtin 'path_id' /lib/udev/rules.d/60-persistent-serial.rules:9
LINK 'serial/by-path/pci-0000:00:14.0-usb-0:9.1:1.0-port0' /lib/udev/rules.d/60-persistent-serial.rules:11
IMPORT builtin 'usb_id' /lib/udev/rules.d/60-persistent-serial.rules:13
/sys/devices/pci0000:00/0000:00:14.0/usb3/3-9/3-9.1/3-9.1:1.0: if_class 255 protocol 0
LINK 'serial/by-id/usb-FTDI_FT232R_USB_UART_A4018BU0-if00-port0' /lib/udev/rules.d/60-persistent-serial.rules:18
IMPORT builtin skip 'usb_id' /lib/udev/rules.d/75-tty-description.rules:6
IMPORT builtin 'hwdb' /lib/udev/rules.d/75-tty-description.rules:6
LINK 'ttyLumagen' /etc/udev/rules.d/serialports.rules:2
handling device node '/dev/ttyUSB0', devnum=c188:0, mode=0660, uid=0, gid=20
preserve permissions /dev/ttyUSB0, 020660, uid=0, gid=20
preserve already existing symlink '/dev/char/188:0' to '../ttyUSB0'
found 'c188:0' claiming '/run/udev/links/\x2fserial\x2fby-id\x2fusb-FTDI_FT232R_USB_UART_A4018BU0-if00-port0'
creating link '/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A4018BU0-if00-port0' to '/dev/ttyUSB0'
preserve already existing symlink '/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A4018BU0-if00-port0' to '../../ttyUSB0'
found 'c188:0' claiming '/run/udev/links/\x2fserial\x2fby-path\x2fpci-0000:00:14.0-usb-0:9.1:1.0-port0'
creating link '/dev/serial/by-path/pci-0000:00:14.0-usb-0:9.1:1.0-port0' to '/dev/ttyUSB0'
preserve already existing symlink '/dev/serial/by-path/pci-0000:00:14.0-usb-0:9.1:1.0-port0' to '../../ttyUSB0'
creating link '/dev/ttyLumagen' to '/dev/ttyUSB0'
creating symlink '/dev/ttyLumagen' to 'ttyUSB0'
.ID_PORT=0
ACTION=add
DEVLINKS=/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A4018BU0-if00-port0 /dev/serial/by-path/pci-0000:00:14.0-usb-0:9.1:1.0-port0 /dev/ttyLumagen
DEVNAME=/dev/ttyUSB0
DEVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-9/3-9.1/3-9.1:1.0/ttyUSB0/tty/ttyUSB0
ID_BUS=usb
ID_MODEL=FT232R_USB_UART
ID_MODEL_ENC=FT232R\x20USB\x20UART
ID_MODEL_FROM_DATABASE=FT232 USB-Serial (UART) IC
ID_MODEL_ID=6001
ID_PATH=pci-0000:00:14.0-usb-0:9.1:1.0
ID_PATH_TAG=pci-0000_00_14_0-usb-0_9_1_1_0
ID_REVISION=0600
ID_SERIAL=FTDI_FT232R_USB_UART_A4018BU0
ID_SERIAL_SHORT=A4018BU0
ID_TYPE=generic
ID_USB_DRIVER=ftdi_sio
ID_USB_INTERFACES=:ffffff:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=FTDI
ID_VENDOR_ENC=FTDI
ID_VENDOR_FROM_DATABASE=Future Technology Devices International, Ltd
ID_VENDOR_ID=0403
MAJOR=188
MINOR=0
SUBSYSTEM=tty
USEC_INITIALIZED=426370555
unload module index

符号链接确实如预期的那样创建了。然后我运行udevadm trigger,它删除了符号链接。
为什么udevadm trigger(和正常的udev操作)不起作用,而udevadm test起作用?
系统为Ubuntu服务器14.04 LTS:Linux jimmy 3.13.0-40-generic #69-Ubuntu SMP Thu Nov 13 17:53:56 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

0yg35tkg

0yg35tkg1#

我知道这是旧的,但我会把它留在这里,为未来的搜索像我一样:
检查您的规则是否包含常用的ACTION=="add"。似乎udevadm trigger将其处理视为change操作,因此任何包含此子句的规则都不匹配。udevadm test确实使用add操作,这就是它在那里工作的原因。它在正常 Boot 设置下也应该工作,因为它也是add操作。

iih3973s

iih3973s2#

我遇到了完全相同的现象。udevadm test工作,但udevadm trigger不工作。我的情况是udevd没有运行。我只是键入udevd &,然后,规则应用于udevadm trigger

相关问题