All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aras Vaichas <arasv@magtech.com.au>
To: linux-hotplug@vger.kernel.org
Subject: ENV variable scope question
Date: Thu, 21 Aug 2008 01:37:33 +0000	[thread overview]
Message-ID: <48ACC6DD.4070705@magtech.com.au> (raw)

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 
______________________________________________________________________

             reply	other threads:[~2008-08-21  1:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-21  1:37 Aras Vaichas [this message]
2008-08-21  5:30 ` ENV variable scope question 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48ACC6DD.4070705@magtech.com.au \
    --to=arasv@magtech.com.au \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.