* ENV{DEVNAME} in remove rule?
@ 2007-07-03 17:16 Richard Michael
2007-07-03 17:45 ` Andrey Borzenkov
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Richard Michael @ 2007-07-03 17:16 UTC (permalink / raw)
To: linux-hotplug
Hello,
I'm learning my way around udev, and have written these rules to add a
device:
KERNEL="sd*[!0-9]", ENV{ID_SERIAL}="", IMPORT{program}="/lib/udev/usb_id -x"
KERNEL="sd*[!0-9]", ENV{ID_TYPE}="?*", IMPORT{program}="/lib/udev/path_id %p"
KERNEL="sd*[!0-9]", ENV{ID_PATH}="*usb-0:6:1.0*", NAME="storage/raid-$env{ID_BUS}-%M-%m"
I want to run a command when it is removed, so I've written these rules:
(The first rule is a catch-all where I do "set >> /tmp/debug" to see
what's available in the environment..)
SUBSYSTEM="*", RUN+="/root/udev-catch-remove"
ENV{DEVNAME}="/dev/storage/raid-*", RUN+="/root/raid_management"
When the device is disconnected, "udevmonitor --env" shows me:
(DEVNAME appears just as I hoped..)
UDEV [1183481937.246643] remove /block/sdc (block)
UDEV_LOG=7
ACTION=remove
DEVPATH=/block/sdc
SUBSYSTEM=block
SEQNUM\x1266
MINOR2
MAJOR=8
PHYSDEVPATH=/devices/pci0000:00/0000:00:0b.1/usb2/2-6/2-6:1.0/host15/target15:0:0/15:0:0:0
PHYSDEVBUS=scsi
PHYSDEVDRIVER=sd
UDEVD_EVENT=1
ID_VENDOR=Maxtor_6
ID_MODELà40L0
ID_REVISION\b11
ID_SERIAL=Maxtor_6_E040L0
ID_TYPE=disk
ID_BUS=usb
ID_PATH=pci-0000:00:0b.1-usb-0:6:1.0-scsi-0:0:0:0
DEVLINKS=/dev/disk/by-id/usb-Maxtor_6_E040L0 /dev/disk/by-path/pci-0000:00:0b.1-usb-0:6:1.0-scsi-0:0:0:0
DEVNAME=/dev/storage/raid-usb-8-32
But, my command /root/raid_management is never run, as if udev isn't
matching ENV{DEVNAME}.
What have I misunderstood?
This is on Fedora 7 machine, using (slightly old) udev 106.
("rpm -q udev" = udev-106-4.fc7)
Thanks,
Richard
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
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] 6+ messages in thread
* Re: ENV{DEVNAME} in remove rule?
2007-07-03 17:16 ENV{DEVNAME} in remove rule? Richard Michael
@ 2007-07-03 17:45 ` Andrey Borzenkov
2007-07-03 17:52 ` Richard Michael
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Andrey Borzenkov @ 2007-07-03 17:45 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1.1: Type: text/plain, Size: 460 bytes --]
On Tuesday 03 July 2007, Richard Michael wrote:
>
> But, my command /root/raid_management is never run, as if udev isn't
> matching ENV{DEVNAME}.
>
> What have I misunderstood?
>
DEVNAME is set by udev before calling RUN programs. It is not available when
rules are being processed.
In general I am not sure it is wise to match on DEVNAME It can be changed at
any time by installing different rule(s). Better to match on device
properties.
[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 286 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
[-- Attachment #3: Type: text/plain, Size: 226 bytes --]
_______________________________________________
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] 6+ messages in thread
* Re: ENV{DEVNAME} in remove rule?
2007-07-03 17:16 ENV{DEVNAME} in remove rule? Richard Michael
2007-07-03 17:45 ` Andrey Borzenkov
@ 2007-07-03 17:52 ` Richard Michael
2007-07-03 18:06 ` Andrey Borzenkov
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Richard Michael @ 2007-07-03 17:52 UTC (permalink / raw)
To: linux-hotplug
> DEVNAME is set by udev before calling RUN programs. It is not available when
> rules are being processed.
Where are these details documented? I've been writing lots of test
rules to try and figure this out, but I'd prefer to just read something.
> In general I am not sure it is wise to match on DEVNAME It can be changed at
> any time by installing different rule(s). Better to match on device
> properties.
I'd really prefer to match PHYSDEVPATH, because what I actually care
about is identifying the USB socket which the device is attached
(especially for the "add" rule.. the "remove" just uses the device name
as I set it when it was added). However, PHYSDEVPATH has been
deprecated.
I want to create block devices (not symlinks) for the specific ports of
a USB (or firewire) controller, and take actions depending on which
socket of the controller has been used.
Thanks,
Richard
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
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] 6+ messages in thread
* Re: ENV{DEVNAME} in remove rule?
2007-07-03 17:16 ENV{DEVNAME} in remove rule? Richard Michael
2007-07-03 17:45 ` Andrey Borzenkov
2007-07-03 17:52 ` Richard Michael
@ 2007-07-03 18:06 ` Andrey Borzenkov
2007-07-03 18:17 ` Richard Michael
2007-07-03 19:44 ` Andrey Borzenkov
4 siblings, 0 replies; 6+ messages in thread
From: Andrey Borzenkov @ 2007-07-03 18:06 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1.1: Type: text/plain, Size: 742 bytes --]
On Tuesday 03 July 2007, Richard Michael wrote:
> > DEVNAME is set by udev before calling RUN programs. It is not available
> > when rules are being processed.
>
> Where are these details documented?
source code?
> I've been writing lots of test
> rules to try and figure this out, but I'd prefer to just read something.
>
patches to manual pages are welcome :)
>
> I want to create block devices (not symlinks) for the specific ports of
> a USB (or firewire) controller, and take actions depending on which
> socket of the controller has been used.
>
What's wrong with using ID_PATH? It also has advantage of being more stable
than PHYSDEVPATH (which includes volatile details like running SCSI host
number).
[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 286 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
[-- Attachment #3: Type: text/plain, Size: 226 bytes --]
_______________________________________________
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] 6+ messages in thread
* Re: ENV{DEVNAME} in remove rule?
2007-07-03 17:16 ENV{DEVNAME} in remove rule? Richard Michael
` (2 preceding siblings ...)
2007-07-03 18:06 ` Andrey Borzenkov
@ 2007-07-03 18:17 ` Richard Michael
2007-07-03 19:44 ` Andrey Borzenkov
4 siblings, 0 replies; 6+ messages in thread
From: Richard Michael @ 2007-07-03 18:17 UTC (permalink / raw)
To: linux-hotplug
On Tue, Jul 03, 2007 at 10:06:08PM +0400, Andrey Borzenkov wrote:
> On Tuesday 03 July 2007, Richard Michael wrote:
> > > DEVNAME is set by udev before calling RUN programs. It is not available
> > > when rules are being processed.
> >
> > Where are these details documented?
>
> source code?
I thought so. I think udev is great, it just needs slightly more helpful
documentation to make is really user accessible. There are quite a few
"things to know" (such as the default PATH, which took awhile to
realize I was overlooking..).
> > I've been writing lots of test
> > rules to try and figure this out, but I'd prefer to just read something.
> >
>
> patches to manual pages are welcome :)
I was thinking about changes to the How To Write UDev Rules document..
> What's wrong with using ID_PATH? It also has advantage of being more stable
> than PHYSDEVPATH (which includes volatile details like running SCSI host
> number).
Yes, I noticed the target number changes even when the hardware remains
identical.
I thought I had a problem running path_id/usb_id to set those environment
variables (I don't remember which one sets them..), because the sysfs
entry was already gone. I think I misunderstood, maybe the variables
are set from when the device was created? .. I'll look into again. I'm
probably just confused, it's been a bit of mess building some
understanding.. :)
Thanks,
Richard
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
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] 6+ messages in thread
* Re: ENV{DEVNAME} in remove rule?
2007-07-03 17:16 ENV{DEVNAME} in remove rule? Richard Michael
` (3 preceding siblings ...)
2007-07-03 18:17 ` Richard Michael
@ 2007-07-03 19:44 ` Andrey Borzenkov
4 siblings, 0 replies; 6+ messages in thread
From: Andrey Borzenkov @ 2007-07-03 19:44 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1.1: Type: text/plain, Size: 720 bytes --]
On Tuesday 03 July 2007, Richard Michael wrote:
> I thought I had a problem running path_id/usb_id to set those environment
> variables (I don't remember which one sets them..), because the sysfs
> entry was already gone. I think I misunderstood, maybe the variables
> are set from when the device was created?
Yes. You have to import them (unless already done) on "add" event; those
values are stored in udev database and added to environment *before* rules
are being processed on "remove" event. At least that is the theory :)
You also can explicitly assign any environment variable on "add" and it should
be available as well on "remove". This allows you to mark any specific device
if you like.
[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 286 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
[-- Attachment #3: Type: text/plain, Size: 226 bytes --]
_______________________________________________
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] 6+ messages in thread
end of thread, other threads:[~2007-07-03 19:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-03 17:16 ENV{DEVNAME} in remove rule? Richard Michael
2007-07-03 17:45 ` Andrey Borzenkov
2007-07-03 17:52 ` Richard Michael
2007-07-03 18:06 ` Andrey Borzenkov
2007-07-03 18:17 ` Richard Michael
2007-07-03 19:44 ` Andrey Borzenkov
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).