udev 规则适用,但不设置组

udev 规则适用,但不设置组

我有一块 STM32-Bluepill 板,我在其中刷写了 USB 引导加载程序。如果我将它连接到我的计算机,它会安装在/dev/ttyACM0.lsusb显示为Bus 001 Device 006: ID 1eaf:0004 Leaflabs Maple serial interface

对于 Arduino 项目,我diy的计算机上确实有一个小组。因此,对于 Bluepill,我创建了以下 udev 规则:

#Bootloader-Mode
DRIVERS=="usb", SUBSYSTEMS=="usb", ATTRS{idVendor}=="1eaf", ATTRS{idProduct}=="0004", GROUP="diy", MODE="0660"
#Normal-Operation-Mode
DRIVERS=="usb", SUBSYSTEMS=="usb", ATTRS{idVendor}=="1eaf", ATTRS{idProduct}=="0003", GROUP="diy", MODE="0660"

这两个规则都适用,但没有一个规则正确设置组/dev/ttyACM0(它总是uucp)。我知道这些规则已应用,因为我目前使用一种解决方法,将模式设置为0666。这使我有权使用该设备,但无论如何我想正确设置组。

uucp仅由我的默认规则之一设置:/usr/lib/udev/rules.d/50-udev-default.rules。但我的规则是/etc/udev/rules.d/100-bluepill.rules,因此它应该具有更高的优先级。

答案1

尽管数字前缀是指定 udev 规则顺序的常规方法,但处理实际上是词法的。从man udev

RULES FILES
       The udev rules are read from the files located in the system rules
       directories /lib/udev/rules.d and /usr/local/lib/udev/rules.d, the
       volatile runtime directory /run/udev/rules.d and the local
       administration directory /etc/udev/rules.d. All rules files are
       collectively sorted and processed in lexical order, regardless of the
       directories in which they live. However, files with identical filenames
       replace each other. Files in /etc have the highest priority, files in
       /run take precedence over files with the same name under /usr. This can
       be used to override a system-supplied rules file with a local file if
       needed; a symlink in /etc with the same name as a rules file in /lib,
       pointing to /dev/null, disables the rules file entirely. Rule files
       must have the extension .rules; other extensions are ignored.

如此100-bluepill.rules排序 50-udev-default.rules(1 < 5)。要使您的规则最后应用,请选择类似 的内容99-bluepill.rules

相关内容