]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
Merge with Dhaval's branch
authorBalbir Singh <balbir@linux.vnet.ibm.com>
Sun, 11 May 2008 10:27:04 +0000 (10:27 +0000)
committerBalbir Singh <balbir@linux.vnet.ibm.com>
Sun, 11 May 2008 10:27:04 +0000 (10:27 +0000)
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/branches/balbir@26 4f4bb910-9a46-0410-90c8-c897d4f1cd53

api.c
libcg.h
tests/libcg_ba.cpp

diff --git a/api.c b/api.c
index 9f144a307c8811885bdfb40fe23e1e2ae650c04f..b154de1715b9ca7d3825195408c0d9544a790315 100644 (file)
--- a/api.c
+++ b/api.c
@@ -321,9 +321,8 @@ int cg_modify_cgroup(struct cgroup *cgroup)
        for (i = 0; i < CG_CONTROLLER_MAX && cgroup->controller[i];
                                                i++, strcpy(path, base)) {
                int j;
-               for(j = 0; j < CG_NV_MAX &&
-                       cgroup->controller[i]->values[j];
-                       j++, strcpy(path, base)) {
+               for(j = 0; j < CG_NV_MAX && cgroup->controller[i]->values[j];
+                                               j++, strcpy(path, base)) {
                        strcat(path, cgroup->controller[i]->values[j]->name);
                        error = cg_set_control_value(path,
                                cgroup->controller[i]->values[j]->value);
@@ -362,9 +361,15 @@ int cg_create_cgroup(struct cgroup *cgroup, int ignore_ownership)
 
        strcpy(base, path);
 
+<<<<<<< .mine
+       if (!ignore_ownership)
+               cg_chown_recursive(fts_path, cgroup->control_uid,
+                                       cgroup->control_gid);
+=======
        if (!ignore_ownership)
                error = cg_chown_recursive(fts_path, cgroup->control_uid,
                                                cgroup->control_gid);
+>>>>>>> .r18
 
        if (error)
                goto err;
@@ -401,7 +406,11 @@ err:
  *
  *  returns 0 on success.
  */
+<<<<<<< .mine
+int cg_delete_cgroup(struct cgroup *cgroup, int ignore_tasks)
+=======
 int cg_delete_cgroup(struct cgroup *cgroup, int ignore_migration)
+>>>>>>> .r18
 {
        FILE *delete_tasks, *base_tasks;
        int tids;
@@ -434,7 +443,11 @@ int cg_delete_cgroup(struct cgroup *cgroup, int ignore_migration)
 del_open_err:
        fclose(base_tasks);
 base_open_err:
+<<<<<<< .mine
+       if (ignore_tasks) {
+=======
        if (ignore_migration) {
+>>>>>>> .r18
                cg_build_path(cgroup->name, path);
                error = rmdir(path);
        }
diff --git a/libcg.h b/libcg.h
index 88f5a45a202423104998e109dbb7be95202ddeb1..7dfe9a49c4e9088c868037009feeae114215100f 100644 (file)
--- a/libcg.h
+++ b/libcg.h
@@ -24,6 +24,7 @@ __BEGIN_DECLS
 #include <linux/types.h>
 #include <stdio.h>
 #include <sys/stat.h>
+#include <unistd.h>
 
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE
@@ -138,19 +139,20 @@ void cg_unload_current_config(void);
 
 #define CG_NV_MAX 100
 #define CG_CONTROLLER_MAX 100
+#define CG_VALUE_MAX 100
 /* Functions and structures that can be used by the application*/
 struct control_value {
        char name[FILENAME_MAX];
-       char *value;
+       char value[CG_VALUE_MAX];
 };
 
 struct controller {
-       char *name;
+       char name[FILENAME_MAX];
        struct control_value *values[CG_NV_MAX];
 };
 
 struct cgroup {
-       char *name;
+       char name[FILENAME_MAX];
        struct controller *controller[CG_CONTROLLER_MAX];
        uid_t tasks_uid;
        gid_t tasks_gid;
@@ -163,6 +165,7 @@ int cg_attach_task(struct cgroup *cgroup);
 int cg_modify_cgroup(struct cgroup *cgroup);
 int cg_create_cgroup(struct cgroup *cgroup, int ignore_ownership);
 int cg_delete_cgroup(struct cgroup *cgroup, int ignore_migration);
+int cg_attach_task_pid(struct cgroup *cgroup, pid_t tid);
 
 __END_DECLS
 
index a820196f77530a7513723b9ccc3dc84839da59a6..b8df520b22aae0bfa3e65f0b0c87259b4c5952ac 100644 (file)
@@ -82,17 +82,14 @@ struct cgroup *cg::makenode(const string &name, const string &task_uid,
 
        dbg("tuid %d, tgid %d, cuid %d, cgid %d\n", tuid, tgid, cuid, cgid);
 
-       ccg->name = (char *)malloc(strlen(name.c_str()) + 1);
        strcpy(ccg->name, name.c_str());
        ccg->controller[0] = (struct controller *)
                                calloc(1, sizeof(struct controller));
-       ccg->controller[0]->name = (char *)malloc(strlen("cpu") + 1);
        strcpy(ccg->controller[0]->name,"cpu");
 
        ccg->controller[0]->values[0] = (struct control_value *)
                                        calloc(1, sizeof(struct control_value));
        strcpy(ccg->controller[0]->values[0]->name,"cpu.shares");
-       ccg->controller[0]->values[0]->value = (char *)malloc(strlen("100") + 1);
        strcpy(ccg->controller[0]->values[0]->value, "100");
        ccg->tasks_uid = tuid;
        ccg->tasks_gid = tgid;