X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fswap.c;h=0d3cb2f40622c608865313ff23876f5139bc5c17;hb=550c4dcc4184d5c4d55d3786b66797e5fb99c30a;hp=ddda9e1a3104d5b6143c9b89aabaf2bb72c5fa71;hpb=ead8e4788ee31bbdc38b4cd3c6e71c8a95bbc95a;p=elogind.git diff --git a/src/swap.c b/src/swap.c index ddda9e1a3..0d3cb2f40 100644 --- a/src/swap.c +++ b/src/swap.c @@ -199,9 +199,15 @@ static int swap_add_device_links(Swap *s) { else return 0; - return unit_add_node_link(UNIT(s), s->what, - !p->noauto && p->nofail && - s->meta.manager->running_as == MANAGER_SYSTEM); + if (is_device_path(s->what)) + return unit_add_node_link(UNIT(s), s->what, + !p->noauto && p->nofail && + s->meta.manager->running_as == MANAGER_SYSTEM); + else + /* File based swap devices need to be ordered after + * remount-rootfs.service, since they might need a + * writable file system. */ + return unit_add_dependency_by_name(UNIT(s), UNIT_AFTER, SPECIAL_REMOUNT_ROOTFS_SERVICE, NULL, true); } static int swap_add_default_dependencies(Swap *s) { @@ -289,7 +295,7 @@ static int swap_load(Unit *u) { if ((r = swap_add_target_links(s)) < 0) return r; - if ((r = unit_add_default_cgroup(u)) < 0) + if ((r = unit_add_default_cgroups(u)) < 0) return r; if (s->meta.default_dependencies) @@ -1162,6 +1168,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); @@ -1319,6 +1358,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