[systemd-devel] [udev] Limitation of capturing remove events?

Tom Yan tom.ty89 at gmail.com
Mon Aug 31 20:32:33 PDT 2015


Is it a limitation or bug that I can only capture remove events with
purely SUBSYSTEM or KENREL match, but not with ATTR{*} or even DRIVER?

I unplugged and re-plugged the specific device once before each `cat test`:

[tom at localhost ~]$ cat /etc/udev/rules.d/usb.rules
KERNEL=="1-14", RUN+="/usr/bin/bash -c 'echo $DEVPATH $ACTION >>
/home/tom/test'"
[tom at localhost ~]$ sudo systemctl restart systemd-udevd systemd-udev-trigger
[tom at localhost ~]$ cat test
/devices/pci0000:00/0000:00:14.0/usb1/1-14 add
/devices/pci0000:00/0000:00:14.0/usb1/1-14 remove
/devices/pci0000:00/0000:00:14.0/usb1/1-14 add
[tom at localhost ~]$ sudo rm test

[tom at localhost ~]$ cat /etc/udev/rules.d/usb.rules
SUBSYSTEM=="usb", ATTR{busnum}=="1", ATTR{devpath}=="14",
RUN+="/usr/bin/bash -c 'echo $DEVPATH $ACTION >> /home/tom/test'"
[tom at localhost ~]$ sudo systemctl restart systemd-udevd systemd-udev-trigger
[tom at localhost ~]$ cat test
/devices/pci0000:00/0000:00:14.0/usb1/1-14 add
/devices/pci0000:00/0000:00:14.0/usb1/1-14 add
[tom at localhost ~]$ sudo rm test

[tom at localhost ~]$ cat /etc/udev/rules.d/usb.rules
SUBSYSTEM=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c52e",
RUN+="/usr/bin/bash -c 'echo $DEVPATH $ACTION >> /home/tom/test'"
[tom at localhost ~]$ sudo systemctl restart systemd-udevd systemd-udev-trigger
[tom at localhost ~]$ cat test
/devices/pci0000:00/0000:00:14.0/usb1/1-14 add
/devices/pci0000:00/0000:00:14.0/usb1/1-14 add
[tom at localhost ~]$ sudo rm test

[tom at localhost ~]$ cat /etc/udev/rules.d/usb.rules
KERNEL=="2-6", RUN+="/usr/bin/bash -c 'echo $DEVPATH $ACTION >> /home/tom/test'"
[tom at localhost ~]$ sudo systemctl restart systemd-udevd systemd-udev-trigger
[tom at localhost ~]$ cat test
/devices/pci0000:00/0000:00:14.0/usb2/2-6 add
/devices/pci0000:00/0000:00:14.0/usb2/2-6 remove
/devices/pci0000:00/0000:00:14.0/usb2/2-6 add
[tom at localhost ~]$ sudo rm test

[tom at localhost ~]$ cat /etc/udev/rules.d/usb.rules
ATTR{serial}=="AA011214140810091125", RUN+="/usr/bin/bash -c 'echo
$DEVPATH $ACTION >> /home/tom/test'"
[tom at localhost ~]$ sudo systemctl restart systemd-udevd systemd-udev-trigger
[tom at localhost ~]$ cat test
/devices/pci0000:00/0000:00:14.0/usb2/2-6 add
/devices/pci0000:00/0000:00:14.0/usb2/2-6 add
[tom at localhost ~]$ sudo rm test

[tom at localhost ~]$ cat /etc/udev/rules.d/usb.rules
SUBSYSTEM=="usb", RUN+="/usr/bin/bash -c 'echo $DEVPATH $ACTION >>
/home/tom/test'"
[tom at localhost ~]$ sudo systemctl restart systemd-udevd systemd-udev-trigger
[tom at localhost ~]$ cat test
/devices/pci0000:00/0000:00:14.0/usb1 add
/devices/pci0000:00/0000:00:14.0/usb2 add
/devices/pci0000:00/0000:00:14.0/usb2/2-6 add
/devices/pci0000:00/0000:00:14.0/usb2/2-1 add
/devices/pci0000:00/0000:00:14.0/usb2/2-0:1.0 add
/devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0 add
/devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.0 add
/devices/pci0000:00/0000:00:14.0/usb1/1-0:1.0 add
/devices/pci0000:00/0000:00:1a.0/usb3 add
/devices/pci0000:00/0000:00:14.0/usb1/1-14 add
/devices/pci0000:00/0000:00:1d.0/usb4 add
/devices/pci0000:00/0000:00:1d.0/usb4/4-0:1.0 add
/devices/pci0000:00/0000:00:1a.0/usb3/3-0:1.0 add
/devices/pci0000:00/0000:00:1d.0/usb4/4-1 add
/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1:1.0 add
/devices/pci0000:00/0000:00:1a.0/usb3/3-1 add
/devices/pci0000:00/0000:00:14.0/usb1/1-14/1-14:1.1 add
/devices/pci0000:00/0000:00:14.0/usb1/1-14/1-14:1.0 add
/devices/pci0000:00/0000:00:1a.0/usb3/3-1/3-1:1.0 add
/devices/pci0000:00/0000:00:14.0/usb1/1-14/1-14:1.0 remove
/devices/pci0000:00/0000:00:14.0/usb1/1-14/1-14:1.1 remove
/devices/pci0000:00/0000:00:14.0/usb1/1-14 remove
/devices/pci0000:00/0000:00:14.0/usb1/1-14 add
/devices/pci0000:00/0000:00:14.0/usb1/1-14/1-14:1.0 add
/devices/pci0000:00/0000:00:14.0/usb1/1-14/1-14:1.1 add
/devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.0 remove
/devices/pci0000:00/0000:00:14.0/usb2/2-6 remove
/devices/pci0000:00/0000:00:14.0/usb2/2-6 add
/devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.0 add
[tom at localhost ~]$ sudo rm test

[tom at localhost ~]$ cat /etc/udev/rules.d/usb.rules
DRIVER=="usb", RUN+="/usr/bin/bash -c 'echo $DEVPATH $ACTION >> /home/tom/test'"
[tom at localhost ~]$ sudo systemctl restart systemd-udevd systemd-udev-trigger
[tom at localhost ~]$ cat test
/devices/pci0000:00/0000:00:14.0/usb1 add
/devices/pci0000:00/0000:00:14.0/usb2 add
/devices/pci0000:00/0000:00:14.0/usb2/2-6 add
/devices/pci0000:00/0000:00:1a.0/usb3 add
/devices/pci0000:00/0000:00:14.0/usb2/2-1 add
/devices/pci0000:00/0000:00:14.0/usb1/1-14 add
/devices/pci0000:00/0000:00:1a.0/usb3/3-1 add
/devices/pci0000:00/0000:00:1d.0/usb4 add
/devices/pci0000:00/0000:00:1d.0/usb4/4-1 add
/devices/pci0000:00/0000:00:14.0/usb1/1-14 add
/devices/pci0000:00/0000:00:14.0/usb2/2-6 add

Attached are the outputs of `udevadm info -a` on the two devices used
in the trials.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: info_1_14
Type: application/octet-stream
Size: 2988 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150901/28458dfc/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: info_2_6
Type: application/octet-stream
Size: 3008 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150901/28458dfc/attachment-0003.obj>


More information about the systemd-devel mailing list