This is an automated email from the ASF dual-hosted git repository.
bmahler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
The following commit(s) were added to refs/heads/master by this push:
new 343c8d121 [cgroups2] Add utility to list all the available subsystems
in a cgroup.
343c8d121 is described below
commit 343c8d1211bb94c040ee4363e1ecb2c811573e44
Author: Devin Leamy <[email protected]>
AuthorDate: Fri Mar 8 14:32:36 2024 -0500
[cgroups2] Add utility to list all the available subsystems in a cgroup.
Interface to the "cgroup.controllers" control file.
This closes #503
---
src/linux/cgroups2.cpp | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/linux/cgroups2.cpp b/src/linux/cgroups2.cpp
index 6cd53125c..4d4775ecf 100644
--- a/src/linux/cgroups2.cpp
+++ b/src/linux/cgroups2.cpp
@@ -72,6 +72,26 @@ const std::string TYPE = "cgroup.type";
} // namespace control {
+namespace controllers {
+
+// Find the available controllers (AKA subsystems) in the provided cgroup.
+Try<set<string>> available(const string& cgroup)
+{
+ Try<string> read =
+ cgroups2::read(cgroup, cgroups2::control::CONTROLLERS);
+
+ if (read.isError()) {
+ return Error("Failed to read cgroup.controllers: " + read.error());
+ }
+
+ vector<string> subsystems = strings::split(*read, " ");
+ return set<string>(
+ std::make_move_iterator(subsystems.begin()),
+ std::make_move_iterator(subsystems.end()));
+}
+
+} // namespace controllers {
+
namespace subtree_control {