- /* Ignore the header line */
- (void) fgets(buf, sizeof(buf), f);
-
- for (;;) {
- char *controller;
- int enabled = 0;
-
- if (fscanf(f, "%ms %*i %*i %i", &controller, &enabled) != 2) {
-
- if (feof(f))
- break;
-
- log_error("Failed to parse /proc/cgroups.");
- return -EIO;
- }
-
- if (!enabled) {
- free(controller);
- continue;
- }
-
- r = set_consume(controllers, controller);
- if (r < 0) {
- log_error("Failed to add controller to set.");
- return r;
- }
- }
+ r = cg_kernel_controllers(controllers);
+ if (r < 0)
+ return log_error_errno(r, "Failed to enumerate cgroup controllers: %m");