chiark / gitweb /
add mount enumerator
[elogind.git] / device.c
index 22b0f6085ecbd753ed91f43f85250d1a98630528..6d7e2c6fa3d51654c391c2b99ab89b79a764b60c 100644 (file)
--- a/device.c
+++ b/device.c
@@ -33,7 +33,7 @@ static void device_dump(Unit *u, FILE *f, const char *prefix) {
                 prefix, d->sysfs);
 }
 
                 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;
 
         char *e;
         int r;
 
@@ -41,10 +41,14 @@ static int device_add_escaped_name(Unit *u, const char *dn) {
         assert(dn);
         assert(dn[0] == '/');
 
         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);
                 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)
         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] == '/');
                 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))) {
                 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 (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)
                         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) {
                         goto fail;
 
         if (names) {