chiark / gitweb /
downgrade a few log msgs
[elogind.git] / unit.c
diff --git a/unit.c b/unit.c
index dea6b8bf7641dc6747ff42efd00bf45e34edf52a..fd6723f4ce77796f8439f9291e4280d33aca9d7a 100644 (file)
--- a/unit.c
+++ b/unit.c
@@ -713,7 +713,7 @@ fail:
         u->meta.load_state = UNIT_FAILED;
         unit_add_to_dbus_queue(u);
 
-        log_error("Failed to load configuration for %s: %s", u->meta.id, strerror(-r));
+        log_debug("Failed to load configuration for %s: %s", u->meta.id, strerror(-r));
 
         return r;
 }
@@ -1831,6 +1831,42 @@ int unit_deserialize(Unit *u, FILE *f, FDSet *fds) {
         }
 }
 
+int unit_add_node_link(Unit *u, const char *what, bool wants) {
+        Unit *device;
+        char *e;
+        int r;
+
+        assert(u);
+
+        if (!what)
+                return 0;
+
+        /* Adds in links to the device node that this unit is based on */
+
+        if (!path_startswith(what, "/dev/") && !path_startswith(what, "/sys/"))
+                return 0;
+
+        if (!(e = unit_name_build_escape(what+1, NULL, ".device")))
+                return -ENOMEM;
+
+        r = manager_load_unit(u->meta.manager, e, NULL, &device);
+        free(e);
+
+        if (r < 0)
+                return r;
+
+        if ((r = unit_add_dependency(u, UNIT_AFTER, device, true)) < 0)
+                return r;
+
+        if ((r = unit_add_dependency(u, UNIT_REQUIRES, device, true)) < 0)
+                return r;
+
+        if (wants)
+                if ((r = unit_add_dependency(device, UNIT_WANTS, u, false)) < 0)
+                        return r;
+
+        return 0;
+}
 
 static const char* const unit_type_table[_UNIT_TYPE_MAX] = {
         [UNIT_SERVICE] = "service",