[systemd-devel] udev rules environment variable
Robert Milasan
rmilasan at suse.com
Tue Dec 17 03:44:14 PST 2013
On Tue, 17 Dec 2013 11:52:15 +0100
"Kay Sievers" <kay at vrfy.org> wrote:
> On Tue, Dec 17, 2013 at 8:56 AM, Hannes Reinecke <hare at suse.de> wrote:
> > On 12/17/2013 08:52 AM, Robert Milasan wrote:
> >> Hello,
> >> got a small question about creating a rule, like this:
> >>
> >> ACTION=="add", ...., ENV{test_device}="1"
> >>
> >> ACTION=="remove, ...., ENV{test_device}=="1",
> >> RUN+="/path/to/some/script"
> >>
> >> Does udev save test_device variable someplace and then it can be
> >> used later on, when have ACTION=="remove" ?
>
> > Typically not.
>
> There is a standard REMOVE_CMD in 95-udev-late.rules to use for this
>
> All variables are stored in the database and are contained in the
> "remove" event, without the need to be added or queried. Sysfs though
> is not available, all of it is gone at "remove".
>
> > I would be using external tools for that, like 'collect'
>
> That is needed to sync stuff across multiple devices, not for a single
> one, right?
>
> > Might be biased, though, what with me having written it ...
> >
> > And the alternative of querying the udev database from within an
> > udev event is just plain ugly and prone to races.
>
> That happens automatically, it's just part of the "remove"
> environment.
>
> Kay
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
I have this rule as a test, but doesn't do squat (meaning it doesnt
work) :)
ACTION=="add", SUBSYSTEM=="net", KERNEL=="?*", ENV{test_device}="1"
ACTION=="remove", SUBSYSTEM=="net", KERNEL=="?*", ENV{test_device}=="1", RUN+="/bin/sh -c 'echo test_device > /tmp/test_device.log'"
--
Robert Milasan
L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmilasan at suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402 6FE7 2F64 167C 1909 6D1A
More information about the systemd-devel
mailing list