这个 udev 规则有什么问题?

这个 udev 规则有什么问题?

我正在读这篇文章关联试图制定适当的规则,使 BSG 设备节点拥有wheel的组所有权和0660的权限。这是我的规则:

[user@mylinux ~]$ cat /etc/udev/rules.d/bsg.rules
NAME=="bsg/[0-9]:[0-9]:[0-9]:[0-9]", SUBSYSTEM=="bsg", GROUP=wheel, MODE=0660

但它不起作用,如下所示:

[user@mylinux ~]$ ls -l /dev/bsg
total 0
crw-rw---- 1 root root 252, 0 Oct 30 06:02 0:0:0:0

udevadm info -q all -n /dev/bsg/0:0:0:0这是我要处理的输出:

P: /devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/bsg/0:0:0:0
N: bsg/0:0:0:0
S: char/252:0
E: UDEV_LOG=3
E: DEVPATH=/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/bsg/0:0:0:0
E: MAJOR=252
E: MINOR=0
E: DEVNAME=/dev/bsg/0:0:0:0
E: SUBSYSTEM=bsg
E: DEVLINKS=/dev/char/252:0

现在,我假设该值N: bsg/0:0:0:0姓名udev 在规则文件中期望的键。最终,我需要让这条规则足够通用,以便任意数量的 BSG 设备都可以适当更改权限。这NAME="bsg/[0-9]*:[0-9]*:[0-9]*:[0-9]*"。那也不起作用。

如果重要的话,这是在 CentOS 6.2 上。


更新问题以显示udevadm test下面 slm 建议的输出。我已将规则文件的名称更改为/etc/udev/rules.d/80-bsg.rules.文件名似乎是唯一的。文件内容尚未发生任何更改。这是以下的输出udevadm test

parse_file: reading '/lib/udev/rules.d/10-console.rules' as rules file
parse_file: reading '/lib/udev/rules.d/10-dm.rules' as rules file
parse_file: reading '/lib/udev/rules.d/11-dm-lvm.rules' as rules file
parse_file: reading '/lib/udev/rules.d/13-dm-disk.rules' as rules file
parse_file: reading '/etc/udev/rules.d/40-hplip.rules' as rules file
parse_file: reading '/lib/udev/rules.d/40-isdn.rules' as rules file
parse_file: reading '/lib/udev/rules.d/40-libgphoto2.rules' as rules file
parse_file: reading '/lib/udev/rules.d/40-multipath.rules' as rules file
parse_file: reading '/lib/udev/rules.d/40-redhat.rules' as rules file
parse_file: reading '/lib/udev/rules.d/50-firmware.rules' as rules file
parse_file: reading '/lib/udev/rules.d/50-udev-default.rules' as rules file
parse_file: reading '/etc/udev/rules.d/56-hpmud_support.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-cdrom_id.rules' as rules file
parse_file: reading '/etc/udev/rules.d/60-fprint-autosuspend.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-net.rules' as rules file
parse_file: reading '/etc/udev/rules.d/60-pcmcia.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-persistent-alsa.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-persistent-input.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-persistent-serial.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-persistent-storage-tape.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-persistent-storage.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-persistent-v4l.rules' as rules file
parse_file: reading '/etc/udev/rules.d/60-raw.rules' as rules file
parse_file: reading '/lib/udev/rules.d/61-mobile-action.rules' as rules file
parse_file: reading '/lib/udev/rules.d/61-option-modem-modeswitch.rules' as rules file
parse_file: reading '/lib/udev/rules.d/61-persistent-storage-edd.rules' as rules file
parse_file: reading '/lib/udev/rules.d/64-device-mapper.rules' as rules file
parse_file: reading '/lib/udev/rules.d/64-md-raid.rules' as rules file
parse_file: reading '/lib/udev/rules.d/65-libsane.rules' as rules file
parse_file: reading '/lib/udev/rules.d/65-md-incremental.rules' as rules file
parse_file: reading '/lib/udev/rules.d/70-acl.rules' as rules file
parse_file: reading '/lib/udev/rules.d/70-anaconda.rules' as rules file
parse_file: reading '/etc/udev/rules.d/70-cups-libusb.rules' as rules file
parse_file: reading '/lib/udev/rules.d/70-hid2hci.rules' as rules file
parse_file: reading '/etc/udev/rules.d/70-persistent-net.rules' as rules file
parse_file: reading '/lib/udev/rules.d/70-printers.rules' as rules file
parse_file: reading '/lib/udev/rules.d/75-cd-aliases-generator.rules' as rules file
parse_file: reading '/lib/udev/rules.d/75-net-description.rules' as rules file
parse_file: reading '/lib/udev/rules.d/75-persistent-net-generator.rules' as rules file
parse_file: reading '/lib/udev/rules.d/75-tty-description.rules' as rules file
parse_file: reading '/lib/udev/rules.d/77-mm-ericsson-mbm.rules' as rules file
parse_file: reading '/lib/udev/rules.d/77-mm-longcheer-port-types.rules' as rules file
parse_file: reading '/lib/udev/rules.d/77-mm-pcmcia-device-blacklist.rules' as rules file
parse_file: reading '/lib/udev/rules.d/77-mm-platform-serial-whitelist.rules' as rules file
parse_file: reading '/lib/udev/rules.d/77-mm-simtech-port-types.rules' as rules file
parse_file: reading '/lib/udev/rules.d/77-mm-usb-device-blacklist.rules' as rules file
parse_file: reading '/lib/udev/rules.d/77-mm-zte-port-types.rules' as rules file
parse_file: reading '/lib/udev/rules.d/77-nm-olpc-mesh.rules' as rules file
parse_file: reading '/lib/udev/rules.d/78-sound-card.rules' as rules file
parse_file: reading '/lib/udev/rules.d/79-fstab_import.rules' as rules file
parse_file: reading '/etc/udev/rules.d/80-bsg.rules' as rules file
parse_file: reading '/lib/udev/rules.d/80-drivers.rules' as rules file
parse_file: reading '/lib/udev/rules.d/80-udisks.rules' as rules file
parse_file: reading '/lib/udev/rules.d/85-regulatory.rules' as rules file
parse_file: reading '/lib/udev/rules.d/88-clock.rules' as rules file
parse_file: reading '/etc/udev/rules.d/90-alsa.rules' as rules file
parse_file: reading '/etc/udev/rules.d/90-hal.rules' as rules file
parse_file: reading '/lib/udev/rules.d/90-pulseaudio.rules' as rules file
parse_file: reading '/etc/udev/rules.d/91-drm-modeset.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-devkit-power-battery-recall-dell.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-devkit-power-battery-recall-fujitsu.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-devkit-power-battery-recall-gateway.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-devkit-power-battery-recall-ibm.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-devkit-power-battery-recall-lenovo.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-devkit-power-battery-recall-toshiba.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-devkit-power-csr.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-devkit-power-hid.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-devkit-power-wup.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-dm-notify.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-keymap.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-udev-late.rules' as rules file
parse_file: reading '/etc/udev/rules.d/98-kexec.rules' as rules file
parse_file: reading '/etc/udev/rules.d/99-fuse.rules' as rules file
parse_file: reading '/dev/.udev/rules.d/99-root.rules' as rules file
udev_rules_new: rules use 141480 bytes tokens (11790 * 12 bytes), 29125 bytes buffer
udev_rules_new: temporary index used 50200 bytes (2510 * 20 bytes)
udev_device_new_from_syspath: device 0x89af120 has devpath '/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/bsg/0:0:0:0'
udev_device_new_from_syspath: device 0x89c7ac0 has devpath '/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/bsg/0:0:0:0'
udev_device_read_db: device 0x89c7ac0 filled with db symlink data '/dev/bsg/0:0:0:0'
udev_rules_apply_to_event: LINK 'char/252:0' /lib/udev/rules.d/50-udev-default.rules:4
udev_device_new_from_syspath: device 0x89b0d48 has devpath '/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0'
udev_rules_apply_to_event: RUN 'socket:@/org/freedesktop/hal/udev_event' /etc/udev/rules.d/90-hal.rules:2
udev_event_execute_rules: no node name set, will use kernel supplied name 'bsg/0:0:0:0'
udev_device_update_db: create db link (bsg/0:0:0:0 char/252:0)
udev_device_update_db: unable to create db file '/dev/.udev/db/bsg:0:0:0:0': No such file or directory
udev_node_add: creating device node '/dev/bsg/0:0:0:0', devnum=252:0, mode=0660, uid=0, gid=0
udev_node_mknod: preserve file '/dev/bsg/0:0:0:0', because it has correct dev_t
udev_node_mknod: preserve permissions /dev/bsg/0:0:0:0, 020660, uid=0, gid=0
node_symlink: preserve already existing symlink '/dev/char/252:0' to '../bsg/0:0:0:0'
udevadm_test: UDEV_LOG=6
udevadm_test: DEVPATH=/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/bsg/0:0:0:0
udevadm_test: MAJOR=252
udevadm_test: MINOR=0
udevadm_test: DEVNAME=/dev/bsg/0:0:0:0
udevadm_test: ACTION=add
udevadm_test: SUBSYSTEM=bsg
udevadm_test: DEVLINKS=/dev/char/252:0
udevadm_test: run: 'socket:@/org/freedesktop/hal/udev_event'

答案1

尝试更改规则文件的名称,使其带有数字前缀。也许是这样的:

/etc/udev/rules.d/99-bsg.rules

您还可以使用以下方法测试您的规则文件udevadm test

$ udevadm test /devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/bsg/0:0:0:0

参考

相关内容