ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
a9339c
From d772781b2810ae71bace24cce05f255212a348ed Mon Sep 17 00:00:00 2001
a9339c
From: Franck Bui <fbui@suse.com>
a9339c
Date: Thu, 8 Oct 2015 19:06:06 +0200
a9339c
Subject: [PATCH] Make sure the mount units pulled by 'RequiresMountsFor=' are
a9339c
 loaded (if they exist)
a9339c
a9339c
We should make sure that mount units involved by 'RequiresMountsFor='
a9339c
directives are really loaded if not required by any others units so
a9339c
that Requires= dependencies on the mount units are applied and thus
a9339c
the mount unit dependencies are started.
a9339c
a9339c
(cherry-picked from commit c7c89abb9edf9320246482bf4a8e0656199281ae)
a9339c
a9339c
Resolves: #1619743
a9339c
---
a9339c
 src/core/unit.c | 18 ++++++++++++++----
a9339c
 1 file changed, 14 insertions(+), 4 deletions(-)
a9339c
a9339c
diff --git a/src/core/unit.c b/src/core/unit.c
a9339c
index cfddce34d..e8532a057 100644
a9339c
--- a/src/core/unit.c
a9339c
+++ b/src/core/unit.c
a9339c
@@ -1131,13 +1131,23 @@ static int unit_add_mount_dependencies(Unit *u) {
a9339c
                 char prefix[strlen(*i) + 1];
a9339c
 
a9339c
                 PATH_FOREACH_PREFIX_MORE(prefix, *i) {
a9339c
+                        _cleanup_free_ char *p = NULL;
a9339c
                         Unit *m;
a9339c
 
a9339c
-                        r = manager_get_unit_by_path(u->manager, prefix, ".mount", &m);
a9339c
-                        if (r < 0)
a9339c
-                                return r;
a9339c
-                        if (r == 0)
a9339c
+                        p = unit_name_from_path(prefix, ".mount");
a9339c
+                        if (!p)
a9339c
+                                return -ENOMEM;
a9339c
+
a9339c
+                        m = manager_get_unit(u->manager, p);
a9339c
+                        if (!m) {
a9339c
+                                /* Make sure to load the mount unit if
a9339c
+                                 * it exists. If so the dependencies
a9339c
+                                 * on this unit will be added later
a9339c
+                                 * during the loading of the mount
a9339c
+                                 * unit. */
a9339c
+                                (void) manager_load_unit_prepare(u->manager, p, NULL, NULL, &m);
a9339c
                                 continue;
a9339c
+                        }
a9339c
                         if (m == u)
a9339c
                                 continue;
a9339c