diff options
Diffstat (limited to 'libmodprobe/libmodprobe_ext.cpp')
-rw-r--r-- | libmodprobe/libmodprobe_ext.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libmodprobe/libmodprobe_ext.cpp b/libmodprobe/libmodprobe_ext.cpp index 2efcac290..8bebe4c9f 100644 --- a/libmodprobe/libmodprobe_ext.cpp +++ b/libmodprobe/libmodprobe_ext.cpp @@ -30,8 +30,9 @@ bool Modprobe::Insmod(const std::string& path_name, const std::string& parameter return false; } + auto canonical_name = MakeCanonical(path_name); std::string options = ""; - auto options_iter = module_options_.find(MakeCanonical(path_name)); + auto options_iter = module_options_.find(canonical_name); if (options_iter != module_options_.end()) { options = options_iter->second; } @@ -44,6 +45,7 @@ bool Modprobe::Insmod(const std::string& path_name, const std::string& parameter if (ret != 0) { if (errno == EEXIST) { // Module already loaded + module_loaded_.emplace(canonical_name); return true; } LOG(ERROR) << "Failed to insmod '" << path_name << "' with args '" << options << "'"; @@ -51,15 +53,18 @@ bool Modprobe::Insmod(const std::string& path_name, const std::string& parameter } LOG(INFO) << "Loaded kernel module " << path_name; + module_loaded_.emplace(canonical_name); return true; } bool Modprobe::Rmmod(const std::string& module_name) { - int ret = syscall(__NR_delete_module, MakeCanonical(module_name).c_str(), O_NONBLOCK); + auto canonical_name = MakeCanonical(module_name); + int ret = syscall(__NR_delete_module, canonical_name.c_str(), O_NONBLOCK); if (ret != 0) { PLOG(ERROR) << "Failed to remove module '" << module_name << "'"; return false; } + module_loaded_.erase(canonical_name); return true; } |