summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDhaval Giani <dhaval@linux.vnet.ibm.com>2009-06-18 19:42:48 +0530
committerDhaval Giani <dhaval@linux.vnet.ibm.com>2009-06-18 19:49:40 +0530
commit3ee2b056852a65bc7a3128ef924f1ae83573016e (patch)
tree04841d70bdd5722f8fd88e0c7a0b42db5002b65b /tests
parent80e9084d3e7be7fbec1ed72f90b88c7626fb93d1 (diff)
downloadlibcg-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 'tests')
-rw-r--r--tests/Makefile.am3
-rw-r--r--tests/get_controller.c34
2 files changed, 36 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 41aebd3..e8401f2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -2,7 +2,7 @@ INCLUDES = -I$(top_srcdir)/include
LDADD = $(top_srcdir)/src/.libs/libcgroup.la
# compile the tests, but do not install them
-noinst_PROGRAMS = libcgrouptest01 libcg_ba setuid pathtest walk_test read_stats walk_task
+noinst_PROGRAMS = libcgrouptest01 libcg_ba setuid pathtest walk_test read_stats walk_task get_controller
libcgrouptest01_SOURCES=libcgrouptest01.c test_functions.c libcgrouptest.h
libcg_ba_SOURCES=libcg_ba.cpp
@@ -11,6 +11,7 @@ pathtest_SOURCES=pathtest.c
walk_test_SOURCES=walk_test.c
read_stats_SOURCES=read_stats.c
walk_task_SOURCES=walk_task.c
+get_controller_SOURCES=get_controller.c
EXTRA_DIST = pathtest.sh runlibcgrouptest.sh
diff --git a/tests/get_controller.c b/tests/get_controller.c
new file mode 100644
index 0000000..1829f5c
--- /dev/null
+++ b/tests/get_controller.c
@@ -0,0 +1,34 @@
+#include <libcgroup.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int main()
+{
+ int error;
+ void *handle;
+ struct cgroup_mount_point info;
+
+ error = cgroup_init();
+
+ if (error) {
+ printf("cgroup_init failed with %s\n", cgroup_strerror(error));
+ exit(1);
+ }
+
+ error = cgroup_get_controller_begin(&handle, &info);
+
+ while (error != ECGEOF) {
+ printf("Controller %s is mounted at %s\n", info.name,
+ info.path);
+ error = cgroup_get_controller_next(&handle, &info);
+ if (error && error != ECGEOF) {
+ printf("cgroup_get_contrller_next failed with %s",
+ cgroup_strerror(error));
+ exit(1);
+ }
+ }
+
+ error = cgroup_get_controller_end(&handle);
+
+ return 0;
+}