chiark / gitweb /
dbus: small typo in introspection data
[elogind.git] / src / device.c
index 46b3ed3dff8166f447125b63fc22e675f4d77e51..7323192a7176ddaa0fa46fd5181725904a79ea6c 100644 (file)
@@ -1,4 +1,4 @@
-/*-*- Mode: C; c-basic-offset: 8 -*-*/
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
 
 /***
   This file is part of systemd.
@@ -190,12 +190,12 @@ static int device_update_unit(Manager *m, struct udev_device *dev, const char *p
 
         /* If this is a different unit, then let's not merge things */
         if (u && DEVICE(u)->sysfs && !path_equal(DEVICE(u)->sysfs, sysfs)) {
-                log_error("Hmm, something's broken. Asked to create two devices with same name but different sysfs paths.");
+                log_error("Hmm, something's broken. Asked to create two devices with same name but different sysfs paths. (%s vs %s)",
+                          DEVICE(u)->sysfs, sysfs);
                 return -EEXIST;
         }
 
         if (!u) {
-                Device *first;
                 delete = true;
 
                 if (!(u = unit_new(m)))
@@ -204,13 +204,22 @@ static int device_update_unit(Manager *m, struct udev_device *dev, const char *p
                 if ((r = device_add_escaped_name(u, path)) < 0)
                         goto fail;
 
+                unit_add_to_load_queue(u);
+        } else
+                delete = false;
+
+        /* If this was created via some dependency and has not
+         * actually been seen yet ->sysfs will not be
+         * initialized. Hence initialize it if necessary. */
+
+        if (!DEVICE(u)->sysfs) {
+                Device *first;
+
                 if (!(DEVICE(u)->sysfs = strdup(sysfs))) {
                         r = -ENOMEM;
                         goto fail;
                 }
 
-                unit_add_to_load_queue(u);
-
                 if (!m->devices_by_sysfs)
                         if (!(m->devices_by_sysfs = hashmap_new(string_hash_func, string_compare_func))) {
                                 r = -ENOMEM;
@@ -222,9 +231,7 @@ static int device_update_unit(Manager *m, struct udev_device *dev, const char *p
 
                 if ((r = hashmap_replace(m->devices_by_sysfs, DEVICE(u)->sysfs, first)) < 0)
                         goto fail;
-
-        } else
-                delete = false;
+        }
 
         if ((model = udev_device_get_property_value(dev, "ID_MODEL_FROM_DATABASE")) ||
             (model = udev_device_get_property_value(dev, "ID_MODEL"))) {