diff options
author | Dhaval Giani <dhaval@linux.vnet.ibm.com> | 2009-06-18 19:42:48 +0530 |
---|---|---|
committer | Dhaval Giani <dhaval@linux.vnet.ibm.com> | 2009-06-18 19:49:40 +0530 |
commit | 3ee2b056852a65bc7a3128ef924f1ae83573016e (patch) | |
tree | 04841d70bdd5722f8fd88e0c7a0b42db5002b65b /include | |
parent | 80e9084d3e7be7fbec1ed72f90b88c7626fb93d1 (diff) | |
download | libcg-3ee2b056852a65bc7a3128ef924f1ae83573016e.tar.gz libcg-3ee2b056852a65bc7a3128ef924f1ae83573016e.tar.xz libcg-3ee2b056852a65bc7a3128ef924f1ae83573016e.zip |
libcgroup: Introduce get_controller API
This set of APIs will allow the caller to query the mount table
and find out what controller is mounted at what path.
Test program has been included in the patch. Running the test program
results in
[dhaval@gondor tests]$ ../libtool --mode=execute ./get_controller
Controller cpu is mounted at /cgroup
Controller cpuacct is mounted at /cgroup
Controller memory is mounted at /cgroup1
[dhaval@gondor tests]$
Which is the setup on this system.
Changes from v2
1. Remove the incorrect comments as pointed out by Bharata
Changes from v1
1. Use a new structure as mentioned by bharata to return the values.
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
Cc: Jan Safranek <jsafrane@redhat.com>
Acked-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/libcgroup.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/include/libcgroup.h b/include/libcgroup.h index dd87c63..e2abdc8 100644 --- a/include/libcgroup.h +++ b/include/libcgroup.h @@ -134,6 +134,11 @@ struct cgroup_stat { char value[CG_VALUE_MAX]; }; +struct cgroup_mount_point { + char name[FILENAME_MAX]; + char path[FILENAME_MAX]; +}; + /* Functions and structures that can be used by the application*/ struct cgroup; struct cgroup_controller; @@ -303,6 +308,22 @@ int cgroup_get_task_begin(char *cgroup, char *controller, void **handle, */ int cgroup_get_task_next(void **handle, pid_t *pid); int cgroup_get_task_end(void **handle); + +/** + * Read the mount table to give a list where each controller is + * mounted + * @handle: Handle to be used for iteration. + * @name: The variable where the name is stored. Should be freed by caller. + * @path: Te variable where the path to the controller is stored. Should be + * freed by the caller. + */ +int cgroup_get_controller_begin(void **handle, struct cgroup_mount_point *info); +/* + * While walking through the mount table, the controllers will be + * returned in order of their mount points. + */ +int cgroup_get_controller_next(void **handle, struct cgroup_mount_point *info); +int cgroup_get_controller_end(void **handle); /* The wrappers for filling libcg structures */ struct cgroup *cgroup_new_cgroup(const char *name); |