Loading toolbox/modprobe.cpp +20 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ #include <ctype.h> #include <fcntl.h> #include <getopt.h> #include <stdlib.h> Loading @@ -27,6 +28,7 @@ #include <modprobe/modprobe.h> #include <sys/utsname.h> #include <unistd.h> namespace { Loading Loading @@ -105,6 +107,11 @@ static int KernelVersionNameFilter(const dirent* de) { return 0; } std::string GetPageSizeSuffix() { static const size_t page_size = sysconf(_SC_PAGE_SIZE); return android::base::StringPrintf("_%zuk", page_size / 1024); } } // anonymous namespace extern "C" int modprobe_main(int argc, char** argv) { Loading Loading @@ -233,6 +240,19 @@ extern "C" int modprobe_main(int argc, char** argv) { // Allow modules to be directly inside /lib/modules mod_dirs.emplace_back(LIB_MODULES_PREFIX); } if (getpagesize() != 4096) { struct utsname uts {}; if (uname(&uts)) { PLOG(FATAL) << "Failed to get kernel version"; } const auto module_dir = android::base::StringPrintf("/lib/modules/%s%s", uts.release, GetPageSizeSuffix().c_str()); struct stat st {}; if (stat(module_dir.c_str(), &st) == 0 && S_ISDIR(st.st_mode)) { mod_dirs.clear(); mod_dirs.emplace_back(module_dir); } } LOG(DEBUG) << "mode is " << mode; LOG(DEBUG) << "mod_dirs is: " << android::base::Join(mod_dirs, " "); Loading Loading
toolbox/modprobe.cpp +20 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ #include <ctype.h> #include <fcntl.h> #include <getopt.h> #include <stdlib.h> Loading @@ -27,6 +28,7 @@ #include <modprobe/modprobe.h> #include <sys/utsname.h> #include <unistd.h> namespace { Loading Loading @@ -105,6 +107,11 @@ static int KernelVersionNameFilter(const dirent* de) { return 0; } std::string GetPageSizeSuffix() { static const size_t page_size = sysconf(_SC_PAGE_SIZE); return android::base::StringPrintf("_%zuk", page_size / 1024); } } // anonymous namespace extern "C" int modprobe_main(int argc, char** argv) { Loading Loading @@ -233,6 +240,19 @@ extern "C" int modprobe_main(int argc, char** argv) { // Allow modules to be directly inside /lib/modules mod_dirs.emplace_back(LIB_MODULES_PREFIX); } if (getpagesize() != 4096) { struct utsname uts {}; if (uname(&uts)) { PLOG(FATAL) << "Failed to get kernel version"; } const auto module_dir = android::base::StringPrintf("/lib/modules/%s%s", uts.release, GetPageSizeSuffix().c_str()); struct stat st {}; if (stat(module_dir.c_str(), &st) == 0 && S_ISDIR(st.st_mode)) { mod_dirs.clear(); mod_dirs.emplace_back(module_dir); } } LOG(DEBUG) << "mode is " << mode; LOG(DEBUG) << "mod_dirs is: " << android::base::Join(mod_dirs, " "); Loading