summaryrefslogtreecommitdiff
path: root/libmodprobe/libmodprobe_ext_test.cpp
diff options
context:
space:
mode:
authorSteve Muckle <smuckle@google.com>2019-07-30 11:58:11 -0700
committerSteve Muckle <smuckle@google.com>2019-08-06 13:58:13 -0700
commitbb58b0157454ad4f066f098977e37d0494312bae (patch)
treee9295a610fedca5e2593b7d473dd7b36bf8911da /libmodprobe/libmodprobe_ext_test.cpp
parent73b2928b9400ce679a1482fc072be9fa55d7a8cd (diff)
libmodprobe: add support to remove modules
Add a remove method which will unload a given module from the kernel, along with any modules it depended on, assuming those modules are now unused. Change-Id: Ie66dc153ef1771f50e26421d38d3656e95954780
Diffstat (limited to 'libmodprobe/libmodprobe_ext_test.cpp')
-rw-r--r--libmodprobe/libmodprobe_ext_test.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/libmodprobe/libmodprobe_ext_test.cpp b/libmodprobe/libmodprobe_ext_test.cpp
index 0f073cb5c..ca1c081c8 100644
--- a/libmodprobe/libmodprobe_ext_test.cpp
+++ b/libmodprobe/libmodprobe_ext_test.cpp
@@ -51,6 +51,16 @@ bool Modprobe::Insmod(const std::string& path_name) {
return true;
}
+bool Modprobe::Rmmod(const std::string& module_name) {
+ for (auto it = modules_loaded.begin(); it != modules_loaded.end(); it++) {
+ if (*it == module_name) {
+ modules_loaded.erase(it);
+ return true;
+ }
+ }
+ return false;
+}
+
bool Modprobe::ModuleExists(const std::string& module_name) {
auto deps = GetDependencies(module_name);
if (deps.empty()) {