diff options
author | Mark Salyzyn <salyzyn@google.com> | 2020-06-15 11:51:59 -0700 |
---|---|---|
committer | Mark Salyzyn <salyzyn@google.com> | 2020-06-15 12:51:38 -0700 |
commit | 703fb74fb5d7b806f188f2814f8dd770add26eeb (patch) | |
tree | 516a2719ec342905b0e5a2dc70cf20069146e8e8 /libmodprobe | |
parent | 9287716a1c7fe375a4c6031e6e31d98501bfdebd (diff) | |
download | core-703fb74fb5d7b806f188f2814f8dd770add26eeb.tar.gz |
modprobe: Use more inclusive language for modprobe and libmodprobe
blacklist is replaced with blocklist.
Test: none
Change-Id: I59f9fde5900b9aee82aca1eab4a6ded3d136063b
Diffstat (limited to 'libmodprobe')
-rw-r--r-- | libmodprobe/include/modprobe/modprobe.h | 8 | ||||
-rw-r--r-- | libmodprobe/libmodprobe.cpp | 21 | ||||
-rw-r--r-- | libmodprobe/libmodprobe_ext.cpp | 4 | ||||
-rw-r--r-- | libmodprobe/libmodprobe_ext_test.cpp | 2 | ||||
-rw-r--r-- | libmodprobe/libmodprobe_test.cpp | 10 |
5 files changed, 24 insertions, 21 deletions
diff --git a/libmodprobe/include/modprobe/modprobe.h b/libmodprobe/include/modprobe/modprobe.h index a7687af16..4806b08b4 100644 --- a/libmodprobe/include/modprobe/modprobe.h +++ b/libmodprobe/include/modprobe/modprobe.h @@ -36,7 +36,7 @@ class Modprobe { std::vector<std::string>* post_dependencies); void ResetModuleCount() { module_count_ = 0; } int GetModuleCount() { return module_count_; } - void EnableBlacklist(bool enable); + void EnableBlocklist(bool enable); void EnableVerbose(bool enable); private: @@ -55,7 +55,7 @@ class Modprobe { bool ParseSoftdepCallback(const std::vector<std::string>& args); bool ParseLoadCallback(const std::vector<std::string>& args); bool ParseOptionsCallback(const std::vector<std::string>& args); - bool ParseBlacklistCallback(const std::vector<std::string>& args); + bool ParseBlocklistCallback(const std::vector<std::string>& args); void ParseKernelCmdlineOptions(); void ParseCfg(const std::string& cfg, std::function<bool(const std::vector<std::string>&)> f); @@ -65,8 +65,8 @@ class Modprobe { std::vector<std::pair<std::string, std::string>> module_post_softdep_; std::vector<std::string> module_load_; std::unordered_map<std::string, std::string> module_options_; - std::set<std::string> module_blacklist_; + std::set<std::string> module_blocklist_; std::unordered_set<std::string> module_loaded_; int module_count_ = 0; - bool blacklist_enabled = false; + bool blocklist_enabled = false; }; diff --git a/libmodprobe/libmodprobe.cpp b/libmodprobe/libmodprobe.cpp index d19379676..07504c158 100644 --- a/libmodprobe/libmodprobe.cpp +++ b/libmodprobe/libmodprobe.cpp @@ -194,17 +194,18 @@ bool Modprobe::ParseOptionsCallback(const std::vector<std::string>& args) { return true; } -bool Modprobe::ParseBlacklistCallback(const std::vector<std::string>& args) { +bool Modprobe::ParseBlocklistCallback(const std::vector<std::string>& args) { auto it = args.begin(); const std::string& type = *it++; - if (type != "blacklist") { - LOG(ERROR) << "non-blacklist line encountered in modules.blacklist"; + // +Legacy + if ((type != "blocklist") && (type != "blacklist")) { + LOG(ERROR) << "non-blocklist line encountered in modules.blocklist"; return false; } if (args.size() != 2) { - LOG(ERROR) << "lines in modules.blacklist must have exactly 2 entries, not " << args.size(); + LOG(ERROR) << "lines in modules.blocklist must have exactly 2 entries, not " << args.size(); return false; } @@ -214,7 +215,7 @@ bool Modprobe::ParseBlacklistCallback(const std::vector<std::string>& args) { if (canonical_name.empty()) { return false; } - this->module_blacklist_.emplace(canonical_name); + this->module_blocklist_.emplace(canonical_name); return true; } @@ -331,16 +332,18 @@ Modprobe::Modprobe(const std::vector<std::string>& base_paths, const std::string auto options_callback = std::bind(&Modprobe::ParseOptionsCallback, this, _1); ParseCfg(base_path + "/modules.options", options_callback); - auto blacklist_callback = std::bind(&Modprobe::ParseBlacklistCallback, this, _1); - ParseCfg(base_path + "/modules.blacklist", blacklist_callback); + auto blocklist_callback = std::bind(&Modprobe::ParseBlocklistCallback, this, _1); + ParseCfg(base_path + "/modules.blocklist", blocklist_callback); + // Legacy + ParseCfg(base_path + "/modules.blacklist", blocklist_callback); } ParseKernelCmdlineOptions(); android::base::SetMinimumLogSeverity(android::base::INFO); } -void Modprobe::EnableBlacklist(bool enable) { - blacklist_enabled = enable; +void Modprobe::EnableBlocklist(bool enable) { + blocklist_enabled = enable; } void Modprobe::EnableVerbose(bool enable) { diff --git a/libmodprobe/libmodprobe_ext.cpp b/libmodprobe/libmodprobe_ext.cpp index 658970874..84f71506a 100644 --- a/libmodprobe/libmodprobe_ext.cpp +++ b/libmodprobe/libmodprobe_ext.cpp @@ -80,8 +80,8 @@ 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"; + if (blocklist_enabled && module_blocklist_.count(module_name)) { + LOG(INFO) << "module " << module_name << " is blocklisted"; return false; } auto deps = GetDependencies(module_name); diff --git a/libmodprobe/libmodprobe_ext_test.cpp b/libmodprobe/libmodprobe_ext_test.cpp index 9ee5ba7ab..e79bfaf84 100644 --- a/libmodprobe/libmodprobe_ext_test.cpp +++ b/libmodprobe/libmodprobe_ext_test.cpp @@ -72,7 +72,7 @@ bool Modprobe::Rmmod(const std::string& module_name) { bool Modprobe::ModuleExists(const std::string& module_name) { auto deps = GetDependencies(module_name); - if (blacklist_enabled && module_blacklist_.count(module_name)) { + if (blocklist_enabled && module_blocklist_.count(module_name)) { return false; } if (deps.empty()) { diff --git a/libmodprobe/libmodprobe_test.cpp b/libmodprobe/libmodprobe_test.cpp index eea0abd52..5919c49be 100644 --- a/libmodprobe/libmodprobe_test.cpp +++ b/libmodprobe/libmodprobe_test.cpp @@ -113,9 +113,9 @@ TEST(libmodprobe, Test) { "options test9.ko param_x=1 param_y=2 param_z=3\n" "options test100.ko param_1=1\n"; - const std::string modules_blacklist = - "blacklist test9.ko\n" - "blacklist test3.ko\n"; + const std::string modules_blocklist = + "blocklist test9.ko\n" + "blocklist test3.ko\n"; const std::string modules_load = "test4.ko\n" @@ -139,7 +139,7 @@ TEST(libmodprobe, Test) { 0600, getuid(), getgid())); ASSERT_TRUE(android::base::WriteStringToFile(modules_load, dir_path + "/modules.load", 0600, getuid(), getgid())); - ASSERT_TRUE(android::base::WriteStringToFile(modules_blacklist, dir_path + "/modules.blacklist", + ASSERT_TRUE(android::base::WriteStringToFile(modules_blocklist, dir_path + "/modules.blocklist", 0600, getuid(), getgid())); for (auto i = test_modules.begin(); i != test_modules.end(); ++i) { @@ -176,6 +176,6 @@ TEST(libmodprobe, Test) { EXPECT_TRUE(modules_loaded == expected_after_remove); - m.EnableBlacklist(true); + m.EnableBlocklist(true); EXPECT_FALSE(m.LoadWithAliases("test4", true)); } |