libprocessgroup: Combine all 3 ActivateControllers implementations into one
Remove this code duplication and use just one interface.
Bug: 349105928
Change-Id: Id8c7186d9665e9087a654f5781b7593b06349160
diff --git a/libprocessgroup/cgroup_map.cpp b/libprocessgroup/cgroup_map.cpp
index 8180ccf..32bef13 100644
--- a/libprocessgroup/cgroup_map.cpp
+++ b/libprocessgroup/cgroup_map.cpp
@@ -194,24 +194,6 @@
return CgroupControllerWrapper(nullptr);
}
-int CgroupMap::ActivateControllers(const std::string& path) const {
- for (const auto& [name, descriptor] : descriptors_) {
- const uint32_t flags = descriptor.controller()->flags();
- const uint32_t max_activation_depth = descriptor.controller()->max_activation_depth();
- const int depth = GetCgroupDepth(descriptor.controller()->path(), path);
-
- if (flags & CGROUPRC_CONTROLLER_FLAG_NEEDS_ACTIVATION && depth < max_activation_depth) {
- std::string str("+");
- str.append(descriptor.controller()->name());
- if (!WriteStringToFile(str, path + "/cgroup.subtree_control")) {
- if (flags & CGROUPRC_CONTROLLER_FLAG_OPTIONAL) {
- PLOG(WARNING) << "Activation of cgroup controller " << str
- << " failed in path " << path;
- } else {
- return -errno;
- }
- }
- }
- }
- return 0;
+bool CgroupMap::ActivateControllers(const std::string& path) const {
+ return ::ActivateControllers(path, descriptors_);
}