summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorKen'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>2009-06-26 14:49:50 +0900
committerDhaval Giani <dhaval@linux.vnet.ibm.com>2009-06-29 16:47:32 +0530
commit495c45c844522c29ee4d0a26942e894f1346c237 (patch)
tree68731c59dcce9488cb07e5e925174f264808c370 /include
parentd297b6fc17d51b8c2f6cdc094ada378d49e9a583 (diff)
downloadlibcg-495c45c844522c29ee4d0a26942e894f1346c237.tar.gz
libcg-495c45c844522c29ee4d0a26942e894f1346c237.tar.xz
libcg-495c45c844522c29ee4d0a26942e894f1346c237.zip
Add the key "process name" to find a matching rule.
Hi, Changelog of v6: ================ * No change. Changelog of v5.1: ================== * BUGFIX: Clear the flags meaning "found a matching rule" when a process name does not match. There was a problem that cgexec and cgclassify didn't work correctly if a user executes cgexec/cgclassify based on /etc/cgrules.conf. For example, if a root user executes `cgclassify $$` on the following /etc/cgrules.conf, the process ($$) should be moved to users/root on cpuset and memory subsystems. But the process was moved to users/root/cp on memory subsystem only. Example of /etc/cgrules.conf: ============================= root:cp cpuset users/root/cp % memory users/root/cp root cpuset users/root % memory users/root The cause is why the flags meaning "found a matching rule" (uid, gid, and matched) is not cleared when a process name does not match. This problem is fixed on this patch. Changelog of v5: ================ * Rebase the patch to the latest code. Changelog of v4: ================ * No change. Changelog of v3: ================ * BUGFIX: Fix the handling of '%' in /etc/cgrules.conf. Changelog of v2: ================ * Use strcmp() instead of strncmp() for checking a process name strictly. * Some cleanups. Description: ============ This patch adds the key "process name" to find a matching rule. Thanks Ken'ichi Ohmichi Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
Diffstat (limited to 'include')
-rw-r--r--include/libcgroup.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/libcgroup.h b/include/libcgroup.h
index 6155f09..a9799ab 100644
--- a/include/libcgroup.h
+++ b/include/libcgroup.h
@@ -149,6 +149,27 @@ int cgroup_create_cgroup_from_parent(struct cgroup *cgroup, int ignore_ownership
int cgroup_copy_cgroup(struct cgroup *dst, struct cgroup *src);
/**
+ * 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
+ * the configuration file each time it is called.
+ *
+ * The flags can alter the behavior of this function:
+ * CGFLAG_USECACHE: Use cached rules instead of parsing the config file
+ *
+ * This function may NOT be thread safe.
+ * @param uid The UID to match
+ * @param gid The GID to match
+ * @param procname The PROCESS NAME to match
+ * @param pid The PID of the process to move
+ * @param flags Bit flags to change the behavior, as defined above
+ * @return 0 on success, > 0 on error
+ * TODO: Determine thread-safeness and fix of not safe.
+ */
+int cgroup_change_cgroup_flags(const uid_t uid, const gid_t gid,
+ char *procname, const pid_t pid, const int flags);
+
+/**
* Changes the cgroup of a program based on the rules in the config file. If a
* rule exists for the given UID or GID, then the given PID is placed into the
* correct group. By default, this function parses the configuration file each