linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* ENV variable scope question
@ 2008-08-21  1:37 Aras Vaichas
  2008-08-21  5:30 ` Aras Vaichas
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Aras Vaichas @ 2008-08-21  1:37 UTC (permalink / raw)
  To: linux-hotplug

Hi, I'm looking to unload a userspace driver when a particular device is
removed.

My load rule is this:

ACTION="add",SUBSYSTEM="usb_endpoint",ATTR{device/manufacturer}="Crystalfontz",
RUN+="/usr/bin/sv up lcdd"

Now the problem was that when I disconnect the device there is no longer
a "device/manufacturer" file, so I added an environment variable
LCDD_DEVICE to the rule:

ACTION="add",SUBSYSTEM="usb_endpoint",ATTR{device/manufacturer}="Crystalfontz",
ENV{LCDD_DEVICE}="%k", RUN+="/usr/bin/sv up lcdd"

I had hoped to be able to match this LCDD_DEVICE variable when the
kernel name appeared in the remove event. So I tried:

ACTION="remove", ENV{LCDD_DEVICE}="%k", RUN+="... remove the driver ..."

But this rule never triggered.

I put in a debug line, and disconnected the device:

ACTION="remove", RUN+="/bin/sh -c 'logger B %k = $env{LCDD_DEVICE}'"

Jan  1 00:41:21 user.notice root: B usbdev1.23_ep81 Jan  1 00:41:21 user.notice root: B usbdev1.23_ep02 Jan  1 00:41:21 user.notice root: B usbdev1.23_ep00 = usbdev1.23_ep00
<--- !!!
Jan  1 00:41:21 user.notice root: B ttyUSB1 Jan  1 00:41:21 user.notice root: B ttyUSB1 Jan  1 00:41:21 user.notice root: B 1-1:1.0 Jan  1 00:41:21 user.notice root: B 1-1 
So there is a situation where %k  was equal to LCDD_DEVICE, but
regardless the rule didn't trigger. Did I get the syntax wrong?

Also, it appears that the scope of the environment variable LCDD_DEVICE
only occurs when the actual device has caused the uevent. OK.

So should I make my remove rule like this?

ACTION="remove", ENV{LCDD_DEVICE}!="", RUN+="... remove the driver ..."

Aras

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-08-22  3:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-21  1:37 ENV variable scope question Aras Vaichas
2008-08-21  5:30 ` Aras Vaichas
2008-08-21  5:33 ` FW:Re: " Sujit Karataparambil
2008-08-21  5:47 ` Aras Vaichas
2008-08-21  6:31 ` FW:Re: " Kay Sievers
2008-08-21  6:45 ` Kay Sievers
2008-08-21  7:17 ` Aras Vaichas
2008-08-21  7:57 ` Kay Sievers
2008-08-22  3:44 ` Aras Vaichas

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).