From 703fb74fb5d7b806f188f2814f8dd770add26eeb Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Mon, 15 Jun 2020 11:51:59 -0700 Subject: [PATCH] modprobe: Use more inclusive language for modprobe and libmodprobe blacklist is replaced with blocklist. Test: none Change-Id: I59f9fde5900b9aee82aca1eab4a6ded3d136063b --- libmodprobe/include/modprobe/modprobe.h | 8 ++++---- libmodprobe/libmodprobe.cpp | 21 ++++++++++++--------- libmodprobe/libmodprobe_ext.cpp | 4 ++-- libmodprobe/libmodprobe_ext_test.cpp | 2 +- libmodprobe/libmodprobe_test.cpp | 10 +++++----- toolbox/modprobe.cpp | 10 +++++----- 6 files changed, 29 insertions(+), 26 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* 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& args); bool ParseLoadCallback(const std::vector& args); bool ParseOptionsCallback(const std::vector& args); - bool ParseBlacklistCallback(const std::vector& args); + bool ParseBlocklistCallback(const std::vector& args); void ParseKernelCmdlineOptions(); void ParseCfg(const std::string& cfg, std::function&)> f); @@ -65,8 +65,8 @@ class Modprobe { std::vector> module_post_softdep_; std::vector module_load_; std::unordered_map module_options_; - std::set module_blacklist_; + std::set module_blocklist_; std::unordered_set 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& args) { return true; } -bool Modprobe::ParseBlacklistCallback(const std::vector& args) { +bool Modprobe::ParseBlocklistCallback(const std::vector& 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& 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& 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)); } diff --git a/toolbox/modprobe.cpp b/toolbox/modprobe.cpp index 1b5f54e8f..3ffa74ecd 100644 --- a/toolbox/modprobe.cpp +++ b/toolbox/modprobe.cpp @@ -36,7 +36,7 @@ static void print_usage(void) { std::cerr << " modprobe [-alrqvsDb] [-d DIR] MODULE [symbol=value][...]" << std::endl; std::cerr << std::endl; std::cerr << "Options:" << std::endl; - std::cerr << " -b: Apply blacklist to module names too" << std::endl; + std::cerr << " -b: Apply blocklist to module names too" << std::endl; std::cerr << " -d: Load modules from DIR, option may be used multiple times" << std::endl; std::cerr << " -D: Print dependencies for modules only, do not load"; std::cerr << " -h: Print this help" << std::endl; @@ -59,7 +59,7 @@ extern "C" int modprobe_main(int argc, char** argv) { std::string module_parameters; std::vector mod_dirs; modprobe_mode mode = AddModulesMode; - bool blacklist = false; + bool blocklist = false; bool verbose = false; int rv = EXIT_SUCCESS; @@ -72,7 +72,7 @@ extern "C" int modprobe_main(int argc, char** argv) { check_mode(); break; case 'b': - blacklist = true; + blocklist = true; break; case 'd': mod_dirs.emplace_back(optarg); @@ -151,8 +151,8 @@ extern "C" int modprobe_main(int argc, char** argv) { Modprobe m(mod_dirs); m.EnableVerbose(verbose); - if (blacklist) { - m.EnableBlacklist(true); + if (blocklist) { + m.EnableBlocklist(true); } for (const auto& module : modules) {