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

Commit 7c98b898 authored by Devin Moore's avatar Devin Moore Committed by Gerrit Code Review
Browse files

Merge changes from topic "bootconfig_args"

* changes:
  fs_mgr: handle more bootconfig parameters
  init: handle more bootconfig parameters
parents fcb28f5d 20b74257
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2203,7 +2203,8 @@ std::string fs_mgr_get_super_partition_name(int slot) {
    // Devices upgrading to dynamic partitions are allowed to specify a super
    // partition name. This includes cuttlefish, which is a non-A/B device.
    std::string super_partition;
    if (fs_mgr_get_boot_config_from_kernel_cmdline("super_partition", &super_partition)) {
    if (fs_mgr_get_boot_config_from_bootconfig_source("super_partition", &super_partition) ||
        fs_mgr_get_boot_config_from_kernel_cmdline("super_partition", &super_partition)) {
        if (fs_mgr_get_slot_suffix().empty()) {
            return super_partition;
        }
+16 −2
Original line number Diff line number Diff line
@@ -299,7 +299,8 @@ void ParseFsMgrFlags(const std::string& flags, FstabEntry* entry) {
std::string InitAndroidDtDir() {
    std::string android_dt_dir;
    // The platform may specify a custom Android DT path in kernel cmdline
    if (!fs_mgr_get_boot_config_from_kernel_cmdline("android_dt_dir", &android_dt_dir)) {
    if (!fs_mgr_get_boot_config_from_bootconfig_source("android_dt_dir", &android_dt_dir) &&
        !fs_mgr_get_boot_config_from_kernel_cmdline("android_dt_dir", &android_dt_dir)) {
        // Fall back to the standard procfs-based path
        android_dt_dir = kDefaultAndroidDtDir;
    }
@@ -842,9 +843,22 @@ std::vector<FstabEntry*> GetEntriesForMountPoint(Fstab* fstab, const std::string
}

std::set<std::string> GetBootDevices() {
    // First check the kernel commandline, then try the device tree otherwise
    // First check bootconfig, then kernel commandline, then the device tree
    std::string dt_file_name = get_android_dt_dir() + "/boot_devices";
    std::string value;
    if (fs_mgr_get_boot_config_from_bootconfig_source("boot_devices", &value) ||
        fs_mgr_get_boot_config_from_bootconfig_source("boot_device", &value)) {
        std::set<std::string> boot_devices;
        // remove quotes and split by spaces
        auto boot_device_strings = base::Split(base::StringReplace(value, "\"", "", true), " ");
        for (std::string_view device : boot_device_strings) {
            // trim the trailing comma, keep the rest.
            base::ConsumeSuffix(&device, ",");
            boot_devices.emplace(device);
        }
        return boot_devices;
    }

    if (fs_mgr_get_boot_config_from_kernel_cmdline("boot_devices", &value) ||
        ReadDtFile(dt_file_name, &value)) {
        auto boot_devices = Split(value, ",");
+2 −0
Original line number Diff line number Diff line
@@ -121,6 +121,7 @@ const std::vector<std::pair<std::string, std::string>> result_space = {

const std::string bootconfig =
        "androidboot.bootdevice  = \" \"1d84000.ufshc\"\n"
        "androidboot.boot_devices = \"dev1\", \"dev2,withcomma\", \"dev3\"\n"
        "androidboot.baseband = \"sdy\"\n"
        "androidboot.keymaster = \"1\"\n"
        "androidboot.serialno = \"BLAHBLAHBLAH\"\n"
@@ -152,6 +153,7 @@ const std::string bootconfig =

const std::vector<std::pair<std::string, std::string>> bootconfig_result_space = {
        {"androidboot.bootdevice", "1d84000.ufshc"},
        {"androidboot.boot_devices", "dev1, dev2,withcomma, dev3"},
        {"androidboot.baseband", "sdy"},
        {"androidboot.keymaster", "1"},
        {"androidboot.serialno", "BLAHBLAHBLAH"},
+14 −2
Original line number Diff line number Diff line
@@ -105,8 +105,20 @@ void StartConsole(const std::string& cmdline) {
    _exit(127);
}

int FirstStageConsole(const std::string& cmdline) {
    auto pos = cmdline.find("androidboot.first_stage_console=");
int FirstStageConsole(const std::string& cmdline, const std::string& bootconfig) {
    auto pos = bootconfig.find("androidboot.first_stage_console =");
    if (pos != std::string::npos) {
        int val = 0;
        if (sscanf(bootconfig.c_str() + pos, "androidboot.first_stage_console = \"%d\"", &val) !=
            1) {
            return FirstStageConsoleParam::DISABLED;
        }
        if (val <= FirstStageConsoleParam::MAX_PARAM_VALUE && val >= 0) {
            return val;
        }
    }

    pos = cmdline.find("androidboot.first_stage_console=");
    if (pos != std::string::npos) {
        int val = 0;
        if (sscanf(cmdline.c_str() + pos, "androidboot.first_stage_console=%d", &val) != 1) {
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ enum FirstStageConsoleParam {
};

void StartConsole(const std::string& cmdline);
int FirstStageConsole(const std::string& cmdline);
int FirstStageConsole(const std::string& cmdline, const std::string& bootconfig);

}  // namespace init
}  // namespace android
Loading