summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJan Safranek <jsafrane@redhat.com>2009-08-04 14:28:15 +0200
committerDhaval Giani <dhaval@linux.vnet.ibm.com>2009-08-06 11:57:48 +0530
commit6c4f6a3e4cf680c2bd488d4121ff4871bd711435 (patch)
tree9ad66dda7d9db8207445f4482108b9fd22d1759a /include
parent40716a24b737e55422b31b926996720ed9bca6bb (diff)
downloadlibcg-6c4f6a3e4cf680c2bd488d4121ff4871bd711435.tar.gz
libcg-6c4f6a3e4cf680c2bd488d4121ff4871bd711435.tar.xz
libcg-6c4f6a3e4cf680c2bd488d4121ff4871bd711435.zip
Add recursive cgroup_delete_cgroup_ext.
Changelog: - add braces to cgroup_delete_cgroup_ext to improve readability - use enum instead of macro to define flags The new function allows to recursively delete whole tree of groups. There is new infrastructure created around (cg_delete_cgroup_controller_recursive). It has inconsistent behavior when root group removal is requested - it removes all children (if requested), but does not remove the root itself and returns success value. This allows simple rewrite of cgclear functions to use this function. Original cgroup_delete_cgroup now leads to cgroup_delete_cgroup_ext. Signed-off-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
Diffstat (limited to 'include')
-rw-r--r--include/libcgroup.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/include/libcgroup.h b/include/libcgroup.h
index 3d5660c..d3fad97 100644
--- a/include/libcgroup.h
+++ b/include/libcgroup.h
@@ -114,6 +114,21 @@ enum cgroup_daemon_type {
CGROUP_DAEMON_UNCHANGE_CHILDREN = 0x1,
};
+/**
+ * Flags for cgroup_delete_cgroup_ext
+ */
+enum cgroup_delete_flag {
+ /**
+ * Ignore errors caused by migration of tasks to parent group.
+ */
+ CGFLAG_DELETE_IGNORE_MIGRATION = 1,
+
+ /**
+ * Recursively delete all child groups.
+ */
+ CGFLAG_DELETE_RECURSIVE = 2,
+};
+
struct cgroup_file_info {
enum cgroup_file_type type;
const char *path;
@@ -155,6 +170,21 @@ int cgroup_create_cgroup_from_parent(struct cgroup *cgroup, int ignore_ownership
int cgroup_copy_cgroup(struct cgroup *dst, struct cgroup *src);
/**
+ * Delete control group.
+ * All tasks are automatically moved to parent group.
+ * If CGFLAG_DELETE_IGNORE_MIGRATION flag is used, the errors that occurred
+ * during the task movement are ignored.
+ * CGFLAG_DELETE_RECURSIVE flag specifies that all subgroups should be removed
+ * too. If root group is being removed with this flag specified, all subgroups
+ * are removed but the root group itself is left undeleted.
+ *
+ * @param cgroup Group to delete.
+ * @param flags Combination of CGFLAG_DELETE_* flags, which indicate what and
+ * how to delete.
+ */
+int cgroup_delete_cgroup_ext(struct cgroup *cgroup, int flags);
+
+/**
* Changes the cgroup of a program based on the rules in the config file.
* If a rule exists for the given UID, GID or PROCESS NAME, then the given
* PID is placed into the correct group. By default, this function parses