chiark / gitweb /
path,timer: order units after sysinit by default
authorLennart Poettering <lennart@poettering.net>
Fri, 16 Jul 2010 16:57:21 +0000 (18:57 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 16 Jul 2010 16:57:21 +0000 (18:57 +0200)
fixme
src/path.c
src/timer.c

diff --git a/fixme b/fixme
index c98ffec..a3c9950 100644 (file)
--- a/fixme
+++ b/fixme
@@ -47,8 +47,6 @@
 
 * default.target must be %ghosted...
 
-* systemd.path muss irgendwie nen sinvolles Defaultdependencies=True kriegen, genaus timer usw.
-
 * In command lines, support both "$FOO" and $FOO
 
 * systemd-install disable should recursively kill all symlinks
index 2ae6e56..a9fa377 100644 (file)
@@ -101,6 +101,18 @@ static int path_verify(Path *p) {
         return 0;
 }
 
+static int path_add_default_dependencies(Path *p) {
+        int r;
+
+        assert(p);
+
+        if (p->meta.manager->running_as == MANAGER_SYSTEM)
+                if ((r = unit_add_two_dependencies_by_name(UNIT(p), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, NULL, true)) < 0)
+                        return r;
+
+        return unit_add_two_dependencies_by_name(UNIT(p), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true);
+}
+
 static int path_load(Unit *u) {
         Path *p = PATH(u);
         int r;
@@ -123,9 +135,8 @@ static int path_load(Unit *u) {
                 if ((r = path_add_mount_links(p)) < 0)
                         return r;
 
-                /* Path units shouldn't stay around on shutdown */
                 if (p->meta.default_dependencies)
-                        if ((r = unit_add_two_dependencies_by_name(u, UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true)) < 0)
+                        if ((r = path_add_default_dependencies(p)) < 0)
                                 return r;
         }
 
index 0d4ed27..1580478 100644 (file)
@@ -73,6 +73,18 @@ static int timer_verify(Timer *t) {
         return 0;
 }
 
+static int timer_add_default_dependencies(Timer *t) {
+        int r;
+
+        assert(t);
+
+        if (t->meta.manager->running_as == MANAGER_SYSTEM)
+                if ((r = unit_add_two_dependencies_by_name(UNIT(t), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, NULL, true)) < 0)
+                        return r;
+
+        return unit_add_two_dependencies_by_name(UNIT(t), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true);
+}
+
 static int timer_load(Unit *u) {
         Timer *t = TIMER(u);
         int r;
@@ -92,9 +104,8 @@ static int timer_load(Unit *u) {
                 if ((r = unit_add_dependency(u, UNIT_BEFORE, t->unit, true)) < 0)
                         return r;
 
-                /* Timers shouldn't stay around on shutdown */
                 if (t->meta.default_dependencies)
-                        if ((r = unit_add_two_dependencies_by_name(u, UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true)) < 0)
+                        if ((r = timer_add_default_dependencies(t)) < 0)
                                 return r;
         }