chiark / gitweb /
build: expose libcryptsetup dependency in build string
[elogind.git] / src / swap.c
index f7f9530a03963daf34df4c5cb1bcdb4f1e012335..ec9f157b156f7bb2e2d33dd46174d31e3759327d 100644 (file)
@@ -176,7 +176,7 @@ static int swap_add_target_links(Swap *s) {
 
         if (!p->noauto &&
             (p->handle || s->meta.manager->swap_auto) &&
-            !s->from_fragment &&
+            s->from_etc_fstab &&
             s->meta.manager->running_as == MANAGER_SYSTEM)
                 if ((r = unit_add_dependency(tu, UNIT_WANTS, UNIT(s), true)) < 0)
                         return r;
@@ -211,10 +211,7 @@ static int swap_add_default_dependencies(Swap *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;
-
-                if ((r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_BEFORE, UNIT_CONFLICTED_BY, SPECIAL_UMOUNT_TARGET, NULL, true)) < 0)
+                if ((r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true)) < 0)
                         return r;
         }
 
@@ -283,7 +280,6 @@ static int swap_load(Unit *u) {
                         if ((r = unit_set_description(u, s->what)) < 0)
                                 return r;
 
-
                 if ((r = swap_add_device_links(s)) < 0)
                         return r;
 
@@ -293,6 +289,9 @@ static int swap_load(Unit *u) {
                 if ((r = swap_add_target_links(s)) < 0)
                         return r;
 
+                if ((r = unit_add_default_cgroups(u)) < 0)
+                        return r;
+
                 if (s->meta.default_dependencies)
                         if ((r = swap_add_default_dependencies(s)) < 0)
                                 return r;
@@ -1163,6 +1162,39 @@ static Unit *swap_following(Unit *u) {
         return UNIT(first);
 }
 
+static int swap_following_set(Unit *u, Set **_set) {
+        Swap *s = SWAP(u);
+        Swap *other;
+        Set *set;
+        int r;
+
+        assert(s);
+        assert(_set);
+
+        if (LIST_JUST_US(same_proc_swaps, s)) {
+                *_set = NULL;
+                return 0;
+        }
+
+        if (!(set = set_new(NULL, NULL)))
+                return -ENOMEM;
+
+        LIST_FOREACH_AFTER(same_proc_swaps, other, s)
+                if ((r = set_put(set, other)) < 0)
+                        goto fail;
+
+        LIST_FOREACH_BEFORE(same_proc_swaps, other, s)
+                if ((r = set_put(set, other)) < 0)
+                        goto fail;
+
+        *_set = set;
+        return 1;
+
+fail:
+        set_free(set);
+        return r;
+}
+
 static void swap_shutdown(Manager *m) {
         assert(m);
 
@@ -1320,6 +1352,7 @@ const UnitVTable swap_vtable = {
         .bus_invalidating_properties =  bus_swap_invalidating_properties,
 
         .following = swap_following,
+        .following_set = swap_following_set,
 
         .enumerate = swap_enumerate,
         .shutdown = swap_shutdown