Lines Matching defs:cgroup
78 char *cg_control(const char *cgroup, const char *control)
80 size_t len = strlen(cgroup) + strlen(control) + 2;
83 snprintf(ret, len, "%s/%s", cgroup, control);
88 int cg_read(const char *cgroup, const char *control, char *buf, size_t len)
92 snprintf(path, sizeof(path), "%s/%s", cgroup, control);
100 int cg_read_strcmp(const char *cgroup, const char *control,
117 if (cg_read(cgroup, control, buf, size)) {
127 int cg_read_strstr(const char *cgroup, const char *control, const char *needle)
131 if (cg_read(cgroup, control, buf, sizeof(buf)))
137 long cg_read_long(const char *cgroup, const char *control)
141 if (cg_read(cgroup, control, buf, sizeof(buf)))
147 long cg_read_key_long(const char *cgroup, const char *control, const char *key)
152 if (cg_read(cgroup, control, buf, sizeof(buf)))
162 long cg_read_lc(const char *cgroup, const char *control)
169 if (cg_read(cgroup, control, buf, sizeof(buf)))
178 int cg_write(const char *cgroup, const char *control, char *buf)
183 snprintf(path, sizeof(path), "%s/%s", cgroup, control);
202 * cgroup /sys/fs/cgroup cgroup2 rw,seclabel,noexec,relatime 0 0
220 int cg_create(const char *cgroup)
222 return mkdir(cgroup, 0755);
225 int cg_wait_for_proc_count(const char *cgroup, int count)
234 if (cg_read(cgroup, "cgroup.procs", buf, sizeof(buf)))
250 int cg_killall(const char *cgroup)
255 if (cg_read(cgroup, "cgroup.procs", buf, sizeof(buf)))
274 int cg_destroy(const char *cgroup)
279 ret = rmdir(cgroup);
281 cg_killall(cgroup);
292 int cg_enter(const char *cgroup, int pid)
297 return cg_write(cgroup, "cgroup.procs", pidbuf);
300 int cg_enter_current(const char *cgroup)
302 return cg_write(cgroup, "cgroup.procs", "0");
305 int cg_enter_current_thread(const char *cgroup)
307 return cg_write(cgroup, "cgroup.threads", "0");
310 int cg_run(const char *cgroup,
311 int (*fn)(const char *cgroup, void *arg),
323 if (cg_write(cgroup, "cgroup.procs", buf))
325 exit(fn(cgroup, arg));
343 .cgroup = cgroup_fd,
408 static int clone_into_cgroup_run_nowait(const char *cgroup,
409 int (*fn)(const char *cgroup, void *arg),
415 cgroup_fd = dirfd_open_opath(cgroup);
422 exit(fn(cgroup, arg));
427 int cg_run_nowait(const char *cgroup,
428 int (*fn)(const char *cgroup, void *arg),
433 pid = clone_into_cgroup_run_nowait(cgroup, fn, arg);
446 if (cg_write(cgroup, "cgroup.procs", buf))
448 exit(fn(cgroup, arg));
482 int alloc_anon(const char *cgroup, void *arg)
555 int clone_into_cgroup_run_wait(const char *cgroup)
560 cgroup_fd = dirfd_open_opath(cgroup);