]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Make sure the mount units pulled by 'RequiresMountsFor=' are loaded (if they exist) 1501/head
authorFranck Bui <fbui@suse.com>
Thu, 8 Oct 2015 17:06:06 +0000 (19:06 +0200)
committerFranck Bui <fbui@suse.com>
Thu, 8 Oct 2015 19:24:22 +0000 (21:24 +0200)
We should make sure that mount units involved by 'RequiresMountsFor='
directives are really loaded if not required by any others units so
that Requires= dependencies on the mount units are applied and thus
the mount unit dependencies are started.

src/core/unit.c

index 3a6313e4a28afc270a6bce4a47e92128ef6bef68..1227399e16c14560960344e4069bdbecee96d1cf 100644 (file)
@@ -1147,13 +1147,23 @@ static int unit_add_mount_dependencies(Unit *u) {
                 char prefix[strlen(*i) + 1];
 
                 PATH_FOREACH_PREFIX_MORE(prefix, *i) {
+                        _cleanup_free_ char *p = NULL;
                         Unit *m;
 
-                        r = manager_get_unit_by_path(u->manager, prefix, ".mount", &m);
+                        r = unit_name_from_path(prefix, ".mount", &p);
                         if (r < 0)
                                 return r;
-                        if (r == 0)
+
+                        m = manager_get_unit(u->manager, p);
+                        if (!m) {
+                                /* Make sure to load the mount unit if
+                                 * it exists. If so the dependencies
+                                 * on this unit will be added later
+                                 * during the loading of the mount
+                                 * unit. */
+                                (void) manager_load_unit_prepare(u->manager, p, NULL, NULL, &m);
                                 continue;
+                        }
                         if (m == u)
                                 continue;