linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Moshe Yudkowsky <msha5_17@bl.com>
To: linux-hotplug@vger.kernel.org
Subject: Re: Does RUN work with "remove" events?
Date: Thu, 01 Dec 2005 04:19:40 +0000	[thread overview]
Message-ID: <438E79DC.1090208@bl.com> (raw)
In-Reply-To: <438E2455.5090702@bl.com>

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

      parent reply	other threads:[~2005-12-01  4:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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=438E79DC.1090208@bl.com \
    --to=msha5_17@bl.com \
    --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 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).