|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
From 1b8bdd05fcecd83cc8c8269f06a50ced055ab864 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
From: Franck Bui <fbui@suse.com>
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
Date: Tue, 1 Dec 2015 18:01:44 +0100
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
Subject: [PATCH] fstab-generator: fix automount option and don't start
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
associated mount unit at boot
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
Without this patch applied the mount unit with 'automount' option was still
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
pulled by local-fs.target and thus was activated during the boot process which
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
defeats the purpose of the 'automount' option:
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
$ grep /mnt /etc/fstab
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
/dev/vdb1 /mnt ext2 defaults,x-systemd.automount 0 0
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
$ reboot
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
...
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
$ mount | grep mnt
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
systemd-1 on /mnt type autofs (rw,relatime,fd=34,pgrp=1,timeout=0,minproto=5,maxproto=5,direct)
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
/dev/vdb1 on /mnt type ext2 (rw,relatime)
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
$ systemctl status mnt.mount | grep Active
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
Active: active (mounted) since Thu 2016-03-03 21:36:22 CET; 42s ago
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
With the patch applied:
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
$ reboot
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
...
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
$ mount | grep mnt
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
systemd-1 on /mnt type autofs (rw,relatime,fd=22,pgrp=1,timeout=0,minproto=5,maxproto=5,direct)
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
$ systemctl status mnt.mount | grep Active
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
Active: inactive (dead)
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
$ ls /mnt
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
lost+found
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
$ systemctl status mnt.mount | grep Active
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
Active: active (mounted) since Thu 2016-03-03 21:47:32 CET; 4s ago
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
(cherry picked from commit 2b14df4a9ae92623b584e61db6b5b37accd832c1)
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
src/core/mount.c | 11 ++++++++++-
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
src/fstab-generator/fstab-generator.c | 4 ++--
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
2 files changed, 12 insertions(+), 3 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
diff --git a/src/core/mount.c b/src/core/mount.c
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
index de1075d3a0..cfe4b0f517 100644
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
--- a/src/core/mount.c
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
+++ b/src/core/mount.c
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
@@ -104,6 +104,14 @@ static bool mount_is_auto(const MountParameters *p) {
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
return !fstab_test_option(p->options, "noauto\0");
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
+static bool mount_is_automount(const MountParameters *p) {
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
+ assert(p);
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
+ return fstab_test_option(p->options,
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
+ "comment=systemd.automount\0"
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
+ "x-systemd.automount\0");
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
+}
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
static bool needs_quota(const MountParameters *p) {
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
assert(p);
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
@@ -328,7 +336,8 @@ static int mount_add_device_links(Mount *m) {
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
if (path_equal(m->where, "/"))
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
return 0;
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
- if (mount_is_auto(p) && UNIT(m)->manager->running_as == MANAGER_SYSTEM)
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
+ if (mount_is_auto(p) && !mount_is_automount(p) &&
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
+ UNIT(m)->manager->running_as == MANAGER_SYSTEM)
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
device_wants_mount = true;
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
r = unit_add_node_link(UNIT(m), p->what, device_wants_mount, m->from_fragment ? UNIT_BINDS_TO : UNIT_REQUIRES);
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
index 97a48764ae..6f576b5ecf 100644
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
--- a/src/fstab-generator/fstab-generator.c
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
+++ b/src/fstab-generator/fstab-generator.c
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
@@ -336,8 +336,8 @@ static int add_mount(
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
return log_error_errno(r, "Failed to write unit file %s: %m", unit);
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
- if (!noauto) {
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
- lnk = strjoin(arg_dest, "/", post, nofail || automount ? ".wants/" : ".requires/", name, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
+ if (!noauto && !automount) {
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
+ lnk = strjoin(arg_dest, "/", post, nofail ? ".wants/" : ".requires/", name, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
if (!lnk)
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
return log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
b9a1e3 |
|