summaryrefslogtreecommitdiff
path: root/device.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-01-29 02:07:41 +0100
committerLennart Poettering <lennart@poettering.net>2010-01-29 02:07:41 +0100
commitb08d03ffe58332f590aae5c78a85e4fc0b8588ce (patch)
tree909fb7436bdd7496761bdcb8c3d13fa989aca584 /device.c
parent0ae97ec11506cce808232abd0979e20aed2fd625 (diff)
add mount enumerator
Diffstat (limited to 'device.c')
-rw-r--r--device.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/device.c b/device.c
index 22b0f6085e..6d7e2c6fa3 100644
--- a/device.c
+++ b/device.c
@@ -33,7 +33,7 @@ static void device_dump(Unit *u, FILE *f, const char *prefix) {
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;
@@ -41,10 +41,14 @@ static int device_add_escaped_name(Unit *u, const char *dn) {
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)
@@ -79,7 +83,7 @@ static int device_process_device(Manager *m, struct udev_device *dev) {
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))) {
@@ -116,12 +120,12 @@ static int device_process_device(Manager *m, struct udev_device *dev) {
}
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) {