kernel cmdline

從 lk 傳送到 kerel 的 cmdline 會放在開機後的
adb
/proc/cmdline

開到 android 後,又會被讀出來

/system/core/init/util.cpp

275void import_kernel_cmdline(bool in_qemu,
276                           const std::function<void(const std::string&, const std::string&, bool)>& fn) {
277    std::string cmdline;
278    android::base::ReadFileToString("/proc/cmdline", &cmdline);
279
280    for (const auto& entry : android::base::Split(android::base::Trim(cmdline), " ")) {
281        std::vector<std::string> pieces = android::base::Split(entry, "=");
282        if (pieces.size() == 2) {
283            fn(pieces[0], pieces[1], in_qemu);
284        }
285    }
286}

/system/core/init/init.cpp

391static void import_kernel_nv(const std::string& key, const std::string& value, bool for_emulator) {
392    if (key.empty()) return;
393
394    if (for_emulator) {
395        // In the emulator, export any kernel option with the "ro.kernel." prefix.
396        property_set(android::base::StringPrintf("ro.kernel.%s", key.c_str()).c_str(), value.c_str());
397        return;
398    }
399
400    if (key == "qemu") {
401        strlcpy(qemu, value.c_str(), sizeof(qemu));
402    } else if (android::base::StartsWith(key, "androidboot.")) {
403        property_set(android::base::StringPrintf("ro.boot.%s", key.c_str() + 12).c_str(),
404                     value.c_str());
405    }
406}
posted @ 2017-09-27 18:15  wangchangruei  阅读(605)  评论(0编辑  收藏  举报