libmodprobe: add strict bool argument to LoadListedModules

Continue loading remaining modules after error if strict flag false.

Test: libmodprobe_test
Bug: 141311820
Change-Id: Ib21d4eade1254b16621e7bf2c9efaa173092e7c7
This commit is contained in:
Mark Salyzyn 2019-10-29 09:32:09 -07:00
parent 4645210097
commit d478271b2b
2 changed files with 6 additions and 4 deletions

View File

@ -26,7 +26,7 @@ class Modprobe {
public:
Modprobe(const std::vector<std::string>&);
bool LoadListedModules();
bool LoadListedModules(bool strict = true);
bool LoadWithAliases(const std::string& module_name, bool strict,
const std::string& parameters = "");
bool Remove(const std::string& module_name);

View File

@ -360,13 +360,15 @@ bool Modprobe::LoadWithAliases(const std::string& module_name, bool strict,
return true;
}
bool Modprobe::LoadListedModules() {
bool Modprobe::LoadListedModules(bool strict) {
auto ret = true;
for (const auto& module : module_load_) {
if (!LoadWithAliases(module, true)) {
return false;
ret = false;
if (strict) break;
}
}
return true;
return ret;
}
bool Modprobe::Remove(const std::string& module_name) {