| 169 | } |
| 170 | |
| 171 | void |
| 172 | cg_init(void) |
| 173 | { |
| 174 | if (!cg_enable) |
| 175 | return; |
| 176 | |
| 177 | if (strlen(cf_cg_root) > 5 && !memcmp(cf_cg_root, "auto:", 5)) |
| 178 | { |
| 179 | char *filename = cf_cg_root + 5; |
| 180 | FILE *f = fopen(filename, "r"); |
| 181 | if (!f) |
| 182 | die("Cannot open %s: %m", filename); |
| 183 | |
| 184 | char *line = NULL; |
| 185 | size_t len; |
| 186 | if (getline(&line, &len, f) < 0) |
| 187 | die("Cannot read from %s: %m", filename); |
| 188 | |
| 189 | char *sep = strchr(line, '\n'); |
| 190 | if (sep) |
| 191 | *sep = 0; |
| 192 | |
| 193 | fclose(f); |
| 194 | cf_cg_root = line; |
| 195 | } |
| 196 | |
| 197 | if (!dir_exists(cf_cg_root)) |
| 198 | die("Control group root %s does not exist", cf_cg_root); |
| 199 | |
| 200 | snprintf(cg_name, sizeof(cg_name), "box-%d", box_id); |
| 201 | |
| 202 | msg("Using control group %s under parent %s\n", cg_name, cf_cg_root); |
| 203 | } |
| 204 | |
| 205 | void |
| 206 | cg_create(void) |
no test coverage detected
searching dependent graphs…