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>