Merge "Fix cgroup support for recovery mode"

This commit is contained in:
Suren Baghdasaryan 2019-02-14 18:08:40 +00:00 committed by Gerrit Code Review
commit da20bc763e
3 changed files with 37 additions and 14 deletions

View file

@ -126,22 +126,26 @@ static bool ReadDescriptors(std::map<std::string, CgroupDescriptor>* descriptors
return false;
}
Json::Value cgroups = root["Cgroups"];
for (Json::Value::ArrayIndex i = 0; i < cgroups.size(); ++i) {
std::string name = cgroups[i]["Controller"].asString();
descriptors->emplace(std::make_pair(
name,
CgroupDescriptor(1, name, cgroups[i]["Path"].asString(),
std::strtoul(cgroups[i]["Mode"].asString().c_str(), 0, 8),
cgroups[i]["UID"].asString(), cgroups[i]["GID"].asString())));
if (root.isMember("Cgroups")) {
const Json::Value& cgroups = root["Cgroups"];
for (Json::Value::ArrayIndex i = 0; i < cgroups.size(); ++i) {
std::string name = cgroups[i]["Controller"].asString();
descriptors->emplace(std::make_pair(
name,
CgroupDescriptor(1, name, cgroups[i]["Path"].asString(),
std::strtoul(cgroups[i]["Mode"].asString().c_str(), 0, 8),
cgroups[i]["UID"].asString(), cgroups[i]["GID"].asString())));
}
}
Json::Value cgroups2 = root["Cgroups2"];
descriptors->emplace(std::make_pair(
CGROUPV2_CONTROLLER_NAME,
CgroupDescriptor(2, CGROUPV2_CONTROLLER_NAME, cgroups2["Path"].asString(),
std::strtoul(cgroups2["Mode"].asString().c_str(), 0, 8),
cgroups2["UID"].asString(), cgroups2["GID"].asString())));
if (root.isMember("Cgroups2")) {
const Json::Value& cgroups2 = root["Cgroups2"];
descriptors->emplace(std::make_pair(
CGROUPV2_CONTROLLER_NAME,
CgroupDescriptor(2, CGROUPV2_CONTROLLER_NAME, cgroups2["Path"].asString(),
std::strtoul(cgroups2["Mode"].asString().c_str(), 0, 8),
cgroups2["UID"].asString(), cgroups2["GID"].asString())));
}
return true;
}

View file

@ -74,6 +74,16 @@ LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)
include $(BUILD_PREBUILT)
#######################################
# cgroups.json for recovery
include $(CLEAR_VARS)
LOCAL_MODULE := cgroups.recovery.json
LOCAL_SRC_FILES := $(LOCAL_MODULE)
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/etc
LOCAL_MODULE_STEM := cgroups.json
include $(BUILD_PREBUILT)
#######################################
# task_profiles.json
include $(CLEAR_VARS)

View file

@ -0,0 +1,9 @@
{
"Cgroups": [
{
"Controller": "cpuacct",
"Path": "/acct",
"Mode": "0555"
}
]
}