Merge "Load kernel modules from /lib/modules/uname -r
_$(page_size) if present" into main am: d4e75d578b
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2717339 Change-Id: I9295551c587be853bb24741b6b8c8eaf79b29d64 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
41d7f15c4d
1 changed files with 20 additions and 0 deletions
|
@ -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>
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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…
Reference in a new issue