]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/mount: set Mount.from_proc_self_mountinfo flag before adding default dependencies
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 13 May 2022 03:30:04 +0000 (12:30 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 4 Aug 2022 16:35:38 +0000 (01:35 +0900)
When the function mount_setup_new_unit() is called, the corresponding
.mount unit file is not loaded. Hence, Mount.from_fragment is false.
To add default dependencies to e.g. .device units, it is necessary that
the Mount.from_proc_self_mountinfo flag is set. However, the flag was
not set even the unit has information from /proc/self/mountinfo.

Partially fixes #19983.

src/core/mount.c

index 4263610e8281a2eb576c190f2976ac0274ec7620..229b3de4fd2b0cb1e5e9d9ac22bf5e475aa57fa2 100644 (file)
@@ -1600,15 +1600,15 @@ static int mount_setup_new_unit(
         if (r < 0)
                 return r;
 
-        r = mount_add_non_exec_dependencies(MOUNT(u));
-        if (r < 0)
-                return r;
-
         /* This unit was generated because /proc/self/mountinfo reported it. Remember this, so that by the
          * time we load the unit file for it (and thus add in extra deps right after) we know what source to
          * attributes the deps to. */
         MOUNT(u)->from_proc_self_mountinfo = true;
 
+        r = mount_add_non_exec_dependencies(MOUNT(u));
+        if (r < 0)
+                return r;
+
         /* We have only allocated the stub now, let's enqueue this unit for loading now, so that everything
          * else is loaded in now. */
         unit_add_to_load_queue(u);