[systemd-devel] udev rules environment variable

Kay Sievers kay at vrfy.org
Tue Dec 17 08:36:21 PST 2013


On Tue, Dec 17, 2013 at 2:05 PM, Robert Milasan <rmilasan at suse.com> wrote:
> On Tue, 17 Dec 2013 13:54:34 +0100
> "Martin Pitt" <martin.pitt at ubuntu.com> wrote:
>
>> Robert Milasan [2013-12-17 12:44 +0100]:
>> > 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'"
>>
>> Drop the KERNEL== bits. Network devices don't have a /dev/... device
>> node in Linux, so KERNEL will never be set for those.

KERNEL is the device name in /sys, without the leading path. It is in
almost all cases also the name in /dev, but there are some
differences. And right, it is always set, there is never a point to do
such a match.

> Even without the KERNEL== doesn't seem to work:

It's pointless to match that, so it should not make a difference.

> I'm testing this by first removing the network device (ex. rmmod
> e1000), so I can have first an ADD event and then a REMOVE event, by
> removing again the module, so:
>
> rmmod e1000 (remove first)
> modprobe e1000 (ADD event, set the test_device var to 1)
> rmmod e1000 (REMOVE event, get the test_device value)
>
> This doesn't seem to work, or at least it looks like that.

How old is your udev? You are not possibly talking about years old
versions, right?

Kay


More information about the systemd-devel mailing list