* Does RUN work with "remove" events?
@ 2005-11-30 22:14 Moshe Yudkowsky
2005-11-30 23:21 ` Kay Sievers
2005-12-01 4:19 ` Moshe Yudkowsky
0 siblings, 2 replies; 3+ messages in thread
From: Moshe Yudkowsky @ 2005-11-30 22:14 UTC (permalink / raw)
To: linux-hotplug
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:
> 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"
> 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.
> run_program: '/etc/hotplug/usb/ums' 'block'
and
> 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":
> 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
> SEQNUM\x1255
and I can see from udevmonitor:
> UDEV [1133386804.167444] remove@/devices/pci0000:00/0000:00:10.3/usb4/4-2
and I get events from udev such as
> 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_id\x16865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Does RUN work with "remove" events?
2005-11-30 22:14 Does RUN work with "remove" events? Moshe Yudkowsky
@ 2005-11-30 23:21 ` Kay Sievers
2005-12-01 4:19 ` Moshe Yudkowsky
1 sibling, 0 replies; 3+ messages in thread
From: Kay Sievers @ 2005-11-30 23:21 UTC (permalink / raw)
To: linux-hotplug
On Wed, Nov 30, 2005 at 04:14:45PM -0600, Moshe Yudkowsky wrote:
> 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_id\x16865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Does RUN work with "remove" events?
2005-11-30 22:14 Does RUN work with "remove" events? Moshe Yudkowsky
2005-11-30 23:21 ` Kay Sievers
@ 2005-12-01 4:19 ` Moshe Yudkowsky
1 sibling, 0 replies; 3+ messages in thread
From: Moshe Yudkowsky @ 2005-12-01 4:19 UTC (permalink / raw)
To: linux-hotplug
Kay Sievers wrote:
> On Wed, Nov 30, 2005 at 04:14:45PM -0600, Moshe Yudkowsky wrote:
>
>> 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,
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.
--
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_id\x16865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-12-01 4:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-30 22:14 Does RUN work with "remove" events? Moshe Yudkowsky
2005-11-30 23:21 ` Kay Sievers
2005-12-01 4:19 ` Moshe Yudkowsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).