From: Mike Yuan Date: Sat, 5 Jul 2025 23:54:45 +0000 (+0200) Subject: core/cgroup: regroup functions X-Git-Tag: v258-rc1~147^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=92172973b1282af71ffd392b16a9001a170af084;p=thirdparty%2Fsystemd.git core/cgroup: regroup functions --- diff --git a/src/core/cgroup.c b/src/core/cgroup.c index 9c5e3c41a52..836e974eaa1 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -90,6 +90,19 @@ bool manager_owns_host_root_cgroup(Manager *m) { return empty_or_root(m->cgroup_root); } +bool unit_has_host_root_cgroup(const Unit *u) { + assert(u); + assert(u->manager); + + /* Returns whether this unit manages the root cgroup. This will return true if this unit is the root slice and + * the manager manages the root cgroup. */ + + if (!manager_owns_host_root_cgroup(u->manager)) + return false; + + return unit_has_name(u, SPECIAL_ROOT_SLICE); +} + bool unit_has_startup_cgroup_constraints(Unit *u) { assert(u); @@ -112,19 +125,6 @@ bool unit_has_startup_cgroup_constraints(Unit *u) { c->startup_memory_low_set; } -bool unit_has_host_root_cgroup(const Unit *u) { - assert(u); - assert(u->manager); - - /* Returns whether this unit manages the root cgroup. This will return true if this unit is the root slice and - * the manager manages the root cgroup. */ - - if (!manager_owns_host_root_cgroup(u->manager)) - return false; - - return unit_has_name(u, SPECIAL_ROOT_SLICE); -} - static int set_attribute_and_warn(Unit *u, const char *controller, const char *attribute, const char *value) { int r;