5

I have two rules one for when a device, my phone, is connected and one for when it is disconnected. The rule for add runs the remove rule does not. Here is my udev rule. I simplified but the remove event does not run.

#RUNS:
KERNEL=="sd?1", ATTRS{idVendor}=="0bb4", ATTRS{idProduct}=="0ff9", SYMLINK+="phone", ACTION=="add", RUN+="/usr/bin/touch /tmp/udev.add"
#DOES NOT RUN:
KERNEL=="sd?1", ATTRS{idVendor}=="0bb4", ATTRS{idProduct}=="0ff9", SYMLINK+="phone", ACTION=="remove", RUN+="/usr/bin/touch /tmp/udev.remove"

Why would one run but not the other?

Andrew Redd
  • 2,157

1 Answers1

6

You will need to refactor your removal rule as outlined here: http://www.linuxquestions.org/questions/linux-desktop-74/udev-not-doing-remove-rules-841733/

Summarizing the link content, it appears that once a device is removed, some of its attributes are not readable anymore so you will have to monitor the device removal and focus on the attributes that are dumped with udevadm monitor --environment --udev.

Also, creating a symlink during removal is plain wrong.

aquaherd
  • 6,220
  • 2
    Silly copy and paste errors. That was it. It t should also note that the filtering is on environment variables with ENV{VAR}== instead of the ATTRS{VAR}== and the command above is how you can get the environment variables to filter on. Thank you. – Andrew Redd Oct 13 '11 at 15:38