modprobe: Use more inclusive language for modprobe and libmodprobe

blacklist is replaced with blocklist.

Test: none
Change-Id: I59f9fde5900b9aee82aca1eab4a6ded3d136063b
This commit is contained in:
Mark Salyzyn 2020-06-15 11:51:59 -07:00
parent 9287716a1c
commit 703fb74fb5
6 changed files with 29 additions and 26 deletions

View file

@ -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;
};

View file

@ -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) {

View file

@ -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);

View file

@ -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()) {

View file

@ -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));
}

View file

@ -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<std::string> 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) {