No need extra tmpfs for worker

This commit is contained in:
LoveSy 2024-02-22 22:19:31 +08:00 committed by John Wu
parent 10069215f4
commit 156b0e67ca
3 changed files with 7 additions and 3 deletions

View File

@ -73,7 +73,7 @@ static void setup_mounts() {
// Prepare worker // Prepare worker
ssprintf(path, sizeof(path), "%s/" WORKERDIR, get_magisk_tmp()); ssprintf(path, sizeof(path), "%s/" WORKERDIR, get_magisk_tmp());
xmkdir(path, 0); xmkdir(path, 0);
xmount("worker", path, "tmpfs", 0, "mode=755"); xmount(path, path, nullptr, MS_BIND, nullptr);
xmount(nullptr, path, nullptr, MS_PRIVATE, nullptr); xmount(nullptr, path, nullptr, MS_PRIVATE, nullptr);
} }

View File

@ -20,7 +20,7 @@ void revert_unmount() {
// Unmount dummy skeletons and MAGISKTMP // Unmount dummy skeletons and MAGISKTMP
// since mirror nodes are always mounted under skeleton, we don't have to specifically unmount // since mirror nodes are always mounted under skeleton, we don't have to specifically unmount
for (auto &info: parse_mount_info("self")) { for (auto &info: parse_mount_info("self")) {
if (info.source == "magisk" || info.source == "worker" || // magisktmp tmpfs if (info.source == "magisk" || // magisktmp tmpfs
info.root.starts_with("/adb/modules")) { // bind mount from data partition info.root.starts_with("/adb/modules")) { // bind mount from data partition
targets.insert(info.target); targets.insert(info.target);
} }

View File

@ -162,6 +162,7 @@ void tmpfs_node::mount() {
dir_node::mount(); dir_node::mount();
VLOGD(replace() ? "replace" : "move", worker_dir.data(), node_path().data()); VLOGD(replace() ? "replace" : "move", worker_dir.data(), node_path().data());
xmount(worker_dir.data(), node_path().data(), nullptr, MS_MOVE, nullptr); xmount(worker_dir.data(), node_path().data(), nullptr, MS_MOVE, nullptr);
xmount(nullptr, node_path().data(), nullptr, MS_REMOUNT | MS_BIND | MS_RDONLY, nullptr);
} else { } else {
const string dest = worker_path(); const string dest = worker_path();
// We don't need another layer of tmpfs if parent is tmpfs // We don't need another layer of tmpfs if parent is tmpfs
@ -326,8 +327,11 @@ void load_modules() {
root->mount(); root->mount();
} }
// cleanup mounts
ssprintf(buf, sizeof(buf), "%s/" WORKERDIR, get_magisk_tmp()); ssprintf(buf, sizeof(buf), "%s/" WORKERDIR, get_magisk_tmp());
xmount(nullptr, buf, nullptr, MS_REMOUNT | MS_RDONLY, nullptr); xumount2(buf, MNT_DETACH);
ssprintf(buf, sizeof(buf), "%s/" MODULEMNT, get_magisk_tmp());
xumount2(buf, MNT_DETACH);
} }
/************************ /************************