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

Commit f81c21f8 authored by Steve Muckle's avatar Steve Muckle Committed by android-build-merger
Browse files

libmodprobe: add support to list modules am: 012cfa19 am: 4a644fa5

am: 1b9d1e6b

Change-Id: I822dc5523c0e0b788475d405daff495adb88c7d4
parents 21869e97 1b9d1e6b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ class Modprobe {
    bool LoadWithAliases(const std::string& module_name, bool strict,
                         const std::string& parameters = "");
    bool Remove(const std::string& module_name);
    std::vector<std::string> ListModules(const std::string& pattern);
    void EnableBlacklist(bool enable);

  private:
+13 −0
Original line number Diff line number Diff line
@@ -363,3 +363,16 @@ bool Modprobe::Remove(const std::string& module_name) {
    }
    return true;
}

std::vector<std::string> Modprobe::ListModules(const std::string& pattern) {
    std::vector<std::string> rv;
    for (const auto& [module, deps] : module_deps_) {
        // Attempt to match both the canonical module name and the module filename.
        if (!fnmatch(pattern.c_str(), module.c_str(), 0)) {
            rv.emplace_back(module);
        } else if (!fnmatch(pattern.c_str(), basename(deps[0].c_str()), 0)) {
            rv.emplace_back(deps[0]);
        }
    }
    return rv;
}