Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d032a92c authored by Suren Baghdasaryan's avatar Suren Baghdasaryan
Browse files

Fix cgroup support for recovery mode



In recovery mode a separate set of cgroups should be mounted. Add a
cgroups.recovery.json file to describe cgroups mounted during recovery.
Change cgroups descriptor parset to allow cgroups and cgroups2 sections
to be omitted.

Bug: 124270406
Test: "adb reboot sideload; adb devices" shows 'sideload' as expected

Change-Id: Ic32bd2b4612ec8390064f87d4655d1bd1183d741
Signed-off-by: default avatarSuren Baghdasaryan <surenb@google.com>
parent 612a6d6b
Loading
Loading
Loading
Loading
+19 −15
Original line number Diff line number Diff line
@@ -126,7 +126,8 @@ static bool ReadDescriptors(std::map<std::string, CgroupDescriptor>* descriptors
        return false;
    }

    Json::Value cgroups = root["Cgroups"];
    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(
@@ -135,13 +136,16 @@ static bool ReadDescriptors(std::map<std::string, CgroupDescriptor>* descriptors
                                     std::strtoul(cgroups[i]["Mode"].asString().c_str(), 0, 8),
                                     cgroups[i]["UID"].asString(), cgroups[i]["GID"].asString())));
        }
    }

    Json::Value cgroups2 = root["Cgroups2"];
    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;
}
+10 −0
Original line number Diff line number Diff line
@@ -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)
+9 −0
Original line number Diff line number Diff line
{
  "Cgroups": [
    {
      "Controller": "cpuacct",
      "Path": "/acct",
      "Mode": "0555"
    }
  ]
}