swap: create .wants symlink to 'auto' swap devices

As we load unit files lazily, we need to make sure something pulls in swap
units that should be started automatically, otherwise the default dependencies
will never be applied.

This partially reinstates code removed in
commit 64347fc2b9.

Also don't order swap devices after swap.target when they are 'nofail'.
This commit is contained in:
Tom Gundersen
2013-09-16 01:11:52 +02:00
parent a5c724b25b
commit 4e82fe5213
2 changed files with 22 additions and 4 deletions
+6 -2
View File
@@ -220,8 +220,12 @@ static int swap_add_default_dependencies(Swap *s) {
}
if (!noauto) {
r = unit_add_two_dependencies_by_name_inverse(UNIT(s), UNIT_AFTER, (nofail ? UNIT_WANTS : UNIT_REQUIRES),
SPECIAL_SWAP_TARGET, NULL, true);
if (nofail)
r = unit_add_dependency_by_name_inverse(UNIT(s),
UNIT_WANTS, SPECIAL_SWAP_TARGET, NULL, true);
else
r = unit_add_two_dependencies_by_name_inverse(UNIT(s),
UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SWAP_TARGET, NULL, true);
if (r < 0)
return r;
}