[systemd-devel] udev rules environment variable
Kay Sievers
kay at vrfy.org
Tue Dec 17 02:52:15 PST 2013
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
More information about the systemd-devel
mailing list