]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
lssubsys: Add cgroup v2 support 36/head 37/head
authorTom Hromatka <tom.hromatka@oracle.com>
Wed, 24 Mar 2021 16:38:22 +0000 (10:38 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Thu, 8 Apr 2021 16:28:51 +0000 (10:28 -0600)
Ignore a hierarchy value of zero for cgroup v2 controllers.
This change adds minimal cgroup v2 support to lssubsys.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/libcgroup.map
src/tools/lssubsys.c

index 8967965665269181f613e4122d1690a0add7f03b..29f6dd160495d9ee9324d9f8466b6a2b351f4354 100644 (file)
@@ -137,4 +137,5 @@ CGROUP_0.43 {
        cgroup_test_subsys_mounted;
        cg_mount_table;
        cg_mount_table_lock;
+       cgroup_get_controller_version;
 } CGROUP_0.42;
index bd2e5d5f2a61509846f53e5ffa5d2d253fd019bd..d0a88b62468e0c8e05dc7d0cbbabca0a187e6dac 100644 (file)
@@ -95,6 +95,7 @@ static int print_all_controllers_in_hierarchy(const char *tname,
        int first = 1;
        cont_name_t cont_names;
        cont_name_t cont_name;
+       enum cg_version_t version;
 
        /*
         * Initialize libcgroup and intentionally ignore its result,
@@ -110,8 +111,14 @@ static int print_all_controllers_in_hierarchy(const char *tname,
        }
 
        while (ret != ECGEOF) {
-               /* controller is in the hierrachy */
-               if (info.hierarchy != hierarchy)
+               ret = cgroup_get_controller_version(info.name, &version);
+               if (ret)
+                       goto end;
+
+               /* v1 controllers should be in the hierachy.  v2 controllers
+                * will have a hierarchy value of zero
+                */
+               if (version == CGROUP_V1 && info.hierarchy != hierarchy)
                        goto next;
 
                if (first) {
@@ -162,7 +169,7 @@ static int cgroup_list_all_controllers(const char *tname,
        ret = cgroup_get_all_controller_begin(&handle, &info);
        while (ret == 0) {
                if (info.hierarchy == 0) {
-                       /* the controller is not attached to any hierrachy */
+                       /* the controller is not attached to any hierachy */
                        if (flags & FL_ALL)
                                /* display only if -a flag is set */
                                printf("%s\n", info.name);