]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
api.c: Add cgroup v2 support to cgroup_create_cgroup() 11/head
authorTom Hromatka <tom.hromatka@oracle.com>
Wed, 29 Jul 2020 16:52:49 +0000 (16:52 +0000)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 29 Jul 2020 20:05:10 +0000 (20:05 +0000)
commit8fb91a016a4031fc4853e85b6afc5c378c05951a
tree234307422c1b8a77deb5dbefd43e9228bd21676e
parentcbf0928aaf4c9e4444ba35a78a7734171c5640ab
api.c: Add cgroup v2 support to cgroup_create_cgroup()

This commit adds cgroup v2 support go cgroup_create_cgroup().
If the controller is mounted via cgroup v2, then the
subtree_control file in the parent directory will be updated
to enable the controller in children cgroups.  The tasks
file is only updated for cgroup v1 mounts.

Here's an example of creating a cgroup hierarchy in a single command:
sudo cgcreate -g io:a/b/c/d

The above cgcreate example is equivalent to:
mkdir -p {root_cg}/a/b/c/d
echo +io > {root_cg}/cgroup.subtree_control
echo +io > {root_cg}/a/cgroup.subtree_control
echo +io > {root_cg}/a/b/cgroup.subtree_control
echo +io > {root_cg}/a/b/c/cgroup.subtree_control

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/api.c