Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 54e693e6 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "modprobe: Use more inclusive language for modprobe and libmodprobe" into rvc-dev

parents 4dc1d5f3 502cb7af
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -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;
};
+12 −9
Original line number Diff line number Diff line
@@ -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) {
+2 −2
Original line number Diff line number Diff line
@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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()) {
+5 −5
Original line number Diff line number Diff line
@@ -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));
}
Loading