summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarron Rulon <barron@lexmark.com>2016-08-27 10:27:49 -0400
committerBarron Rulon <barron@lexmark.com>2016-08-27 10:46:52 -0400
commit4f8d40a9dc3d2dc754a30bc9455817ee6a857c62 (patch)
tree870fa22b1eb1989dc22b8ba40e07cd1bd62a48aa
parente520950a03419957875034bc27795b0b81d8e793 (diff)
mount: add new ForceUnmount= setting for mount units, mapping to umount(8)'s "-f" switch
-rw-r--r--man/systemd.mount.xml11
-rw-r--r--src/core/dbus-mount.c1
-rw-r--r--src/core/load-fragment-gperf.gperf.m41
-rw-r--r--src/core/mount.c8
-rw-r--r--src/core/mount.h1
5 files changed, 20 insertions, 2 deletions
diff --git a/man/systemd.mount.xml b/man/systemd.mount.xml
index fa17f22dc3..dd08feb5ad 100644
--- a/man/systemd.mount.xml
+++ b/man/systemd.mount.xml
@@ -365,6 +365,17 @@
</varlistentry>
<varlistentry>
+ <term><varname>ForceUnmount=</varname></term>
+
+ <listitem><para>Takes a boolean argument. If true, force an
+ unmount (in case of an unreachable NFS system).
+ This corresponds with
+ <citerefentry project='man-pages'><refentrytitle>umount</refentrytitle><manvolnum>8</manvolnum></citerefentry>'s
+ <parameter>-f</parameter> switch. Defaults to
+ off.</para></listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><varname>DirectoryMode=</varname></term>
<listitem><para>Directories of mount points (and any parent
directories) are automatically created if needed. This option
diff --git a/src/core/dbus-mount.c b/src/core/dbus-mount.c
index 4421f26bc1..76a7a7ce97 100644
--- a/src/core/dbus-mount.c
+++ b/src/core/dbus-mount.c
@@ -117,6 +117,7 @@ const sd_bus_vtable bus_mount_vtable[] = {
SD_BUS_PROPERTY("DirectoryMode", "u", bus_property_get_mode, offsetof(Mount, directory_mode), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("SloppyOptions", "b", bus_property_get_bool, offsetof(Mount, sloppy_options), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("LazyUnmount", "b", bus_property_get_bool, offsetof(Mount, lazy_unmount), SD_BUS_VTABLE_PROPERTY_CONST),
+ SD_BUS_PROPERTY("ForceUnmount", "b", bus_property_get_bool, offsetof(Mount, force_unmount), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("Result", "s", property_get_result, offsetof(Mount, result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("UID", "u", NULL, offsetof(Unit, ref_uid), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("GID", "u", NULL, offsetof(Unit, ref_gid), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
diff --git a/src/core/load-fragment-gperf.gperf.m4 b/src/core/load-fragment-gperf.gperf.m4
index 420d32dbd7..057b92bfa3 100644
--- a/src/core/load-fragment-gperf.gperf.m4
+++ b/src/core/load-fragment-gperf.gperf.m4
@@ -356,6 +356,7 @@ Mount.TimeoutSec, config_parse_sec, 0,
Mount.DirectoryMode, config_parse_mode, 0, offsetof(Mount, directory_mode)
Mount.SloppyOptions, config_parse_bool, 0, offsetof(Mount, sloppy_options)
Mount.LazyUnmount, config_parse_bool, 0, offsetof(Mount, lazy_unmount)
+Mount.ForceUnmount, config_parse_bool, 0, offsetof(Mount, force_unmount)
EXEC_CONTEXT_CONFIG_ITEMS(Mount)m4_dnl
CGROUP_CONTEXT_CONFIG_ITEMS(Mount)m4_dnl
KILL_CONTEXT_CONFIG_ITEMS(Mount)m4_dnl
diff --git a/src/core/mount.c b/src/core/mount.c
index 2c2a54edbb..6c794d4073 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -678,7 +678,8 @@ static void mount_dump(Unit *u, FILE *f, const char *prefix) {
"%sFrom /proc/self/mountinfo: %s\n"
"%sFrom fragment: %s\n"
"%sDirectoryMode: %04o\n"
- "%sLazyUnmount: %s\n",
+ "%sLazyUnmount: %s\n"
+ "%sForceUnmount: %s\n",
prefix, mount_state_to_string(m->state),
prefix, mount_result_to_string(m->result),
prefix, m->where,
@@ -688,7 +689,8 @@ static void mount_dump(Unit *u, FILE *f, const char *prefix) {
prefix, yes_no(m->from_proc_self_mountinfo),
prefix, yes_no(m->from_fragment),
prefix, m->directory_mode,
- prefix, yes_no(m->lazy_unmount));
+ prefix, yes_no(m->lazy_unmount),
+ prefix, yes_no(m->force_unmount));
if (m->control_pid > 0)
fprintf(f,
@@ -850,6 +852,8 @@ static void mount_enter_unmounting(Mount *m) {
r = exec_command_set(m->control_command, UMOUNT_PATH, m->where, NULL);
if (r >= 0 && m->lazy_unmount)
r = exec_command_append(m->control_command, "-l", NULL);
+ if (r >= 0 && m->force_unmount)
+ r = exec_command_append(m->control_command, "-f", NULL);
if (r < 0)
goto fail;
diff --git a/src/core/mount.h b/src/core/mount.h
index c4a2bff100..9f7326ba6a 100644
--- a/src/core/mount.h
+++ b/src/core/mount.h
@@ -72,6 +72,7 @@ struct Mount {
bool sloppy_options;
bool lazy_unmount;
+ bool force_unmount;
MountResult result;
MountResult reload_result;