summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorDhaval Giani <dhaval@linux.vnet.ibm.com>2009-06-22 17:20:09 +0530
committerDhaval Giani <dhaval@linux.vnet.ibm.com>2009-06-22 17:20:09 +0530
commitb761e6e872d2ef159f0d2e6d80c3fe2b6218bf19 (patch)
tree48da511eeb7d22e44a89a2ce3127b1e97f338449 /src/tools
parent3ee2b056852a65bc7a3128ef924f1ae83573016e (diff)
downloadlibcg-b761e6e872d2ef159f0d2e6d80c3fe2b6218bf19.tar.gz
libcg-b761e6e872d2ef159f0d2e6d80c3fe2b6218bf19.tar.xz
libcg-b761e6e872d2ef159f0d2e6d80c3fe2b6218bf19.zip
libcgroup: Introduce a unload cgroups API
This API will unload the cgroups created in the cgroupfs and unmount and delete the filesystem mount point. The action is equivalent to what is done currently in service cgconfig stop. The reason for this API is to make sure we don't end up with a asymmetric library API subset. Today an application program can programatically through cgroup_config_load_config() load a configuration file, but has no means to cleanup (including all temporarily created groups). changes from v3 1. Address Jan's comments from http://article.gmane.org/gmane.comp.lib.libcg.devel/1105 changes from v2 1. Fix a leak as noted by Bharata 2. Address Balbir's review comments at http://article.gmane.org/gmane.comp.lib.libcg.devel/1080 changes from v1 1. Change the name of the function to cgroup_unload_cgroups 2. Change the name of the executatble to cgclear 3. Split out the funtions Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/Makefile.am4
-rw-r--r--src/tools/cgclear.c37
2 files changed, 40 insertions, 1 deletions
diff --git a/src/tools/Makefile.am b/src/tools/Makefile.am
index 2b4c9e7..f82916c 100644
--- a/src/tools/Makefile.am
+++ b/src/tools/Makefile.am
@@ -5,7 +5,7 @@ if WITH_TOOLS
bin_PROGRAMS = cgexec cgclassify cgcreate cgset
-sbin_PROGRAMS = cgconfigparser
+sbin_PROGRAMS = cgconfigparser cgclear
cgexec_SOURCES = cgexec.c tools-common.c tools-common.h
@@ -15,4 +15,6 @@ cgcreate_SOURCES = cgcreate.c tools-common.c tools-common.h
cgconfigparser_SOURCES = cgconfig.c
+cgclear_SOURCES = cgclear.c
+
endif
diff --git a/src/tools/cgclear.c b/src/tools/cgclear.c
new file mode 100644
index 0000000..1485768
--- /dev/null
+++ b/src/tools/cgclear.c
@@ -0,0 +1,37 @@
+/*
+ * Copyright IBM Corporation. 2009
+ *
+ * Authors: Dhaval Giani <dhaval@linux.vnet.ibm.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Code initiated and designed by Dhaval Giani. All faults are most likely
+ * his mistake.
+ */
+
+#include <libcgroup.h>
+#include <libcgroup-internal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+int main(int argc, char *argv[])
+{
+ int error;
+
+ error = cgroup_unload_cgroups();
+
+ if (error) {
+ printf("%s failed with %s\n", argv[0], cgroup_strerror(error));
+ exit(3);
+ }
+
+ return 0;
+}