Lines Matching refs:cgroup
80 char *cg_control(const char *cgroup, const char *control) in cg_control() argument
82 size_t len = strlen(cgroup) + strlen(control) + 2; in cg_control()
85 snprintf(ret, len, "%s/%s", cgroup, control); in cg_control()
90 int cg_read(const char *cgroup, const char *control, char *buf, size_t len) in cg_read() argument
94 snprintf(path, sizeof(path), "%s/%s", cgroup, control); in cg_read()
102 int cg_read_strcmp(const char *cgroup, const char *control, in cg_read_strcmp() argument
119 if (cg_read(cgroup, control, buf, size)) { in cg_read_strcmp()
129 int cg_read_strstr(const char *cgroup, const char *control, const char *needle) in cg_read_strstr() argument
133 if (cg_read(cgroup, control, buf, sizeof(buf))) in cg_read_strstr()
139 long cg_read_long(const char *cgroup, const char *control) in cg_read_long() argument
143 if (cg_read(cgroup, control, buf, sizeof(buf))) in cg_read_long()
149 long cg_read_key_long(const char *cgroup, const char *control, const char *key) in cg_read_key_long() argument
154 if (cg_read(cgroup, control, buf, sizeof(buf))) in cg_read_key_long()
164 long cg_read_lc(const char *cgroup, const char *control) in cg_read_lc() argument
171 if (cg_read(cgroup, control, buf, sizeof(buf))) in cg_read_lc()
180 int cg_write(const char *cgroup, const char *control, char *buf) in cg_write() argument
185 snprintf(path, sizeof(path), "%s/%s", cgroup, control); in cg_write()
222 int cg_create(const char *cgroup) in cg_create() argument
224 return mkdir(cgroup, 0755); in cg_create()
227 int cg_wait_for_proc_count(const char *cgroup, int count) in cg_wait_for_proc_count() argument
236 if (cg_read(cgroup, "cgroup.procs", buf, sizeof(buf))) in cg_wait_for_proc_count()
252 int cg_killall(const char *cgroup) in cg_killall() argument
258 if (!cg_write(cgroup, "cgroup.kill", "1")) in cg_killall()
261 if (cg_read(cgroup, "cgroup.procs", buf, sizeof(buf))) in cg_killall()
280 int cg_destroy(const char *cgroup) in cg_destroy() argument
285 ret = rmdir(cgroup); in cg_destroy()
287 cg_killall(cgroup); in cg_destroy()
298 int cg_enter(const char *cgroup, int pid) in cg_enter() argument
303 return cg_write(cgroup, "cgroup.procs", pidbuf); in cg_enter()
306 int cg_enter_current(const char *cgroup) in cg_enter_current() argument
308 return cg_write(cgroup, "cgroup.procs", "0"); in cg_enter_current()
311 int cg_enter_current_thread(const char *cgroup) in cg_enter_current_thread() argument
313 return cg_write(cgroup, "cgroup.threads", "0"); in cg_enter_current_thread()
316 int cg_run(const char *cgroup, in cg_run() argument
317 int (*fn)(const char *cgroup, void *arg), in cg_run() argument
329 if (cg_write(cgroup, "cgroup.procs", buf)) in cg_run()
331 exit(fn(cgroup, arg)); in cg_run()
349 .cgroup = cgroup_fd, in clone_into_cgroup()
414 static int clone_into_cgroup_run_nowait(const char *cgroup, in clone_into_cgroup_run_nowait() argument
415 int (*fn)(const char *cgroup, void *arg), in clone_into_cgroup_run_nowait() argument
421 cgroup_fd = dirfd_open_opath(cgroup); in clone_into_cgroup_run_nowait()
428 exit(fn(cgroup, arg)); in clone_into_cgroup_run_nowait()
433 int cg_run_nowait(const char *cgroup, in cg_run_nowait() argument
434 int (*fn)(const char *cgroup, void *arg), in cg_run_nowait() argument
439 pid = clone_into_cgroup_run_nowait(cgroup, fn, arg); in cg_run_nowait()
452 if (cg_write(cgroup, "cgroup.procs", buf)) in cg_run_nowait()
454 exit(fn(cgroup, arg)); in cg_run_nowait()
488 int alloc_anon(const char *cgroup, void *arg) in alloc_anon() argument
561 int clone_into_cgroup_run_wait(const char *cgroup) in clone_into_cgroup_run_wait() argument
566 cgroup_fd = dirfd_open_opath(cgroup); in clone_into_cgroup_run_wait()
586 int cg_prepare_for_wait(const char *cgroup) in cg_prepare_for_wait() argument
594 ret = inotify_add_watch(fd, cg_control(cgroup, "cgroup.events"), in cg_prepare_for_wait()