dcavalca / rpms / systemd

Forked from rpms/systemd 4 months ago
Clone
Blob Blame History Raw
From 043a559ff3732439fc61872a6320ee0a05dd088f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Thu, 5 Dec 2013 00:41:12 -0500
Subject: [PATCH] systemd: add a start job for all units specified with
 SYSTEMD_WANTS=

---
 src/core/device.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/core/device.c b/src/core/device.c
index 5397bd6..610fe88 100644
--- a/src/core/device.c
+++ b/src/core/device.c
@@ -281,7 +281,8 @@ static int device_update_unit(Manager *m, struct udev_device *dev, const char *p
                         size_t l;
 
                         FOREACH_WORD_QUOTED(w, l, wants, state) {
-                                char *e, *n;
+                                _cleanup_free_ char *e, *n = NULL;
+                                Unit *other;
 
                                 e = strndup(w, l);
                                 if (!e) {
@@ -293,12 +294,19 @@ static int device_update_unit(Manager *m, struct udev_device *dev, const char *p
                                         r = -ENOMEM;
                                         goto fail;
                                 }
-                                free(e);
 
                                 r = unit_add_dependency_by_name(u, UNIT_WANTS, n, NULL, true);
-                                free(n);
                                 if (r < 0)
                                         goto fail;
+
+                                other = manager_get_unit(u->manager, n);
+                                if (!other || !unit_can_start(other))
+                                        continue;
+
+                                r = manager_add_job(u->manager, JOB_START, other, JOB_REPLACE, true, NULL, NULL);
+                                if (r < 0)
+                                        log_warning("Failed to add job %s/%s, ignoring: %s.",
+                                                    other->id, job_type_to_string(JOB_START), strerror(-r));
                         }
                 }
         }
-- 
1.8.4.2