chiark / gitweb /
mount: add global configuration options for handling of auto mounts
authorLennart Poettering <lennart@poettering.net>
Wed, 25 Aug 2010 01:11:26 +0000 (03:11 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 25 Aug 2010 01:11:26 +0000 (03:11 +0200)
src/dbus-manager.c
src/main.c
src/manager.h
src/mount.c
src/swap.c
src/system.conf

index eb3768455c2c76edcb5e11074ad4339ab02e6faa..557124712aeca203c7aebfe69a4e113207ebec2f 100644 (file)
         "  <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" \
         " </interface>\n"
 
 #define INTROSPECTION_BEGIN                                             \
@@ -252,6 +255,9 @@ 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     },
                 { NULL, NULL, NULL, NULL, NULL }
         };
 
index 35ee1c73e1bfb0bf550851c37fbaccee4bffb449..54fc0540ac92ed148e2fcd530b8d0de5d1196893 100644 (file)
@@ -64,6 +64,9 @@ 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 FILE* serialization = NULL;
 
@@ -472,16 +475,19 @@ static int config_parse_cpu_affinity(
 static int parse_config_file(void) {
 
         const ConfigItem items[] = {
-                { "LogLevel",    config_parse_level,        NULL,             "Manager" },
-                { "LogTarget",   config_parse_target,       NULL,             "Manager" },
-                { "LogColor",    config_parse_color,        NULL,             "Manager" },
-                { "LogLocation", config_parse_location,     NULL,             "Manager" },
-                { "DumpCore",    config_parse_bool,         &arg_dump_core,   "Manager" },
-                { "CrashShell",  config_parse_bool,         &arg_crash_shell, "Manager" },
-                { "ShowStatus",  config_parse_bool,         &arg_show_status, "Manager" },
-                { "SysVConsole", config_parse_bool,         &arg_sysv_console,"Manager" },
-                { "CrashChVT",   config_parse_int,          &arg_crash_chvt,  "Manager" },
-                { "CPUAffinity", config_parse_cpu_affinity, NULL,             "Manager" },
+                { "LogLevel",    config_parse_level,        NULL,               "Manager" },
+                { "LogTarget",   config_parse_target,       NULL,               "Manager" },
+                { "LogColor",    config_parse_color,        NULL,               "Manager" },
+                { "LogLocation", config_parse_location,     NULL,               "Manager" },
+                { "DumpCore",    config_parse_bool,         &arg_dump_core,     "Manager" },
+                { "CrashShell",  config_parse_bool,         &arg_crash_shell,   "Manager" },
+                { "ShowStatus",  config_parse_bool,         &arg_show_status,   "Manager" },
+                { "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" },
                 { NULL, NULL, NULL, NULL }
         };
 
@@ -986,6 +992,9 @@ 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;
 
         if ((r = manager_startup(m, serialization, fds)) < 0)
                 log_error("Failed to fully start up daemon: %s", strerror(-r));
index 2b4eee933dfed189099abf76475a95e8d9886ecc..dd48593d4ce70c6027cc3f3a695bf60bf48bbbea 100644 (file)
@@ -202,6 +202,10 @@ struct Manager {
         bool confirm_spawn;
         bool sysv_console;
 
+        bool mount_on_plug;
+        bool swap_on_plug;
+        bool mount_auto;
+
         int n_deserializing;
 };
 
index b667ae52c9e00dbdc1f83aa6deaca387c369fb26..b49443ced11b962e8d930049647ca49cf3b009f0 100644 (file)
@@ -244,7 +244,8 @@ static int mount_add_target_links(Mount *m) {
 
         noauto = !!mount_test_option(p->options, MNTOPT_NOAUTO);
         user = mount_test_option(p->options, "user") || mount_test_option(p->options, "users");
-        handle = !!mount_test_option(p->options, "comment=systemd.mount");
+        handle = !!mount_test_option(p->options, "comment=systemd.mount") ||
+                m->meta.manager->mount_auto;
         automount = !!mount_test_option(p->options, "comment=systemd.automount");
 
         if (mount_test_option(p->options, "_netdev") ||
@@ -362,7 +363,9 @@ static int mount_load(Unit *u) {
                         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)) < 0)
+                        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_mount_links(m)) < 0)
index c81fd67cc8c22b1fc9fbb081c224dfe5a9604ac4..4a672fbdffe047560ab2430bfc620ce973c28f4e 100644 (file)
@@ -195,7 +195,9 @@ 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)) < 0)
+                if ((r = unit_add_node_link(u, s->what,
+                                            u->meta.manager->running_as == MANAGER_SYSTEM &&
+                                            u->meta.manager->swap_on_plug)) < 0)
                         return r;
 
                 if ((r = swap_add_mount_links(s)) < 0)
index 11885e0b59b71ec0aac7c0bf8044280cc1a3f79e..9d87c6dfda8f51356f0e31891fafad20753d7479 100644 (file)
@@ -5,7 +5,7 @@
 #  the Free Software Foundation; either version 2 of the License, or
 #  (at your option) any later version.
 #
-# See system.conf(5) for details
+# See systemd(1) for details
 
 [Manager]
 #LogLevel=info
@@ -18,3 +18,6 @@
 #SysVConsole=yes
 #CrashChVT=1
 #CPUAffinity=1 2
+#MountOnPlug=yes
+#SwapOnPlug=yes
+#MountAuto=yes