You are not logged in.

#1 2013-04-08 13:10:19

Hacksign
Member
Registered: 2012-07-30
Posts: 68

[SOLVED]udev doesn't execute my custom rule

Here is my device info:

XSign rules.d # udevadm info -a -n /dev/sdb1

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:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/host8/target8:0:0/8:0:0:0/block/sdb/sdb1':
    KERNEL=="sdb1"
    SUBSYSTEM=="block"
    DRIVER==""
    ATTR{ro}=="0"
    ATTR{size}=="15685569"
    ATTR{stat}=="     240     1120     1906      320        0        0        0        0        0      320      320"
    ATTR{partition}=="1"
    ATTR{start}=="63"
    ATTR{discard_alignment}=="0"
    ATTR{alignment_offset}=="0"
    ATTR{inflight}=="       0        0"

  looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/host8/target8:0:0/8:0:0:0/block/sdb':
    KERNELS=="sdb"
    SUBSYSTEMS=="block"
    DRIVERS==""
    ATTRS{ro}=="0"
    ATTRS{size}=="15685632"
    ATTRS{stat}=="     255     1123     2050      330        0        0        0        0        0      330      330"
    ATTRS{range}=="16"
    ATTRS{discard_alignment}=="0"
    ATTRS{events}=="media_change"
    ATTRS{ext_range}=="256"
    ATTRS{events_poll_msecs}=="-1"
    ATTRS{alignment_offset}=="0"
    ATTRS{inflight}=="       0        0"
    ATTRS{removable}=="1"
    ATTRS{capability}=="51"
    ATTRS{events_async}==""

  looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/host8/target8:0:0/8:0:0:0':
    KERNELS=="8:0:0:0"
    SUBSYSTEMS=="scsi"
    DRIVERS=="sd"
    ATTRS{rev}=="1.00"
    ATTRS{type}=="0"
    ATTRS{scsi_level}=="0"
    ATTRS{model}=="USB  SD Reader  "
    ATTRS{state}=="running"
    ATTRS{queue_type}=="none"
    ATTRS{iodone_cnt}=="0x1dd"
    ATTRS{iorequest_cnt}=="0x1dd"
    ATTRS{timeout}=="30"
    ATTRS{evt_media_change}=="0"
    ATTRS{max_sectors}=="240"
    ATTRS{ioerr_cnt}=="0x2"
    ATTRS{queue_depth}=="1"
    ATTRS{vendor}=="Generic "
    ATTRS{device_blocked}=="0"
    ATTRS{iocounterbits}=="32"

  looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/host8/target8:0:0':
    KERNELS=="target8:0:0"
    SUBSYSTEMS=="scsi"
    DRIVERS==""

  looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/host8':
    KERNELS=="host8"
    SUBSYSTEMS=="scsi"
    DRIVERS==""

  looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0':
    KERNELS=="1-1.1:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb-storage"
    ATTRS{bInterfaceClass}=="08"
    ATTRS{bInterfaceSubClass}=="06"
    ATTRS{bInterfaceProtocol}=="50"
    ATTRS{bNumEndpoints}=="02"
    ATTRS{supports_autosuspend}=="1"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bInterfaceNumber}=="00"

  looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1':
    KERNELS=="1-1.1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{devpath}=="1.1"
    ATTRS{idVendor}=="090c"
    ATTRS{speed}=="480"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{busnum}=="1"
    ATTRS{devnum}=="8"
    ATTRS{configuration}==""
    ATTRS{bMaxPower}=="500mA"
    ATTRS{authorized}=="1"
    ATTRS{bmAttributes}=="80"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{maxchild}=="0"
    ATTRS{bcdDevice}=="0100"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{serial}=="12345678901234567890"
    ATTRS{version}==" 2.00"
    ATTRS{urbnum}=="1264"
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="Silicon Motion, Inc."
    ATTRS{removable}=="removable"
    ATTRS{idProduct}=="6200"
    ATTRS{bDeviceClass}=="00"
    ATTRS{product}=="Generic USB2.0 card "

  looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1':
    KERNELS=="1-1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{devpath}=="1"
    ATTRS{idVendor}=="8087"
    ATTRS{speed}=="480"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{busnum}=="1"
    ATTRS{devnum}=="2"
    ATTRS{configuration}==""
    ATTRS{bMaxPower}=="  0mA"
    ATTRS{authorized}=="1"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{maxchild}=="6"
    ATTRS{bcdDevice}=="0000"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{version}==" 2.00"
    ATTRS{urbnum}=="130"
    ATTRS{ltm_capable}=="no"
    ATTRS{removable}=="fixed"
    ATTRS{idProduct}=="0020"
    ATTRS{bDeviceClass}=="09"

  looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1':
    KERNELS=="usb1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{devpath}=="0"
    ATTRS{idVendor}=="1d6b"
    ATTRS{speed}=="480"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{authorized_default}=="1"
    ATTRS{busnum}=="1"
    ATTRS{devnum}=="1"
    ATTRS{configuration}==""
    ATTRS{bMaxPower}=="  0mA"
    ATTRS{authorized}=="1"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{maxchild}=="3"
    ATTRS{bcdDevice}=="0308"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{serial}=="0000:00:1a.0"
    ATTRS{version}==" 2.00"
    ATTRS{urbnum}=="26"
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="Linux 3.8.3-2-ARCH ehci_hcd"
    ATTRS{removable}=="unknown"
    ATTRS{idProduct}=="0002"
    ATTRS{bDeviceClass}=="09"
    ATTRS{product}=="EHCI Host Controller"

  looking at parent device '/devices/pci0000:00/0000:00:1a.0':
    KERNELS=="0000:00:1a.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="ehci-pci"
    ATTRS{irq}=="23"
    ATTRS{subsystem_vendor}=="0x17aa"
    ATTRS{broken_parity_status}=="0"
    ATTRS{class}=="0x0c0320"
    ATTRS{companion}==""
    ATTRS{consistent_dma_mask_bits}=="32"
    ATTRS{dma_mask_bits}=="32"
    ATTRS{local_cpus}=="ff"
    ATTRS{device}=="0x3b3c"
    ATTRS{uframe_periodic_max}=="100"
    ATTRS{enable}=="1"
    ATTRS{msi_bus}==""
    ATTRS{local_cpulist}=="0-7"
    ATTRS{vendor}=="0x8086"
    ATTRS{subsystem_device}=="0x2163"
    ATTRS{d3cold_allowed}=="1"

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

and rule:

XSign rules.d # cat 100-usb.rules 
KERNEL=="sd*", SUBSYSTEMS=="scsi", ATTRS{model}=="USB SD Reader", SYMLINK+="test_%n", OPTIONS+="all_partitions"

and the test:

XSign rules.d # udevadm test /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/host8/target8:0:0/8:0:0:0/block/sdb/sdb1
calling: test
version 198
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:          198
file size:         5544030 bytes
header size             80 bytes
strings            1242254 bytes
nodes              4301696 bytes
load module index
Skipping overridden file: /usr/lib/udev/rules.d/80-net-name-slot.rules.
read rules file: /etc/udev/rules.d/01-razer-udev.rules
read rules file: /usr/lib/udev/rules.d/10-dm.rules
read rules file: /usr/lib/udev/rules.d/10-vboxdrv.rules
read rules file: /etc/udev/rules.d/100-usb.rules
read rules file: /usr/lib/udev/rules.d/11-dm-lvm.rules
read rules file: /usr/lib/udev/rules.d/13-dm-disk.rules
read rules file: /usr/lib/udev/rules.d/40-hpet-permissions.rules
read rules file: /usr/lib/udev/rules.d/42-usb-hid-pm.rules
read rules file: /usr/lib/udev/rules.d/50-udev-default.rules
read rules file: /usr/lib/udev/rules.d/60-cdrom_id.rules
read rules file: /usr/lib/udev/rules.d/60-fprint-autosuspend.rules
read rules file: /usr/lib/udev/rules.d/60-pcmcia.rules
read rules file: /usr/lib/udev/rules.d/60-persistent-alsa.rules
read rules file: /usr/lib/udev/rules.d/60-persistent-input.rules
read rules file: /usr/lib/udev/rules.d/60-persistent-serial.rules
read rules file: /usr/lib/udev/rules.d/60-persistent-storage-tape.rules
read rules file: /usr/lib/udev/rules.d/60-persistent-storage.rules
read rules file: /usr/lib/udev/rules.d/60-persistent-v4l.rules
read rules file: /usr/lib/udev/rules.d/60-rfkill.rules
read rules file: /usr/lib/udev/rules.d/60-vboxguest.rules
read rules file: /usr/lib/udev/rules.d/61-accelerometer.rules
read rules file: /usr/lib/udev/rules.d/63-md-raid-arrays.rules
read rules file: /usr/lib/udev/rules.d/64-btrfs.rules
read rules file: /usr/lib/udev/rules.d/64-md-raid-assembly.rules
read rules file: /usr/lib/udev/rules.d/69-cd-sensors.rules
IMPORT found builtin 'usb_id --export %p', replacing /usr/lib/udev/rules.d/69-cd-sensors.rules:85
read rules file: /usr/lib/udev/rules.d/69-dm-lvm-metad.rules
read rules file: /usr/lib/udev/rules.d/70-infrared.rules
read rules file: /usr/lib/udev/rules.d/70-power-switch.rules
read rules file: /usr/lib/udev/rules.d/70-uaccess.rules
read rules file: /usr/lib/udev/rules.d/71-seat.rules
read rules file: /usr/lib/udev/rules.d/73-seat-late.rules
read rules file: /usr/lib/udev/rules.d/75-net-description.rules
read rules file: /usr/lib/udev/rules.d/75-probe_mtd.rules
read rules file: /usr/lib/udev/rules.d/75-tty-description.rules
read rules file: /usr/lib/udev/rules.d/78-sound-card.rules
read rules file: /usr/lib/udev/rules.d/80-drivers.rules
read rules file: /etc/udev/rules.d/80-net-name-slot.rules
read rules file: /usr/lib/udev/rules.d/80-udisks.rules
read rules file: /usr/lib/udev/rules.d/90-alsa-restore.rules
read rules file: /etc/udev/rules.d/91-fingerprint-gui-upek.rules
read rules file: /usr/lib/udev/rules.d/95-cd-devices.rules
read rules file: /usr/lib/udev/rules.d/95-dm-notify.rules
read rules file: /usr/lib/udev/rules.d/95-keyboard-force-release.rules
read rules file: /usr/lib/udev/rules.d/95-keymap.rules
read rules file: /usr/lib/udev/rules.d/95-udev-late.rules
read rules file: /usr/lib/udev/rules.d/97-bluetooth-hid2hci.rules
read rules file: /usr/lib/udev/rules.d/99-laptop-mode.rules
read rules file: /usr/lib/udev/rules.d/99-systemd.rules
rules contain 49152 bytes tokens (4096 * 12 bytes), 20074 bytes strings
3343 strings (40625 bytes), 2291 de-duplicated (21604 bytes), 1053 trie nodes used
GROUP 6 /usr/lib/udev/rules.d/50-udev-default.rules:40
LINK 'disk/by-id/usb-Generic_USB_SD_Reader_12345678901234567890-0:0-part1' /usr/lib/udev/rules.d/60-persistent-storage.rules:43
LINK 'disk/by-path/pci-0000:00:1a.0-usb-0:1.1:1.0-scsi-0:0:0:0-part1' /usr/lib/udev/rules.d/60-persistent-storage.rules:57
IMPORT builtin 'blkid' /usr/lib/udev/rules.d/60-persistent-storage.rules:70
probe /dev/sdb1 raid offset=0
LINK 'disk/by-uuid/1DFC8855338F968C' /usr/lib/udev/rules.d/60-persistent-storage.rules:76
LINK 'disk/by-label/Hacksign\x27s\x20Documents\x20Disk' /usr/lib/udev/rules.d/60-persistent-storage.rules:77
IMPORT 'udisks-part-id /dev/sdb1' /usr/lib/udev/rules.d/80-udisks.rules:84
starting 'udisks-part-id /dev/sdb1'
'udisks-part-id /dev/sdb1' [2444] exit with return code 0
handling device node '/dev/sdb1', devnum=b8:17, mode=0660, uid=0, gid=6
preserve permissions /dev/sdb1, 060660, uid=0, gid=6
preserve already existing symlink '/dev/block/8:17' to '../sdb1'
found 'b8:17' claiming '/run/udev/links/\x2fdisk\x2fby-id\x2fusb-Generic_USB_SD_Reader_12345678901234567890-0:0-part1'
creating link '/dev/disk/by-id/usb-Generic_USB_SD_Reader_12345678901234567890-0:0-part1' to '/dev/sdb1'
preserve already existing symlink '/dev/disk/by-id/usb-Generic_USB_SD_Reader_12345678901234567890-0:0-part1' to '../../sdb1'
found 'b8:17' claiming '/run/udev/links/\x2fdisk\x2fby-label\x2fHacksign\x5cx27s\x5cx20Documents\x5cx20Disk'
creating link '/dev/disk/by-label/Hacksign\x27s\x20Documents\x20Disk' to '/dev/sdb1'
preserve already existing symlink '/dev/disk/by-label/Hacksign\x27s\x20Documents\x20Disk' to '../../sdb1'
found 'b8:17' claiming '/run/udev/links/\x2fdisk\x2fby-path\x2fpci-0000:00:1a.0-usb-0:1.1:1.0-scsi-0:0:0:0-part1'
creating link '/dev/disk/by-path/pci-0000:00:1a.0-usb-0:1.1:1.0-scsi-0:0:0:0-part1' to '/dev/sdb1'
preserve already existing symlink '/dev/disk/by-path/pci-0000:00:1a.0-usb-0:1.1:1.0-scsi-0:0:0:0-part1' to '../../sdb1'
found 'b8:17' claiming '/run/udev/links/\x2fdisk\x2fby-uuid\x2f1DFC8855338F968C'
creating link '/dev/disk/by-uuid/1DFC8855338F968C' to '/dev/sdb1'
preserve already existing symlink '/dev/disk/by-uuid/1DFC8855338F968C' to '../../sdb1'
ACTION=add
DEVLINKS=/dev/disk/by-id/usb-Generic_USB_SD_Reader_12345678901234567890-0:0-part1 /dev/disk/by-label/Hacksign\x27s\x20Documents\x20Disk /dev/disk/by-path/pci-0000:00:1a.0-usb-0:1.1:1.0-scsi-0:0:0:0-part1 /dev/disk/by-uuid/1DFC8855338F968C
DEVNAME=/dev/sdb1
DEVPATH=/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/host8/target8:0:0/8:0:0:0/block/sdb/sdb1
DEVTYPE=partition
ID_BUS=usb
ID_DRIVE_FLASH_SD=1
ID_FS_LABEL=Hacksign_s_Documents_Disk
ID_FS_LABEL_ENC=Hacksign\x27s\x20Documents\x20Disk
ID_FS_TYPE=ntfs
ID_FS_USAGE=filesystem
ID_FS_UUID=1DFC8855338F968C
ID_FS_UUID_ENC=1DFC8855338F968C
ID_INSTANCE=0:0
ID_MODEL=USB_SD_Reader
ID_MODEL_ENC=USB\x20\x20SD\x20Reader\x20\x20
ID_MODEL_ID=6200
ID_PART_ENTRY_DISK=8:16
ID_PART_ENTRY_NUMBER=1
ID_PART_ENTRY_OFFSET=63
ID_PART_ENTRY_SCHEME=dos
ID_PART_ENTRY_SIZE=15685569
ID_PART_ENTRY_TYPE=0x87
ID_PART_TABLE_TYPE=dos
ID_PATH=pci-0000:00:1a.0-usb-0:1.1:1.0-scsi-0:0:0:0
ID_PATH_TAG=pci-0000_00_1a_0-usb-0_1_1_1_0-scsi-0_0_0_0
ID_REVISION=1.00
ID_SERIAL=Generic_USB_SD_Reader_12345678901234567890-0:0
ID_SERIAL_SHORT=12345678901234567890
ID_TYPE=disk
ID_USB_DRIVER=usb-storage
ID_USB_INTERFACES=:080650:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=Generic
ID_VENDOR_ENC=Generic\x20
ID_VENDOR_ID=090c
MAJOR=8
MINOR=17
SUBSYSTEM=block
TAGS=:systemd:
UDISKS_PARTITION=1
UDISKS_PARTITION_ALIGNMENT_OFFSET=0
UDISKS_PARTITION_NUMBER=1
UDISKS_PARTITION_OFFSET=32256
UDISKS_PARTITION_SCHEME=mbr
UDISKS_PARTITION_SIZE=8031011328
UDISKS_PARTITION_SLAVE=/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/host8/target8:0:0/8:0:0:0/block/sdb
UDISKS_PARTITION_TYPE=0x87
UDISKS_PRESENTATION_NOPOLICY=0
USEC_INITIALIZED=7735553

It seems that 100-usb.rules doesn't be executed~
Am I anywhere wrong ?

Last edited by Hacksign (2013-04-09 02:15:13)

Offline

#2 2013-04-08 13:45:30

brebs
Member
Registered: 2007-04-03
Posts: 3,406

Re: [SOLVED]udev doesn't execute my custom rule

You're mixing the hierarchy levels (i.e. subsystems) - can't do that. See working example.

Offline

#3 2013-04-08 15:00:39

Hacksign
Member
Registered: 2012-07-30
Posts: 68

Re: [SOLVED]udev doesn't execute my custom rule

brebs wrote:

You're mixing the hierarchy levels (i.e. subsystems) - can't do that. See working example.

no, I dont think I mixed te hierarchy level.
SUBSYSTEM=="input" matched '/devices/platform/i8042/serio1/serio2/input/input24/mouse2'
and
SUBSYSTEMS=="usb", ATTR{idVendor}=="1532",
matched its parent
....
and I'm so sorry that I pasted a wrong device tree...
sorry sad

Offline

#4 2013-04-08 16:39:51

Hacksign
Member
Registered: 2012-07-30
Posts: 68

Re: [SOLVED]udev doesn't execute my custom rule

Pasted another example of my usb sd card reader.
there is no test_X symbol link in /dev/ directory after i un-pluged sd card reader and re-pluged it in on my computer sad

oh, I use systemd of course:

XSign rules.d # cat /boot/grub/menu.lst

# (0) Arch Linux
title  Arch Linux
root   (hd0,0)
kernel /boot/vmlinuz26 root=/dev/disk/by-label/root resume=/dev/sda7 ro vga=0x361 init=/usr/lib/systemd/systemd quiet
initrd /boot/kernel26.img
Hacksign wrote:
brebs wrote:

You're mixing the hierarchy levels (i.e. subsystems) - can't do that. See working example.

no, I dont think I mixed te hierarchy level.
SUBSYSTEM=="input" matched '/devices/platform/i8042/serio1/serio2/input/input24/mouse2'
and
SUBSYSTEMS=="usb", ATTR{idVendor}=="1532",
matched its parent
....
and I'm so sorry that I pasted a wrong device tree...
sorry sad

Offline

#5 2013-04-08 22:49:00

brebs
Member
Registered: 2007-04-03
Posts: 3,406

Re: [SOLVED]udev doesn't execute my custom rule

Look closely:

ATTRS{model}=="USB  SD Reader  "

There's TWO spaces between USB and SD wink

Offline

#6 2013-04-09 02:14:52

Hacksign
Member
Registered: 2012-07-30
Posts: 68

Re: [SOLVED]udev doesn't execute my custom rule

Ok ,  bitten by the space char wink
thx~

brebs wrote:

Look closely:

ATTRS{model}=="USB  SD Reader  "

There's TWO spaces between USB and SD wink

Offline

Board footer

Powered by FluxBB