Does RUN work with "remove" events?
I've written a udev rule to add a UMS flash drive with device name /dev/ums:
SYSFS{product}="Flash Disk", NAME="ums", RUN+="/etc/hotplug/usb/ums"
I've used "product" in the hope that the rule will be more general, and I won't have to change it for each new USB flash drive.
I selected "Flash Drive based on the following stansa that I saw in udevinfo:
Quoted 15 lines
looking at the device chain at '/sys/devices/pci0000:00/0000:00:10.3/usb4/4-2':
BUS="usb" ID="4-2" DRIVER="usb" SYSFS{bConfigurationValue}="1" SYSFS{bDeviceClass}="00" SYSFS{bDeviceProtocol}="00" SYSFS{bDeviceSubClass}="00" SYSFS{bMaxPower}="200mA" SYSFS{bNumConfigurations}="1" SYSFS{bNumInterfaces}=" 1" SYSFS{bcdDevice}="0200" SYSFS{bmAttributes}="80" SYSFS{configuration}="" SYSFS{devnum}="18"
Quoted 9 lines
SYSFS{idProduct}="2168"
SYSFS{idVendor}="0ea0"
SYSFS{manufacturer}="USB "
SYSFS{maxchild}="0"
SYSFS{product}="Flash Disk "
SYSFS{serial}="255A07F4403C2C06"
SYSFS{speed}="480"
SYSFS{version}=" 2.00"When I plug in the flash drive, I get the expected result: the RUN script runs (as well as the scsi_generic script), and I get a /dev/ums device.
Quoted 1 line
run_program: '/etc/hotplug/usb/ums' 'block'
and
Quoted 1 line
run_program'/etc/hotplug/usb/ums' 'scsi_generic'
as well because I used RUN+= instead of RUN=.
The problem is on remove. The file /dev/hotplug.log shows that I in fact do get a hotplug event of "remove":
Quoted 9 lines
HOTPLUG_TIME='Wed Nov 30 15:40:04 CST 2005'
SUBSYSTEM=usb
OLDPWD=/
DEVPATH=/devices/pci0000:00/0000:00:10.3/usb4/4-2
ACTION=remove
UDEV_LOG=3
UDEVD_EVENT=1
PHYSDEVBUS=usb
SEQNUM55
and I can see from udevmonitor:
Quoted 1 line
UDEV [1133386804.167444] remove@/devices/pci0000:00/0000:00:10.3/usb4/4-2
and I get events from udev such as
Quoted 1 line
udev_event_run: seq 1277 forked, pid [4221], 'remove' 'scsi_generic', 0 seconds old
But the script in RUN never runs -- and I can see this in the udev output log, which I won't attach here.
So, here's the questions:
(a) Is udev supposed to work this way?
(b) If it is supposed to work this way, what's the recommended method to get RUN to work on ACTIONs of "remove"?
(c) If it isn't supposed to work this way, does anyone have any debugging suggestions or ideas of what to try next?
Regards,
Moshe Yudkowsky
(work) http://www.Disaggregate.com
(book) http://www.PebbleAndAvalanche.com
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 3 lines · Moshe Yudkowsky
I've written a udev rule to add a UMS flash drive with device name
/dev/ums:SYSFS{product}="Flash Disk", NAME="ums", RUN+="/etc/hotplug/usb/ums"
Sysfs values are not readable at remove, cause the device directory is already gone. You need to match against properties which you can see in udevmonitor --env or you need to store a custom key with ENV{key}="value" in the database, which is imported on remove.
Kay
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 3 lines · Kay Sievers
Quoted 1 line · Moshe Yudkowsky
I've written a udev rule to add a UMS flash drive with device name
/dev/ums:
Quoted 9 lines
Quoted 2 lines
SYSFS{product}="Flash Disk", NAME="ums", RUN+="/etc/hotplug/usb/ums"
Sysfs values are not readable at remove, cause the device directory is already gone. You need to match against properties which you can see in udevmonitor --env or you need to store a custom key with ENV{key}="value" in the database, which is imported on remove.
Kay,
Thank you very much. I suspected that something of the sort was happening; but I wasn't aware that custom keys for ENV were possible. (It's not on the man page.)
Here's my fix. I've created the following rules:
ACTION="add", SYSFS{product}="Flash Disk", NAME="ums", RUN+="/etc/hotplug/usb/ums", ENV{flashdrive}="%p"
ACTION="remove", ENV{flashdrive}="%p", RUN+="/etc/hotplug/usb/ums"
The first rule sets, on an "add," the custom environment variable "flashdrive" to the value of DEVPATH (%p). The 2nd rule checks, on a "remove," to see if the devpath that's being removed is the one for the flash drive -- if so, the designated script runs.
Signature · 14 lines
Moshe Yudkowsky work: http://www.Disaggregate.com book: http://www.PebbleAndAvalanche.com ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_idv37&alloc_id865&op=click _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net [email protected] https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel