Re: ENV variable scope question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>>> On Thu, Aug 21, 2008 at 03:37, Aras Vaichas <arasv@xxxxxxxxxxxxxx> wrote:
>>>> Hi, I'm looking to unload a userspace driver when a particular
>>>> device is removed.

Here are my (hopefully) final rules.  I have to load/unload on the
usb_device because the ttyUSB[0-9]
device doesn't get disconnected if an application still has the dev file
open.

ACTION=="add", ENV{DEVTYPE}=="usb_device",
ATTRS{manufacturer}=="Crystalfontz", ENV{REMOVE_CMD}="/usr/bin/sv down
lcdd", RUN+="/usr/bin/sv up lcdd"
ACTION=="add", KERNEL=="ttyUSB[0-9]",
ATTRS{manufacturer}=="Crystalfontz", SYMLINK+="lcd"

These rules will:
* load the LCDproc daemon when a supported USB LCD device is plugged in
* create a symbolic link so that the the lcdd configuration file will
always point to the correct ttyUSB*
* facilitate the shutdown of the demon which releases the ttyUSB* device
and frees it for further use

It will fail though if two of the same device are plugged in but that
would be an unusual situation for my embedded product and I can live
with that.


> It's per device, stored in the udev database. You can look at it
> with: /sbin/udevadm info --query=all --name=ttyUSB0 or watch it while
> add/remove a device: /sbin/udevadm monitor --udev --env

udevadm info --query=all --name=ttyUSB0 --attribute-walk

This is also very helpful, and would have saved me some time, but I
didn't know that this is what I really wanted all along. :P

I think my next rule set will be a lot easier and faster now that I
better understand what it is that I am supposed to be looking for.

Thanks for all the help and tips.

Aras

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
--
To unsubscribe from this list: send the line "unsubscribe linux-hotplug" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel]     [Linux DVB]     [Asterisk Internet PBX]     [DCCP]     [Netdev]     [X.org]     [Util Linux NG]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux