c = strndupa(cgroup, n);
c = cg_unescape(c);
- if (!unit_name_is_valid(c, TEMPLATE_INVALID))
+ if (!unit_name_is_valid(c, UNIT_NAME_PLAIN|UNIT_NAME_INSTANCE))
return -ENXIO;
s = strdup(c);
c = cg_unescape(buf);
- return unit_name_is_valid(c, TEMPLATE_INVALID);
+ return unit_name_is_valid(c, UNIT_NAME_PLAIN);
}
return false;
int cg_slice_to_path(const char *unit, char **ret) {
_cleanup_free_ char *p = NULL, *s = NULL, *e = NULL;
const char *dash;
+ int r;
assert(unit);
assert(ret);
return 0;
}
- if (!unit_name_is_valid(unit, TEMPLATE_INVALID))
+ if (!unit_name_is_valid(unit, UNIT_NAME_PLAIN))
return -EINVAL;
if (!endswith(unit, ".slice"))
return -EINVAL;
- p = unit_name_to_prefix(unit);
- if (!p)
- return -ENOMEM;
+ r = unit_name_to_prefix(unit, &p);
+ if (r < 0)
+ return r;
dash = strchr(p, '-');
while (dash) {
return -EINVAL;
strcpy(stpncpy(n, p, dash - p), ".slice");
- if (!unit_name_is_valid(n, TEMPLATE_INVALID))
+ if (!unit_name_is_valid(n, UNIT_NAME_PLAIN))
return -EINVAL;
escaped = cg_escape(n);