summaryrefslogtreecommitdiff
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
parent9d2205426a54e4eeab18bd7d83bc2fbb43eca4a4 (diff)
mount: rework automatic mounting to follow the 'nofail' option in fstab
-rw-r--r--fixme4
-rw-r--r--src/dbus-manager.c6
-rw-r--r--src/main.c9
-rw-r--r--src/manager.h4
-rw-r--r--src/mount.c32
-rw-r--r--src/swap.c33
-rw-r--r--src/swap.h3
-rw-r--r--src/system.conf3
8 files changed, 65 insertions, 29 deletions
diff --git a/fixme b/fixme
index 4ee7815b1a..52b8110681 100644
--- a/fixme
+++ b/fixme
@@ -76,7 +76,7 @@
* add RefuseManualIsolate= (default on?)
-* nofail
+* fstab nofail
* add systemctl switch to dump transaction without executing it
@@ -84,8 +84,6 @@
* system.conf/session.conf brauch ne man page
-* sd-daemon ohne SCM_CREDENTIALS bitte
-
* exec /sbin/poweroff als PID 1 und shutdown
External:
diff --git a/src/dbus-manager.c b/src/dbus-manager.c
index 557124712a..9b0a600221 100644
--- a/src/dbus-manager.c
+++ b/src/dbus-manager.c
@@ -141,9 +141,8 @@
" <property name=\"SysVRcndPath\" type=\"as\" access=\"read\"/>\n" \
" <property name=\"NotifySocket\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"ControlGroupHierarchy\" type=\"s\" access=\"read\"/>\n" \
- " <property name=\"MountOnPlug\" type=\"b\" access=\"read\"/>\n" \
- " <property name=\"SwapOnPlug\" type=\"b\" access=\"read\"/>\n" \
" <property name=\"MountAuto\" type=\"b\" access=\"read\"/>\n" \
+ " <property name=\"SwapAuto\" type=\"b\" access=\"read\"/>\n" \
" </interface>\n"
#define INTROSPECTION_BEGIN \
@@ -255,9 +254,8 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
{ "org.freedesktop.systemd1.Manager", "SysVRcndPath", bus_property_append_strv, "as", m->lookup_paths.sysvrcnd_path },
{ "org.freedesktop.systemd1.Manager", "NotifySocket", bus_property_append_string, "s", m->notify_socket },
{ "org.freedesktop.systemd1.Manager", "ControlGroupHierarchy", bus_property_append_string, "s", m->cgroup_hierarchy },
- { "org.freedesktop.systemd1.Manager", "MountOnPlug", bus_property_append_bool, "b", &m->mount_on_plug },
- { "org.freedesktop.systemd1.Manager", "SwapOnPlug", bus_property_append_bool, "b", &m->swap_on_plug },
{ "org.freedesktop.systemd1.Manager", "MountAuto", bus_property_append_bool, "b", &m->mount_auto },
+ { "org.freedesktop.systemd1.Manager", "SwapAuto", bus_property_append_bool, "b", &m->swap_auto },
{ NULL, NULL, NULL, NULL, NULL }
};
diff --git a/src/main.c b/src/main.c
index 54fc0540ac..f1fa569112 100644
--- a/src/main.c
+++ b/src/main.c
@@ -64,9 +64,8 @@ static int arg_crash_chvt = -1;
static bool arg_confirm_spawn = false;
static bool arg_show_status = true;
static bool arg_sysv_console = true;
-static bool arg_mount_on_plug = true;
-static bool arg_swap_on_plug = true;
static bool arg_mount_auto = true;
+static bool arg_swap_auto = true;
static FILE* serialization = NULL;
@@ -485,9 +484,8 @@ static int parse_config_file(void) {
{ "SysVConsole", config_parse_bool, &arg_sysv_console, "Manager" },
{ "CrashChVT", config_parse_int, &arg_crash_chvt, "Manager" },
{ "CPUAffinity", config_parse_cpu_affinity, NULL, "Manager" },
- { "MountOnPlug", config_parse_bool, &arg_mount_on_plug, "Manager" },
- { "SwapOnPlug", config_parse_bool, &arg_swap_on_plug, "Manager" },
{ "MountAuto", config_parse_bool, &arg_mount_auto, "Manager" },
+ { "SwapAuto", config_parse_bool, &arg_swap_auto, "Manager" },
{ NULL, NULL, NULL, NULL }
};
@@ -992,9 +990,8 @@ int main(int argc, char *argv[]) {
m->confirm_spawn = arg_confirm_spawn;
m->show_status = arg_show_status;
m->sysv_console = arg_sysv_console;
- m->mount_on_plug = arg_mount_on_plug;
- m->swap_on_plug = arg_swap_on_plug;
m->mount_auto = arg_mount_auto;
+ m->swap_auto = arg_swap_auto;
if ((r = manager_startup(m, serialization, fds)) < 0)
log_error("Failed to fully start up daemon: %s", strerror(-r));
diff --git a/src/manager.h b/src/manager.h
index dd48593d4c..e3c6db23bd 100644
--- a/src/manager.h
+++ b/src/manager.h
@@ -201,10 +201,8 @@ struct Manager {
bool show_status;
bool confirm_spawn;
bool sysv_console;
-
- bool mount_on_plug;
- bool swap_on_plug;
bool mount_auto;
+ bool swap_auto;
int n_deserializing;
};
diff --git a/src/mount.c b/src/mount.c
index b49443ced1..08d5de28d7 100644
--- a/src/mount.c
+++ b/src/mount.c
@@ -275,6 +275,30 @@ static int mount_add_target_links(Mount *m) {
}
}
+static int mount_add_device_links(Mount *m) {
+ MountParameters *p;
+ bool nofail, noauto;
+
+ assert(m);
+
+ if (m->from_fragment)
+ p = &m->parameters_fragment;
+ else if (m->from_etc_fstab)
+ p = &m->parameters_etc_fstab;
+ else
+ return 0;
+
+ if (!p->what || path_equal(m->where, "/"))
+ return 0;
+
+ noauto = !!mount_test_option(p->options, MNTOPT_NOAUTO);
+ nofail = !!mount_test_option(p->options, "nofail");
+
+ return unit_add_node_link(UNIT(m), p->what,
+ !noauto && nofail &&
+ UNIT(m)->meta.manager->running_as == MANAGER_SYSTEM);
+}
+
static int mount_add_default_dependencies(Mount *m) {
int r;
@@ -362,11 +386,8 @@ static int mount_load(Unit *u) {
else if (m->from_proc_self_mountinfo && m->parameters_proc_self_mountinfo.what)
what = m->parameters_proc_self_mountinfo.what;
- if (what && !path_equal(m->where, "/"))
- if ((r = unit_add_node_link(u, what,
- u->meta.manager->running_as == MANAGER_SYSTEM &&
- u->meta.manager->mount_on_plug)) < 0)
- return r;
+ if ((r = mount_add_device_links(m)) < 0)
+ return r;
if ((r = mount_add_mount_links(m)) < 0)
return r;
@@ -1289,6 +1310,7 @@ static int mount_load_etc_fstab(Manager *m) {
what,
pri,
!!mount_test_option(me->mnt_opts, MNTOPT_NOAUTO),
+ !!mount_test_option(me->mnt_opts, "nofail"),
!!mount_test_option(me->mnt_opts, "comment=systemd.swapon"),
false);
} else
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)
diff --git a/src/swap.h b/src/swap.h
index 3c53536a83..a180708ac8 100644
--- a/src/swap.h
+++ b/src/swap.h
@@ -39,6 +39,7 @@ typedef struct SwapParameters {
char *what;
int priority;
bool noauto:1;
+ bool nofail:1;
bool handle:1;
} SwapParameters;
@@ -60,7 +61,7 @@ struct Swap {
extern const UnitVTable swap_vtable;
-int swap_add_one(Manager *m, const char *what, int prio, bool no_auto, bool handle, bool from_proc_swap);
+int swap_add_one(Manager *m, const char *what, int prio, bool no_auto, bool no_fail, bool handle, bool from_proc_swap);
int swap_add_one_mount_link(Swap *s, Mount *m);
diff --git a/src/system.conf b/src/system.conf
index 9d87c6dfda..c6a7bf3df8 100644
--- a/src/system.conf
+++ b/src/system.conf
@@ -18,6 +18,5 @@
#SysVConsole=yes
#CrashChVT=1
#CPUAffinity=1 2
-#MountOnPlug=yes
-#SwapOnPlug=yes
#MountAuto=yes
+#SwapAuto=yes