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);
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;
*
* 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;
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);
}
#include <linux/types.h>
#include <stdio.h>
#include <sys/stat.h>
+#include <unistd.h>
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#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;
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
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;