[systemd-devel] [PATCH] mount: fix network umounts
harald at redhat.com
harald at redhat.com
Fri Mar 8 10:18:48 PST 2013
From: Harald Hoyer <harald at redhat.com>
Now works as expected for me.
$ mount 192.168.2.2:/Public /mnt/test
$ systemctl status mnt-test.mount
mnt-test.mount - /mnt/test
Loaded: loaded (/proc/self/mountinfo)
Active: active (mounted) since Fr 2013-03-08 16:24:38 CET; 11s ago
Where: /mnt/test
What: 192.168.2.2:/Public
Mär 08 16:24:38 lenovo systemd[1]: mnt-test.mount changed dead -> mounted
$ systemctl stop remote-fs-pre.target
$ systemctl status mnt-test.mount
mnt-test.mount - /mnt/test
Loaded: loaded (/proc/self/mountinfo)
Active: inactive (dead) since Fr 2013-03-08 16:24:57 CET; 1s ago
Where: /mnt/test
Process: 4968 ExecUnmount=/bin/umount /mnt/test (code=exited, status=0/SUCCESS)
Mär 08 16:24:57 lenovo systemdd[1]: Installed new job mnt-test.mount/stop as 744
Mär 08 16:24:57 lenovo systemd[1]: Unmounting /mnt/test...
Mär 08 16:24:57 lenovo systemd[1]: About to execute /bin/umount /mnt/test
Mär 08 16:24:57 lenovo systemd[1]: Forked /bin/umount as 4968
Mär 08 16:24:57 lenovo systemd[1]: mnt-test.mount changed mounted -> unmounting
Mär 08 16:24:57 lenovo systemd[1]: Child 4968 belongs to mnt-test.mount
Mär 08 16:24:57 lenovo systemd[1]: mnt-test.mount mount process exited, code=exited status=0
Mär 08 16:24:57 lenovo systemd[1]: mnt-test.mount changed unmounting -> dead
Mär 08 16:24:57 lenovo systemd[1]: Job mnt-test.mount/stop finished, result=done
Mär 08 16:24:57 lenovo systemd[1]: Unmounted /mnt/test.
---
src/core/mount.c | 10 +++++++---
src/fstab-generator/fstab-generator.c | 6 ++++++
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/src/core/mount.c b/src/core/mount.c
index 419cf27..6b90731 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -447,15 +447,20 @@ static int mount_add_default_dependencies(Mount *m) {
if (UNIT(m)->manager->running_as != SYSTEMD_SYSTEM)
return 0;
- p = get_mount_parameters_fragment(m);
+ p = get_mount_parameters(m);
+
if (!p)
return 0;
if (path_equal(m->where, "/"))
return 0;
- if (mount_is_network(p))
+ if (mount_is_network(p)) {
after = SPECIAL_REMOTE_FS_PRE_TARGET;
+ r = unit_add_dependency_by_name(UNIT(m), UNIT_PART_OF, after, NULL, true);
+ if (r < 0)
+ return r;
+ }
else
after = SPECIAL_LOCAL_FS_PRE_TARGET;
@@ -1516,7 +1521,6 @@ static int mount_add_one(
if (u->load_state == UNIT_ERROR) {
u->load_state = UNIT_LOADED;
u->load_error = 0;
-
/* Load in the extras later on, after we
* finished initialization of the unit */
load_extras = true;
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index 910bbc1..f855e95 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -274,6 +274,12 @@ static int add_mount(const char *what, const char *where, const char *type, cons
"Before=%s\n",
post);
+ if (isnetwork) {
+ fprintf(f,
+ "PartOf=%s\n",
+ pre);
+ }
+
fprintf(f,
"\n"
"[Mount]\n"
--
1.8.1
More information about the systemd-devel
mailing list