chiark / gitweb /
add new unit_add_dependency_by_name() call
[elogind.git] / unit.c
diff --git a/unit.c b/unit.c
index e8d61c853c51529c3fb2b9c4f0917b833632bd73..a5f4ac76767d1c412db7d166b7d62a3559d860d3 100644 (file)
--- a/unit.c
+++ b/unit.c
@@ -243,7 +243,8 @@ static int ensure_merge(Set **s, Set *other) {
         return 0;
 }
 
-/* FIXME: Does not rollback on failure! */
+/* FIXME: Does not rollback on failure! Needs to fix special unit
+ * pointers. Needs to merge names and dependencies properly.*/
 int unit_merge(Unit *u, Unit *other) {
         int r;
         UnitDependency d;
@@ -371,7 +372,7 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) {
 
 /* Common implementation for multiple backends */
 int unit_load_fragment_and_dropin(Unit *u) {
-        int r;
+        int r, ret;
 
         assert(u);
 
@@ -379,11 +380,13 @@ int unit_load_fragment_and_dropin(Unit *u) {
         if ((r = unit_load_fragment(u)) < 0)
                 return r;
 
+        ret = r > 0;
+
         /* Load drop-in directory data */
         if ((r = unit_load_dropin(u)) < 0)
                 return r;
 
-        return 0;
+        return ret;
 }
 
 int unit_load(Unit *u) {
@@ -833,6 +836,19 @@ int unit_add_dependency(Unit *u, UnitDependency d, Unit *other) {
         return 0;
 }
 
+int unit_add_dependency_by_name(Unit *u, UnitDependency d, const char *name) {
+        Unit *other;
+        int r;
+
+        if ((r = manager_load_unit(u->meta.manager, name, &other)) < 0)
+                return r;
+
+        if ((r = unit_add_dependency(u, d, other)) < 0)
+                return r;
+
+        return 0;
+}
+
 const char *unit_path(void) {
         char *e;