prefix, d->sysfs);
}
-static int device_add_escaped_name(Unit *u, const char *dn) {
+static int device_add_escaped_name(Unit *u, const char *prefix, const char *dn, bool make_id) {
char *e;
int r;
assert(dn);
assert(dn[0] == '/');
- if (!(e = unit_name_escape_path(dn+1, ".device")))
+ if (!(e = unit_name_escape_path(prefix, dn+1, ".device")))
return -ENOMEM;
r = unit_add_name(u, e);
+
+ if (r >= 0 && make_id)
+ unit_choose_id(u, e);
+
free(e);
if (r < 0 && r != -EEXIST)
return -ENOMEM;
assert(sysfs[0] == '/');
- if (!(e = unit_name_escape_path(sysfs+1, ".device")))
+ if (!(e = unit_name_escape_path("sysfs-", sysfs+1, ".device")))
return -ENOMEM;
if (!(u = manager_get_unit(m, e))) {
}
if (dn)
- if ((r = device_add_escaped_name(u, dn)) < 0)
+ if ((r = device_add_escaped_name(u, "node-", dn, true)) < 0)
goto fail;
first = udev_device_get_devlinks_list_entry(dev);
udev_list_entry_foreach(item, first)
- if ((r = device_add_escaped_name(u, udev_list_entry_get_name(item))) < 0)
+ if ((r = device_add_escaped_name(u, "node-", udev_list_entry_get_name(item), false)) < 0)
goto fail;
if (names) {