]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mount: mount unit activated by automount unit should be only ordered against the...
authorFranck Bui <fbui@suse.com>
Wed, 1 Apr 2020 15:46:42 +0000 (17:46 +0200)
committerFranck Bui <fbui@suse.com>
Thu, 2 Apr 2020 08:56:30 +0000 (10:56 +0200)
Both fstab-generator and pid1 are duplicating the handling of
"Before=local-fs.target" dependency for mount units.

fstab-generator is correctly skipping this dep if the mount unit is activated
by an automount unit.

However the condition used by pid1 was incorrect and missed the case when a mount
unit uses "x-systemd.automount" since in this case the mount unit should be
(only) ordered against its automount unit counterpart instead.

src/core/mount.c

index 4be4c1781a4ef4bc9cd43dde10287f11234df7f5..0b57f89c29eb22e09bfe1abfb069fccef36ceff6 100644 (file)
@@ -66,6 +66,14 @@ static bool MOUNT_STATE_WITH_PROCESS(MountState state) {
                       MOUNT_CLEANING);
 }
 
+static bool mount_is_automount(const MountParameters *p) {
+        assert(p);
+
+        return fstab_test_option(p->options,
+                                 "comment=systemd.automount\0"
+                                 "x-systemd.automount\0");
+}
+
 static bool mount_is_network(const MountParameters *p) {
         assert(p);
 
@@ -473,7 +481,7 @@ static int mount_add_default_dependencies(Mount *m) {
                 before = SPECIAL_LOCAL_FS_TARGET;
         }
 
-        if (!nofail) {
+        if (!nofail && !mount_is_automount(p)) {
                 r = unit_add_dependency_by_name(UNIT(m), UNIT_BEFORE, before, true, mask);
                 if (r < 0)
                         return r;