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

Tom Yan tom.ty89 at gmail.com
Mon Aug 31 20:53:13 PDT 2015


Also attach a log of `udevadm monitor` for your reference.

On 1 September 2015 at 11:32, Tom Yan <tom.ty89 at gmail.com> wrote:
> 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: monitor_log
Type: application/octet-stream
Size: 10969 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150901/f75b7bd5/attachment.obj>


More information about the systemd-devel mailing list