chiark / gitweb /
mount: add automatic start ordering dependencies for mounts
[elogind.git] / src / swap.c
index 9203514..de468a0 100644 (file)
@@ -120,6 +120,24 @@ static int swap_add_target_links(Swap *s) {
         return unit_add_dependency(UNIT(s), UNIT_BEFORE, tu, true);
 }
 
+static int swap_add_default_dependencies(Swap *s) {
+        int r;
+
+        assert(s);
+
+        if (s->meta.manager->running_as == MANAGER_SYSTEM) {
+
+                if ((r = unit_add_dependency_by_name(UNIT(s), UNIT_AFTER, SPECIAL_SYSINIT_TARGET, NULL, true)) < 0)
+                        return r;
+
+                /* Note that by default we don't disable swap devices
+                 * on shutdown. i.e. there is no umount.target
+                 * conflicts here. */
+        }
+
+        return 0;
+}
+
 static int swap_verify(Swap *s) {
         bool b;
         char *e;
@@ -185,6 +203,10 @@ static int swap_load(Unit *u) {
 
                 if ((r = swap_add_target_links(s)) < 0)
                         return r;
+
+                if (s->meta.default_dependencies)
+                        if ((r = swap_add_default_dependencies(s)) < 0)
+                                return r;
         }
 
         return swap_verify(s);