From: Kamalesh Babulal Date: Wed, 30 Mar 2022 06:19:14 +0000 (+0530) Subject: python: add support to list cgroup mount points X-Git-Tag: v3.0~94 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=66485b72950d704a317b13a5db1a876ff6967ce1;p=thirdparty%2Flibcgroup.git python: add support to list cgroup mount points Add support to the python bindings to list cgroup mount points. Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka --- diff --git a/src/python/cgroup.pxd b/src/python/cgroup.pxd index bbd30058..7edf6b86 100644 --- a/src/python/cgroup.pxd +++ b/src/python/cgroup.pxd @@ -51,4 +51,7 @@ cdef extern from "libcgroup.h": int cgroup_cgxset(const cgroup * const cg, cg_version_t version, bint ignore_unmappable) + int cgroup_list_mount_points(const cg_version_t cgrp_version, + char ***mount_paths) + # vim: set et ts=4 sw=4: diff --git a/src/python/libcgroup.pyx b/src/python/libcgroup.pyx index 006fbb5d..e3e27d26 100644 --- a/src/python/libcgroup.pyx +++ b/src/python/libcgroup.pyx @@ -277,6 +277,29 @@ cdef class Cgroup: if ret != 0: raise RuntimeError("Failed to create cgroup: {}".format(ret)) + def cgroup_list_mount_points(self, version): + """List cgroup mount points of the specified version + + Arguments: + version - It specifies the cgroup version + + Description: + Parse the /proc/mounts and list the cgroup mount points matching the + version + """ + cdef char **a + + mount_points = [] + ret = cgroup.cgroup_list_mount_points(version, &a) + if ret is not 0: + raise RuntimeError("cgroup_list_mount_points failed: {}".format(ret)); + + i = 0 + while a[i]: + mount_points.append((a[i]).decode("utf-8")) + i = i + 1 + return mount_points + def __dealloc__(self): cgroup.cgroup_free(&self._cgp);