summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api.c19
-rw-r--r--libcg.h9
-rw-r--r--tests/libcg_ba.cpp3
3 files changed, 22 insertions, 9 deletions
diff --git a/api.c b/api.c
index 9f144a3..b154de1 100644
--- 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 88f5a45..7dfe9a4 100644
--- 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
diff --git a/tests/libcg_ba.cpp b/tests/libcg_ba.cpp
index a820196..b8df520 100644
--- a/tests/libcg_ba.cpp
+++ b/tests/libcg_ba.cpp
@@ -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;