MCPcopy Create free account
hub / github.com/apache/mesos / mounted

Function mounted

src/linux/cgroups.cpp:670–711  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

668
669
670Try<bool> mounted(const string& hierarchy, const string& subsystems)
671{
672 if (!os::exists(hierarchy)) {
673 return false;
674 }
675
676 // We compare canonicalized absolute paths.
677 Result<string> realpath = os::realpath(hierarchy);
678 if (!realpath.isSome()) {
679 return Error(
680 "Failed to determine canonical path of '" + hierarchy + "': " +
681 (realpath.isError()
682 ? realpath.error()
683 : "No such file or directory"));
684 }
685
686 Try<set<string>> hierarchies = cgroups::hierarchies();
687 if (hierarchies.isError()) {
688 return Error(
689 "Failed to get mounted hierarchies: " + hierarchies.error());
690 }
691
692 if (hierarchies->count(realpath.get()) == 0) {
693 return false;
694 }
695
696 // Now make sure all the specified subsytems are attached.
697 Try<set<string>> attached = cgroups::subsystems(hierarchy);
698 if (attached.isError()) {
699 return Error(
700 "Failed to get subsystems attached to hierarchy '" +
701 hierarchy + "': " + attached.error());
702 }
703
704 foreach (const string& subsystem, strings::tokenize(subsystems, ",")) {
705 if (attached->count(subsystem) == 0) {
706 return false;
707 }
708 }
709
710 return true;
711}
712
713
714Try<Nothing> create(

Callers 6

foreachFunction · 0.85
foreachMethod · 0.85
TEST_FFunction · 0.85
verifyFunction · 0.85
foreachFunction · 0.85
cleanupFunction · 0.85

Calls 10

hierarchiesFunction · 0.85
subsystemsFunction · 0.85
existsFunction · 0.70
errorMethod · 0.65
realpathFunction · 0.50
ErrorFunction · 0.50
isSomeMethod · 0.45
isErrorMethod · 0.45
countMethod · 0.45
getMethod · 0.45

Tested by 3

foreachFunction · 0.68
foreachMethod · 0.68
TEST_FFunction · 0.68