Loading init/first_stage_init.cpp +20 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ #include <android-base/chrono_utils.h> #include <android-base/file.h> #include <android-base/logging.h> #include <android-base/stringprintf.h> #include <modprobe/modprobe.h> #include <private/android_filesystem_config.h> Loading Loading @@ -153,6 +154,15 @@ void PrepareSwitchRoot() { Copy(snapuserd, dst); } } std::string GetPageSizeSuffix() { static const size_t page_size = sysconf(_SC_PAGE_SIZE); if (page_size <= 4096) { return ""; } return android::base::StringPrintf("_%zuk", page_size / 1024); } } // namespace std::string GetModuleLoadList(BootMode boot_mode, const std::string& dir_path) { Loading Loading @@ -201,10 +211,18 @@ bool LoadKernelModules(BootMode boot_mode, bool want_console, bool want_parallel } dirent* entry = nullptr; std::vector<std::string> module_dirs; const std::string release_specific_module_dir = uts.release + GetPageSizeSuffix(); while ((entry = readdir(base_dir.get()))) { if (entry->d_type != DT_DIR) { continue; } if (entry->d_name == release_specific_module_dir) { LOG(INFO) << "Release specific kernel module dir " << release_specific_module_dir << " found, loading modules from here with no fallbacks."; module_dirs.clear(); module_dirs.emplace_back(entry->d_name); break; } int dir_major = 0, dir_minor = 0; if (sscanf(entry->d_name, "%d.%d", &dir_major, &dir_minor) != 2 || dir_major != major || dir_minor != minor) { Loading @@ -228,6 +246,7 @@ bool LoadKernelModules(BootMode boot_mode, bool want_console, bool want_parallel bool retval = m.LoadListedModules(!want_console); modules_loaded = m.GetModuleCount(); if (modules_loaded > 0) { LOG(INFO) << "Loaded " << modules_loaded << " modules from " << dir_path; return retval; } } Loading @@ -237,6 +256,7 @@ bool LoadKernelModules(BootMode boot_mode, bool want_console, bool want_parallel : m.LoadListedModules(!want_console); modules_loaded = m.GetModuleCount(); if (modules_loaded > 0) { LOG(INFO) << "Loaded " << modules_loaded << " modules from " << MODULE_BASE_DIR; return retval; } return true; Loading Loading
init/first_stage_init.cpp +20 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ #include <android-base/chrono_utils.h> #include <android-base/file.h> #include <android-base/logging.h> #include <android-base/stringprintf.h> #include <modprobe/modprobe.h> #include <private/android_filesystem_config.h> Loading Loading @@ -153,6 +154,15 @@ void PrepareSwitchRoot() { Copy(snapuserd, dst); } } std::string GetPageSizeSuffix() { static const size_t page_size = sysconf(_SC_PAGE_SIZE); if (page_size <= 4096) { return ""; } return android::base::StringPrintf("_%zuk", page_size / 1024); } } // namespace std::string GetModuleLoadList(BootMode boot_mode, const std::string& dir_path) { Loading Loading @@ -201,10 +211,18 @@ bool LoadKernelModules(BootMode boot_mode, bool want_console, bool want_parallel } dirent* entry = nullptr; std::vector<std::string> module_dirs; const std::string release_specific_module_dir = uts.release + GetPageSizeSuffix(); while ((entry = readdir(base_dir.get()))) { if (entry->d_type != DT_DIR) { continue; } if (entry->d_name == release_specific_module_dir) { LOG(INFO) << "Release specific kernel module dir " << release_specific_module_dir << " found, loading modules from here with no fallbacks."; module_dirs.clear(); module_dirs.emplace_back(entry->d_name); break; } int dir_major = 0, dir_minor = 0; if (sscanf(entry->d_name, "%d.%d", &dir_major, &dir_minor) != 2 || dir_major != major || dir_minor != minor) { Loading @@ -228,6 +246,7 @@ bool LoadKernelModules(BootMode boot_mode, bool want_console, bool want_parallel bool retval = m.LoadListedModules(!want_console); modules_loaded = m.GetModuleCount(); if (modules_loaded > 0) { LOG(INFO) << "Loaded " << modules_loaded << " modules from " << dir_path; return retval; } } Loading @@ -237,6 +256,7 @@ bool LoadKernelModules(BootMode boot_mode, bool want_console, bool want_parallel : m.LoadListedModules(!want_console); modules_loaded = m.GetModuleCount(); if (modules_loaded > 0) { LOG(INFO) << "Loaded " << modules_loaded << " modules from " << MODULE_BASE_DIR; return retval; } return true; Loading