static int slice_add_parent_slice(Slice *s) { char *a, *dash; Unit *parent; int r; assert(s); if (UNIT_ISSET(UNIT(s)->slice)) return 0; if (unit_has_name(UNIT(s), SPECIAL_ROOT_SLICE)) return 0; a = strdupa(UNIT(s)->id); dash = strrchr(a, '-'); if (dash) strcpy(dash, ".slice"); else a = (char*) SPECIAL_ROOT_SLICE; r = manager_load_unit(UNIT(s)->manager, a, NULL, NULL, &parent); if (r < 0) return r; unit_ref_set(&UNIT(s)->slice, parent); return 0; }
static int busname_add_extras(BusName *n) { Unit *u = UNIT(n); int r; assert(n); if (!n->name) { n->name = unit_name_to_prefix(u->id); if (!n->name) return -ENOMEM; } if (!u->description) { r = unit_set_description(u, n->name); if (r < 0) return r; } if (n->activating) { if (!UNIT_DEREF(n->service)) { Unit *x; r = unit_load_related_unit(u, ".service", &x); if (r < 0) return r; unit_ref_set(&n->service, x); } r = unit_add_two_dependencies(u, UNIT_BEFORE, UNIT_TRIGGERS, UNIT_DEREF(n->service), true); if (r < 0) return r; } if (u->default_dependencies) { r = busname_add_default_default_dependencies(n); if (r < 0) return r; } return 0; }