summaryrefslogtreecommitdiff
path: root/src/swap.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-08-25 20:37:04 +0200
committerLennart Poettering <lennart@poettering.net>2010-08-25 20:37:04 +0200
commit173a8d04fc3535b571fe4a0d4715c18be315a43a (patch)
treebe5461d41c7037158ffa708b814076f99945b5fe /src/swap.c
parent9d2205426a54e4eeab18bd7d83bc2fbb43eca4a4 (diff)
mount: rework automatic mounting to follow the 'nofail' option in fstab
Diffstat (limited to 'src/swap.c')
-rw-r--r--src/swap.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/swap.c b/src/swap.c
index 4a672fbdff..69ccd3db6c 100644
--- a/src/swap.c
+++ b/src/swap.c
@@ -113,13 +113,33 @@ static int swap_add_target_links(Swap *s) {
if ((r = manager_load_unit(s->meta.manager, SPECIAL_SWAP_TARGET, NULL, NULL, &tu)) < 0)
return r;
- if (!p->noauto && p->handle && s->meta.manager->running_as == MANAGER_SYSTEM)
+ if (!p->noauto && (p->handle || s->meta.manager->swap_auto) && s->meta.manager->running_as == MANAGER_SYSTEM)
if ((r = unit_add_dependency(tu, UNIT_WANTS, UNIT(s), true)) < 0)
return r;
return unit_add_dependency(UNIT(s), UNIT_BEFORE, tu, true);
}
+static int swap_add_device_links(Swap *s) {
+ SwapParameters *p;
+
+ assert(s);
+
+ if (!s->what)
+ return 0;
+
+ if (s->from_fragment)
+ p = &s->parameters_fragment;
+ else if (s->from_etc_fstab)
+ p = &s->parameters_etc_fstab;
+ else
+ return 0;
+
+ return unit_add_node_link(UNIT(s), s->what,
+ !p->noauto && p->nofail &&
+ s->meta.manager->running_as == MANAGER_SYSTEM);
+}
+
static int swap_add_default_dependencies(Swap *s) {
int r;
@@ -195,9 +215,8 @@ static int swap_load(Unit *u) {
if ((r = unit_set_description(u, s->what)) < 0)
return r;
- if ((r = unit_add_node_link(u, s->what,
- u->meta.manager->running_as == MANAGER_SYSTEM &&
- u->meta.manager->swap_on_plug)) < 0)
+
+ if ((r = swap_add_device_links(s)) < 0)
return r;
if ((r = swap_add_mount_links(s)) < 0)
@@ -262,6 +281,7 @@ int swap_add_one(
const char *what,
int priority,
bool noauto,
+ bool nofail,
bool handle,
bool from_proc_swaps) {
Unit *u = NULL;
@@ -311,6 +331,7 @@ int swap_add_one(
p->priority = priority;
p->noauto = noauto;
+ p->nofail = nofail;
p->handle = handle;
if (delete)
@@ -385,6 +406,7 @@ static void swap_dump(Unit *u, FILE *f, const char *prefix) {
"%sWhat: %s\n"
"%sPriority: %i\n"
"%sNoAuto: %s\n"
+ "%sNoFail: %s\n"
"%sHandle: %s\n"
"%sFrom /etc/fstab: %s\n"
"%sFrom /proc/swaps: %s\n"
@@ -393,6 +415,7 @@ static void swap_dump(Unit *u, FILE *f, const char *prefix) {
prefix, s->what,
prefix, p->priority,
prefix, yes_no(p->noauto),
+ prefix, yes_no(p->nofail),
prefix, yes_no(p->handle),
prefix, yes_no(s->from_etc_fstab),
prefix, yes_no(s->from_proc_swaps),
@@ -525,7 +548,7 @@ static int swap_load_proc_swaps(Manager *m) {
if (!d)
return -ENOMEM;
- k = swap_add_one(m, d, prio, false, false, true);
+ k = swap_add_one(m, d, prio, false, false, false, true);
free(d);
if (k < 0)