]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
api for generating the list of variables of given controller
authorIvana Hutarova Varekova <varekova@redhat.com>
Mon, 8 Feb 2010 12:31:47 +0000 (13:31 +0100)
committerBalbir Singh <balbir@linux.vnet.ibm.com>
Wed, 10 Feb 2010 11:13:36 +0000 (16:43 +0530)
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>
include/libcgroup.h
src/libcgroup.map
src/wrapper.c

index d54d9c691fcf683080b925791f3a5d87eddd4c31..ce75d2ee924390b05b95649e98a78bd0548571b5 100644 (file)
@@ -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
  */
index 87d8a5144d5308d5b328589f25d8b82e38002c55..06c5e0721b52319aacf8e0459b012e3607247efa 100644 (file)
@@ -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;
index c82ffbffc144e1fc7eb2ddf4af074f813ba16b6d..53d70a9bf46269890c83e84620e17bac17c06c9f 100644 (file)
@@ -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;
+}
+