Lines Matching refs:buf
25 ssize_t read_text(const char *path, char *buf, size_t max_len) in read_text() argument
34 len = read(fd, buf, max_len - 1); in read_text()
37 buf[len] = 0; in read_text()
44 ssize_t write_text(const char *path, char *buf, ssize_t len) in write_text() argument
52 len = write(fd, buf, len); in write_text()
88 int cg_read(const char *cgroup, const char *control, char *buf, size_t len) in cg_read() argument
95 ret = read_text(path, buf, len); in cg_read()
103 char *buf; in cg_read_strcmp() local
112 buf = malloc(size); in cg_read_strcmp()
113 if (!buf) in cg_read_strcmp()
116 if (cg_read(cgroup, control, buf, size)) { in cg_read_strcmp()
117 free(buf); in cg_read_strcmp()
121 ret = strcmp(expected, buf); in cg_read_strcmp()
122 free(buf); in cg_read_strcmp()
128 char buf[PAGE_SIZE]; in cg_read_strstr() local
130 if (cg_read(cgroup, control, buf, sizeof(buf))) in cg_read_strstr()
133 return strstr(buf, needle) ? 0 : -1; in cg_read_strstr()
138 char buf[128]; in cg_read_long() local
140 if (cg_read(cgroup, control, buf, sizeof(buf))) in cg_read_long()
143 return atol(buf); in cg_read_long()
148 char buf[128]; in cg_read_long_fd() local
150 if (pread(fd, buf, sizeof(buf), 0) <= 0) in cg_read_long_fd()
153 return atol(buf); in cg_read_long_fd()
158 char buf[PAGE_SIZE]; in cg_read_key_long() local
161 if (cg_read(cgroup, control, buf, sizeof(buf))) in cg_read_key_long()
164 ptr = strstr(buf, key); in cg_read_key_long()
173 char buf[PAGE_SIZE]; in cg_read_lc() local
178 if (cg_read(cgroup, control, buf, sizeof(buf))) in cg_read_lc()
181 for (line = strtok(buf, delim); line; line = strtok(NULL, delim)) in cg_read_lc()
188 int cg_write(const char *cgroup, const char *control, char *buf) in cg_write() argument
191 ssize_t len = strlen(buf), ret; in cg_write()
194 ret = write_text(path, buf, len); in cg_write()
212 char buf[64]; in cg_write_numeric() local
215 ret = sprintf(buf, "%lu", value); in cg_write_numeric()
219 return cg_write(cgroup, control, buf); in cg_write_numeric()
225 char buf[10 * PAGE_SIZE]; in cg_find_root() local
229 if (read_text("/proc/self/mounts", buf, sizeof(buf)) <= 0) in cg_find_root()
236 for (fs = strtok(buf, delim); fs; fs = strtok(NULL, delim)) { in cg_find_root()
280 char buf[10 * PAGE_SIZE] = {0}; in cg_wait_for_proc_count() local
287 if (cg_read(cgroup, "cgroup.procs", buf, sizeof(buf))) in cg_wait_for_proc_count()
290 for (ptr = buf; *ptr; ptr++) in cg_wait_for_proc_count()
305 char buf[PAGE_SIZE]; in cg_killall() local
306 char *ptr = buf; in cg_killall()
312 if (cg_read(cgroup, "cgroup.procs", buf, sizeof(buf))) in cg_killall()
315 while (ptr < buf + sizeof(buf)) { in cg_killall()
379 char buf[64]; in cg_run() local
381 snprintf(buf, sizeof(buf), "%d", getpid()); in cg_run()
382 if (cg_write(cgroup, "cgroup.procs", buf)) in cg_run()
502 char buf[64]; in cg_run_nowait() local
504 snprintf(buf, sizeof(buf), "%d", getpid()); in cg_run_nowait()
505 if (cg_write(cgroup, "cgroup.procs", buf)) in cg_run_nowait()
515 char buf[4 * PAGE_SIZE]; in proc_mount_contains() local
518 read = read_text("/proc/mounts", buf, sizeof(buf)); in proc_mount_contains()
522 return strstr(buf, option) != NULL; in proc_mount_contains()
525 ssize_t proc_read_text(int pid, bool thread, const char *item, char *buf, size_t size) in proc_read_text() argument
536 ret = read_text(path, buf, size); in proc_read_text()
542 char buf[PAGE_SIZE]; in proc_read_strstr() local
544 if (proc_read_text(pid, thread, item, buf, sizeof(buf)) < 0) in proc_read_strstr()
547 return strstr(buf, needle) ? 0 : -1; in proc_read_strstr()