swap: handle nofail/noauto in core

This commit is contained in:
Tom Gundersen
2013-09-11 14:43:24 +02:00
parent 88ac30a197
commit 64347fc2b9
2 changed files with 18 additions and 56 deletions
+15
View File
@@ -197,6 +197,7 @@ static int swap_add_device_links(Swap *s) {
}
static int swap_add_default_dependencies(Swap *s) {
bool nofail = false, noauto = false;
int r;
assert(s);
@@ -211,6 +212,20 @@ static int swap_add_default_dependencies(Swap *s) {
if (r < 0)
return r;
if (s->from_fragment) {
SwapParameters *p = &s->parameters_fragment;
nofail = p->nofail;
noauto = p->noauto;
}
if (!noauto) {
r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_BEFORE, (nofail ? UNIT_WANTED_BY : UNIT_REQUIRED_BY),
SPECIAL_SWAP_TARGET, NULL, true);
if (r < 0)
return r;
}
return 0;
}