char *unit_name_mangle(const char *name) {
char *r, *t;
const char *f;
- bool dot = false;
assert(name);
/* Try to turn a string that might not be a unit name into a
* sensible unit name. */
- if (path_startswith(name, "/dev/") ||
- path_startswith(name, "/sys/"))
+ if (is_device_path(name))
return unit_name_from_path(name, ".device");
if (path_is_absolute(name))
return NULL;
for (f = name, t = r; *f; f++) {
-
- if (*f == '.')
- dot = true;
-
if (*f == '/')
*(t++) = '-';
else if (!strchr("@" VALID_CHARS, *f))
*(t++) = *f;
}
- if (!dot)
+ if (unit_name_to_type(name) < 0)
strcpy(t, ".service");
else
*t = 0;