| 471 | |
| 472 | |
| 473 | Result<string> hierarchy(const string& subsystems) |
| 474 | { |
| 475 | Result<string> hierarchy = None(); |
| 476 | Try<set<string>> hierarchies = cgroups::hierarchies(); |
| 477 | if (hierarchies.isError()) { |
| 478 | return Error(hierarchies.error()); |
| 479 | } |
| 480 | |
| 481 | foreach (const string& candidate, hierarchies.get()) { |
| 482 | if (subsystems.empty()) { |
| 483 | hierarchy = candidate; |
| 484 | break; |
| 485 | } |
| 486 | |
| 487 | // Check and see if this candidate meets our subsystem requirements. |
| 488 | Try<bool> mounted = cgroups::mounted(candidate, subsystems); |
| 489 | if (mounted.isError()) { |
| 490 | return Error(mounted.error()); |
| 491 | } else if (mounted.get()) { |
| 492 | hierarchy = candidate; |
| 493 | break; |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | return hierarchy; |
| 498 | } |
| 499 | |
| 500 | |
| 501 | Try<bool> enabled(const string& subsystems) |