summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvana Hutarova Varekova <varekova@redhat.com>2010-02-08 13:31:47 +0100
committerBalbir Singh <balbir@linux.vnet.ibm.com>2010-02-10 16:43:36 +0530
commit49f97cacb816379f629625cf23beb94729a4bbdb (patch)
treeab1e813791db94715a7b94e828098aa3f16b69f1
parent6b50959c3128c9ba7cfcd9602a39877f69aa5351 (diff)
downloadlibcg-49f97cacb816379f629625cf23beb94729a4bbdb.tar.gz
libcg-49f97cacb816379f629625cf23beb94729a4bbdb.tar.xz
libcg-49f97cacb816379f629625cf23beb94729a4bbdb.zip
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 <varekova@redhat.com> Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
-rw-r--r--include/libcgroup.h16
-rw-r--r--src/libcgroup.map2
-rw-r--r--src/wrapper.c24
3 files changed, 42 insertions, 0 deletions
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;
+}
+