[systemd-devel] [RFC][PATCH] Escape unit name from udev

MUNEDA Takahiro muneda.takahiro at jp.fujitsu.com
Thu May 9 09:37:20 PDT 2013


On Mon, 6 May 2013 23:18:33 +0200,
Kay Sievers <kay at vrfy.org> wrote:

> On Mon, May 6, 2013 at 11:12 PM, Lennart Poettering
> <lennart at poettering.net> wrote:
>> On Tue, 23.04.13 13:34, MUNEDA Takahiro (muneda.takahiro at jp.fujitsu.com) wrote:
>>
>>> This patch escapes a unit name which was derived from udev.
>>>
>>> Please imagine following udev rule.
>>>
>>>    ACTION=="online|offline", TAG+="systemd", ENV{SYSTEMD_WANTS}="muneda@%p.service"
>>>    ACTION=="online|offline", TAG+="systemd", ENV{SYSTEMD_WANTS}="muneda@%r.service"
>>>    ACTION=="online|offline", TAG+="systemd", ENV{SYSTEMD_WANTS}="muneda@%S.service"
>>>
>>> When unit name is derived from udev via
>>> udev_device_get_property_value(), the name may contains '/' if
>>> ENV{SYSTEMD_WANTS} has the udev options $devpath(%p), $root(%r), or
>>> $sys(%S).  However, '/' is a invalid char for unit name so processing
>>> of this rule fails as Invalid argument with following message.
>>>
>>> Apr 22 13:21:37 localhost systemd[1]: Failed to load device unit: Invalid argument
>>> Apr 22 13:21:37 localhost systemd[1]: Failed to process udev device event: Invalid argument
>>>
>>> This patch escapes those invalid chars in a unit name.
>>> Tested with 202, and confirmed to apply cleanly on top of commit 195f8e36.
>>
>> The patch looks OK I guess. I merged it now. I am not entirely sure
>> though that using the devpath as instance name is actually the best
>> choice... Kay?

Thank you.

> Some devices can move around during runtime, the device number (dev_t,
> ifindex) or the "<subsytem>:<devname>" is usually the better choice. A
> bit like this:
>    http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/base/core.c#n1918

Thank you for your suggestion.
I may get necessary information from those.  Will check it.

Thanks,
Takahiro


More information about the systemd-devel mailing list