diff options
author | Steve Muckle <smuckle@google.com> | 2019-07-30 11:58:11 -0700 |
---|---|---|
committer | Steve Muckle <smuckle@google.com> | 2019-08-06 13:58:13 -0700 |
commit | bb58b0157454ad4f066f098977e37d0494312bae (patch) | |
tree | e9295a610fedca5e2593b7d473dd7b36bf8911da /libmodprobe/libmodprobe_ext.cpp | |
parent | 73b2928b9400ce679a1482fc072be9fa55d7a8cd (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.cpp')
-rw-r--r-- | libmodprobe/libmodprobe_ext.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libmodprobe/libmodprobe_ext.cpp b/libmodprobe/libmodprobe_ext.cpp index 5f3a04da8..8cbd08c5a 100644 --- a/libmodprobe/libmodprobe_ext.cpp +++ b/libmodprobe/libmodprobe_ext.cpp @@ -51,6 +51,15 @@ bool Modprobe::Insmod(const std::string& path_name) { return true; } +bool Modprobe::Rmmod(const std::string& module_name) { + int ret = syscall(__NR_delete_module, MakeCanonical(module_name).c_str(), O_NONBLOCK); + if (ret != 0) { + PLOG(ERROR) << "Failed to remove module '" << module_name << "'"; + return false; + } + return true; +} + bool Modprobe::ModuleExists(const std::string& module_name) { struct stat fileStat; auto deps = GetDependencies(module_name); |