diff --git a/libmodprobe/include/modprobe/modprobe.h b/libmodprobe/include/modprobe/modprobe.h index 0599ec538..dcb4ffbef 100644 --- a/libmodprobe/include/modprobe/modprobe.h +++ b/libmodprobe/include/modprobe/modprobe.h @@ -34,6 +34,7 @@ class Modprobe { std::vector* dependencies, std::vector* post_dependencies); void EnableBlacklist(bool enable); + void EnableVerbose(bool enable); private: std::string MakeCanonical(const std::string& module_path); diff --git a/libmodprobe/libmodprobe.cpp b/libmodprobe/libmodprobe.cpp index 3e9001a0e..73ae15b07 100644 --- a/libmodprobe/libmodprobe.cpp +++ b/libmodprobe/libmodprobe.cpp @@ -260,12 +260,22 @@ Modprobe::Modprobe(const std::vector& base_paths) { auto blacklist_callback = std::bind(&Modprobe::ParseBlacklistCallback, this, _1); ParseCfg(base_path + "/modules.blacklist", blacklist_callback); } + + android::base::SetMinimumLogSeverity(android::base::INFO); } void Modprobe::EnableBlacklist(bool enable) { blacklist_enabled = enable; } +void Modprobe::EnableVerbose(bool enable) { + if (enable) { + android::base::SetMinimumLogSeverity(android::base::VERBOSE); + } else { + android::base::SetMinimumLogSeverity(android::base::INFO); + } +} + std::vector Modprobe::GetDependencies(const std::string& module) { auto it = module_deps_.find(module); if (it == module_deps_.end()) { @@ -288,6 +298,7 @@ bool Modprobe::InsmodWithDeps(const std::string& module_name, const std::string& // load module dependencies in reverse order for (auto dep = dependencies.rbegin(); dep != dependencies.rend() - 1; ++dep) { + LOG(VERBOSE) << "Loading hard dep for '" << module_name << "': " << *dep; if (!LoadWithAliases(*dep, true)) { return false; } @@ -296,6 +307,7 @@ bool Modprobe::InsmodWithDeps(const std::string& module_name, const std::string& // try to load soft pre-dependencies for (const auto& [module, softdep] : module_pre_softdep_) { if (module_name == module) { + LOG(VERBOSE) << "Loading soft pre-dep for '" << module << "': " << softdep; LoadWithAliases(softdep, false); } } @@ -308,6 +320,7 @@ bool Modprobe::InsmodWithDeps(const std::string& module_name, const std::string& // try to load soft post-dependencies for (const auto& [module, softdep] : module_post_softdep_) { if (module_name == module) { + LOG(VERBOSE) << "Loading soft post-dep for '" << module << "': " << softdep; LoadWithAliases(softdep, false); } } @@ -324,6 +337,7 @@ bool Modprobe::LoadWithAliases(const std::string& module_name, bool strict, // may alias themselves to the requested name) for (const auto& [alias, aliased_module] : module_aliases_) { if (fnmatch(alias.c_str(), module_name.c_str(), 0) != 0) continue; + LOG(VERBOSE) << "Found alias for '" << module_name << "': '" << aliased_module; modules_to_load.emplace(aliased_module); } @@ -334,7 +348,7 @@ bool Modprobe::LoadWithAliases(const std::string& module_name, bool strict, } if (strict && !module_loaded) { - LOG(ERROR) << "LoadWithAliases did not find a module for " << module_name; + LOG(ERROR) << "LoadWithAliases was unable to load " << module_name; return false; } return true; diff --git a/libmodprobe/libmodprobe_ext.cpp b/libmodprobe/libmodprobe_ext.cpp index 3e9ff70cb..2efcac290 100644 --- a/libmodprobe/libmodprobe_ext.cpp +++ b/libmodprobe/libmodprobe_ext.cpp @@ -66,6 +66,7 @@ bool Modprobe::Rmmod(const std::string& module_name) { bool Modprobe::ModuleExists(const std::string& module_name) { struct stat fileStat; if (blacklist_enabled && module_blacklist_.count(module_name)) { + LOG(INFO) << "module " << module_name << " is blacklisted"; return false; } auto deps = GetDependencies(module_name); @@ -74,9 +75,11 @@ bool Modprobe::ModuleExists(const std::string& module_name) { return false; } if (stat(deps.front().c_str(), &fileStat)) { + LOG(INFO) << "module " << module_name << " does not exist"; return false; } if (!S_ISREG(fileStat.st_mode)) { + LOG(INFO) << "module " << module_name << " is not a regular file"; return false; } return true;