From 49f97cacb816379f629625cf23beb94729a4bbdb Mon Sep 17 00:00:00 2001 From: Ivana Hutarova Varekova Date: Mon, 8 Feb 2010 13:31:47 +0100 Subject: api for generating the list of variables of given controller api for generating the list of variables of given controller: changelog - v2: fixed the space on the end of lines * int cgroup_get_value_name_count(struct cgroup_controller, *controller) functions return the number of variables in "controller" * char *cgroup_get_value_name(struct cgroup_controller *controller, int index) function return the "index" variable of "controller" Signed-off-by: Ivana Hutarova Varekova Signed-off-by: Balbir Singh --- include/libcgroup.h | 16 ++++++++++++++++ src/libcgroup.map | 2 ++ src/wrapper.c | 24 ++++++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/include/libcgroup.h b/include/libcgroup.h index d54d9c6..ce75d2e 100644 --- a/include/libcgroup.h +++ b/include/libcgroup.h @@ -469,6 +469,22 @@ int cgroup_set_value_bool(struct cgroup_controller *controller, const char *name, bool value); struct cgroup_controller *cgroup_get_controller(struct cgroup *cgroup, const char *name); + +/** + * Return the number of variables for the specified controller, if the + * structure does not exist -1 is returned + * @param controller Name of the controller for which stats are requested. + */ +int cgroup_get_value_name_count(struct cgroup_controller *controller); + +/** + * Return the "index" variable for the specified controller, + * the return value is the pointer to the internal structure so + * don't dealocate it, or change the content of the memory space. + * @param controller Name of the controller for which stats are requested. + * @param index number of the variable. + */ +char *cgroup_get_value_name(struct cgroup_controller *controller, int index); /* * Config related stuff */ diff --git a/src/libcgroup.map b/src/libcgroup.map index 87d8a51..06c5e07 100644 --- a/src/libcgroup.map +++ b/src/libcgroup.map @@ -82,4 +82,6 @@ global: cgroup_get_all_controller_begin; cgroup_get_all_controller_next; cgroup_get_all_controller_end; + cgroup_get_value_name_count; + cgroup_get_value_name; } CGROUP_0.34; diff --git a/src/wrapper.c b/src/wrapper.c index c82ffbf..53d70a9 100644 --- a/src/wrapper.c +++ b/src/wrapper.c @@ -612,3 +612,27 @@ scgroup_err: cgroup_free(&src_cgroup); return NULL; } + +int cgroup_get_value_name_count(struct cgroup_controller *controller) +{ + int ret; + + if (!controller) + return -1; + + return controller->index; +} + + +char *cgroup_get_value_name(struct cgroup_controller *controller, int index) +{ + + if (!controller) + return NULL; + + if (index < controller->index) + return (controller->values[index])->name; + else + return NULL; +} + -- cgit