diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-04-10 04:48:33 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-04-10 18:00:20 +0200 |
commit | f6ff8c29caeeec3d1f1164be73f87d867d8f1b18 (patch) | |
tree | df5db18dabb33b6afbfcf67721e42e2682749f5a /unit.c | |
parent | 013b87c09199926434583e8bb54ac6cb4b835eb5 (diff) |
unit: introduce unit_load_related_unit()
Diffstat (limited to 'unit.c')
-rw-r--r-- | unit.c | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -1440,6 +1440,28 @@ CGroupBonding* unit_get_default_cgroup(Unit *u) { return cgroup_bonding_find_list(u->meta.cgroup_bondings, u->meta.manager->cgroup_controller); } +int unit_load_related_unit(Unit *u, const char *type, Unit **_found) { + char *t; + int r; + + assert(u); + assert(type); + assert(_found); + + if (!(t = unit_name_change_suffix(unit_id(u), type))) + return -ENOMEM; + + assert(!unit_has_name(u, t)); + + r = manager_load_unit(u->meta.manager, t, _found); + free(t); + + if (r >= 0) + assert(*_found != u); + + return r; +} + static const char* const unit_type_table[_UNIT_TYPE_MAX] = { [UNIT_SERVICE] = "service", [UNIT_TIMER] = "timer", |