X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fswap.c;h=8e494e9b5a194f2f84a43d3567afae05a4e0e68f;hb=44b601bc79e46722bc0f0862ee0ce34a2284ef11;hp=82bfad187e43bb6bd5e0fe84177e69bd27c4228d;hpb=9fb3675e7ef0c6b7a1780980e51492c44fd1faaf;p=elogind.git diff --git a/src/core/swap.c b/src/core/swap.c index 82bfad187..8e494e9b5 100644 --- a/src/core/swap.c +++ b/src/core/swap.c @@ -66,7 +66,7 @@ static void swap_unset_proc_swaps(Swap *s) { * same kernel swap device. */ swaps = UNIT(s)->manager->swaps_by_proc_swaps; first = hashmap_get(swaps, s->parameters_proc_swaps.what); - LIST_REMOVE(Swap, same_proc_swaps, first, s); + LIST_REMOVE(same_proc_swaps, first, s); if (first) hashmap_remove_and_replace(swaps, @@ -137,42 +137,6 @@ static void swap_done(Unit *u) { unit_unwatch_timer(u, &s->timer_watch); } -int swap_add_one_mount_link(Swap *s, Mount *m) { - int r; - - assert(s); - assert(m); - - if (UNIT(s)->load_state != UNIT_LOADED || - UNIT(m)->load_state != UNIT_LOADED) - return 0; - - if (is_device_path(s->what)) - return 0; - - if (!path_startswith(s->what, m->where)) - return 0; - - r = unit_add_two_dependencies(UNIT(s), UNIT_AFTER, UNIT_REQUIRES, UNIT(m), true); - if (r < 0) - return r; - - return 0; -} - -static int swap_add_mount_links(Swap *s) { - Unit *other; - int r; - - assert(s); - - LIST_FOREACH(units_by_type, other, UNIT(s)->manager->units_by_type[UNIT_MOUNT]) - if ((r = swap_add_one_mount_link(s, MOUNT(other))) < 0) - return r; - - return 0; -} - static int swap_add_device_links(Swap *s) { SwapParameters *p; @@ -300,11 +264,11 @@ static int swap_load(Unit *u) { if ((r = unit_set_description(u, s->what)) < 0) return r; - r = swap_add_device_links(s); + r = unit_require_mounts_for(UNIT(s), s->what); if (r < 0) return r; - r = swap_add_mount_links(s); + r = swap_add_device_links(s); if (r < 0) return r; @@ -400,7 +364,7 @@ static int swap_add_one( p->what = wp; first = hashmap_get(m->swaps_by_proc_swaps, wp); - LIST_PREPEND(Swap, same_proc_swaps, first, SWAP(u)); + LIST_PREPEND(same_proc_swaps, first, SWAP(u)); r = hashmap_replace(m->swaps_by_proc_swaps, wp, first); if (r < 0) @@ -625,7 +589,7 @@ static int swap_spawn(Swap *s, ExecCommand *c, pid_t *_pid) { true, true, UNIT(s)->manager->confirm_spawn, - UNIT(s)->cgroup_mask, + UNIT(s)->manager->cgroup_supported, UNIT(s)->cgroup_path, UNIT(s)->id, NULL,