mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-27 12:57:38 +00:00
Fix collect modules
This commit is contained in:
parent
122b4d66b6
commit
aac6ad73da
@ -645,29 +645,25 @@ static void prepare_modules() {
|
|||||||
|
|
||||||
static void collect_modules() {
|
static void collect_modules() {
|
||||||
auto dir = xopen_dir(MODULEROOT);
|
auto dir = xopen_dir(MODULEROOT);
|
||||||
|
if (!dir)
|
||||||
|
return;
|
||||||
int dfd = dirfd(dir.get());
|
int dfd = dirfd(dir.get());
|
||||||
for (dirent *entry; (entry = xreaddir(dir.get()));) {
|
for (dirent *entry; (entry = xreaddir(dir.get()));) {
|
||||||
if (entry->d_type == DT_DIR) {
|
if (entry->d_type == DT_DIR && entry->d_name != ".core"sv) {
|
||||||
if (entry->d_name == ".core"sv)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
int modfd = xopenat(dfd, entry->d_name, O_RDONLY);
|
int modfd = xopenat(dfd, entry->d_name, O_RDONLY);
|
||||||
run_finally f([=]{ close(modfd); });
|
|
||||||
|
|
||||||
if (faccessat(modfd, "remove", F_OK, 0) == 0) {
|
if (faccessat(modfd, "remove", F_OK, 0) == 0) {
|
||||||
LOGI("%s: remove\n", entry->d_name);
|
LOGI("%s: remove\n", entry->d_name);
|
||||||
auto uninstaller = MODULEROOT + "/"s + entry->d_name + "/uninstall.sh";
|
auto uninstaller = MODULEROOT + "/"s + entry->d_name + "/uninstall.sh";
|
||||||
if (access(uninstaller.data(), F_OK) == 0)
|
if (access(uninstaller.data(), F_OK) == 0)
|
||||||
exec_script(uninstaller.data());
|
exec_script(uninstaller.data());
|
||||||
frm_rf(xdup(modfd));
|
frm_rf(modfd);
|
||||||
unlinkat(dfd, entry->d_name, AT_REMOVEDIR);
|
unlinkat(dfd, entry->d_name, AT_REMOVEDIR);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
unlinkat(modfd, "update", 0);
|
unlinkat(modfd, "update", 0);
|
||||||
|
|
||||||
if (faccessat(modfd, "disable", F_OK, 0) != 0)
|
if (faccessat(modfd, "disable", F_OK, 0) != 0)
|
||||||
module_list.emplace_back(entry->d_name);
|
module_list.emplace_back(entry->d_name);
|
||||||
|
close(modfd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user