summaryrefslogtreecommitdiff
path: root/src/core/manager.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-06-01 17:37:20 +0200
committerLennart Poettering <lennart@poettering.net>2018-06-11 12:53:12 +0200
commit8ace1db703680ebe13321e1eb38c38ef27e6e153 (patch)
tree733e98ea04ac97f18a6372649afca03f34a382cc /src/core/manager.c
parentfd1e3fd8defc280595b98d9f60047d8953251ec8 (diff)
downloadsystemd-8ace1db703680ebe13321e1eb38c38ef27e6e153.tar.gz
systemd-8ace1db703680ebe13321e1eb38c38ef27e6e153.tar.bz2
systemd-8ace1db703680ebe13321e1eb38c38ef27e6e153.zip
core: rework manager_load_startable_unit_or_warn() on top of unit_validate_load_state()
These functions do very similar work, let's unify common code.
Diffstat (limited to 'src/core/manager.c')
-rw-r--r--src/core/manager.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/core/manager.c b/src/core/manager.c
index 04e0c6fe3b..e1ce9229a3 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -1954,16 +1954,12 @@ int manager_load_startable_unit_or_warn(
r = manager_load_unit(m, name, path, &error, &unit);
if (r < 0)
return log_error_errno(r, "Failed to load %s %s: %s",
- name ? "unit" : "file", name ?: path,
+ name ? "unit" : "unit file", name ?: path,
bus_error_message(&error, r));
- else if (IN_SET(unit->load_state, UNIT_ERROR, UNIT_NOT_FOUND))
- return log_error_errno(unit->load_error, "Failed to load %s %s: %m",
- name ? "unit" : "file", name ?: path);
- else if (unit->load_state == UNIT_MASKED) {
- log_error("%s %s is masked.",
- name ? "Unit" : "File", name ?: path);
- return -ERFKILL;
- }
+
+ r = bus_unit_validate_load_state(unit, &error);
+ if (r < 0)
+ return log_error_errno(r, "%s", bus_error_message(&error, r));
*ret = unit;
return 0;