libmodprobe: add support for a blacklist
If the blacklist is enabled, blacklisted modules are treated as though
they are not present.
Change-Id: Ie8712f24298e78f92d5028b1ca3a8a3e07a9190a
diff --git a/libmodprobe/libmodprobe_test.cpp b/libmodprobe/libmodprobe_test.cpp
index d5a7d6f..a711631 100644
--- a/libmodprobe/libmodprobe_test.cpp
+++ b/libmodprobe/libmodprobe_test.cpp
@@ -99,6 +99,10 @@
"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_load =
"test4.ko\n"
"test1.ko\n"
@@ -109,17 +113,20 @@
"test11.ko\n";
TemporaryDir dir;
- ASSERT_TRUE(android::base::WriteStringToFile(
- modules_alias, std::string(dir.path) + "/modules.alias", 0600, getuid(), getgid()));
+ auto dir_path = std::string(dir.path);
+ ASSERT_TRUE(android::base::WriteStringToFile(modules_alias, dir_path + "/modules.alias", 0600,
+ getuid(), getgid()));
- ASSERT_TRUE(android::base::WriteStringToFile(
- modules_dep, std::string(dir.path) + "/modules.dep", 0600, getuid(), getgid()));
- ASSERT_TRUE(android::base::WriteStringToFile(
- modules_softdep, std::string(dir.path) + "/modules.softdep", 0600, getuid(), getgid()));
- ASSERT_TRUE(android::base::WriteStringToFile(
- modules_options, std::string(dir.path) + "/modules.options", 0600, getuid(), getgid()));
- ASSERT_TRUE(android::base::WriteStringToFile(
- modules_load, std::string(dir.path) + "/modules.load", 0600, getuid(), getgid()));
+ ASSERT_TRUE(android::base::WriteStringToFile(modules_dep, dir_path + "/modules.dep", 0600,
+ getuid(), getgid()));
+ ASSERT_TRUE(android::base::WriteStringToFile(modules_softdep, dir_path + "/modules.softdep",
+ 0600, getuid(), getgid()));
+ ASSERT_TRUE(android::base::WriteStringToFile(modules_options, dir_path + "/modules.options",
+ 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",
+ 0600, getuid(), getgid()));
for (auto i = test_modules.begin(); i != test_modules.end(); ++i) {
*i = dir.path + *i;
@@ -153,4 +160,7 @@
}
EXPECT_TRUE(modules_loaded == expected_after_remove);
+
+ m.EnableBlacklist(true);
+ EXPECT_FALSE(m.LoadWithAliases("test4", true));
}