[systemd-devel] Requiring hardware device and escaping device names
David Schmitt
david at dasz.at
Wed Mar 26 08:22:22 PDT 2014
On 2014-03-26 14:50, Kai Hendry wrote:
> Thanks Michael for answering, :)
>
> On 26 March 2014 18:59, Michael Biebl <mbiebl at gmail.com> wrote:
>> 2014-03-26 3:56 GMT+01:00 Kai Hendry <hendry at webconverger.com>:
>> If your daemon is not functional if the hardware is not present, I'd
>> probably start it via a udev rule and SYSTEMD_WANTS.
>
> Do you have an example for this please?
>
> I don't quite understand why I can't I just name the device in the
> service file. Why does it have to be so confusing. Still don't
> understand the need for escaping... is there a need?
While Jóhann has answered the technical part of your question, I'd like
to address the quoting part: in the various configuration locations you
were talking about earlier, quoting of filenames is required as these
config directives can take a wide range of arguments that can reference
many other things beside devices. Since those units are all defined in
files, whose names are the unit name, all those names have to be valid
file names. So a unit can also "Requires=foo.service", which will be
defined in a file called foo.service.
The specifics are described in
http://www.freedesktop.org/software/systemd/man/systemd.unit.html:
> Some unit names reflect paths existing in the file system namespace.
> Example: a device unit
> dev-sda.device refers to a device with the device node /dev/sda in
> the file system namespace.
> If this applies, a special way to escape the path name is used, so
> that the result is usable
> as part of a filename. Basically, given a path, "/" is replaced by
> "-", and all unprintable
> characters and the "-" are replaced by C-style "\x20" escapes. The
> root directory "/" is
> encoded as single dash, while otherwise the initial and ending "/" is
> removed from all
> paths during transformation. This escaping is reversible.
Regards, David
More information about the systemd-devel
mailing list