Skip to content

Commit

Permalink
No need extra tmpfs for worker now
Browse files Browse the repository at this point in the history
  • Loading branch information
yujincheng08 committed Feb 22, 2024
1 parent d015892 commit 4a144b4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
3 changes: 1 addition & 2 deletions native/src/core/bootstages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ static void setup_mounts() {
// Prepare worker
ssprintf(path, sizeof(path), "%s/" WORKERDIR, get_magisk_tmp());
xmkdir(path, 0);
xmount("worker", path, "tmpfs", 0, "mode=755");
xmount(nullptr, path, nullptr, MS_PRIVATE, nullptr);
xmount(path, path, nullptr, MS_BIND, nullptr);
}

string find_preinit_device() {
Expand Down
7 changes: 0 additions & 7 deletions native/src/core/daemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,13 +391,6 @@ static void daemon_entry() {
ssprintf(path, sizeof(path), "%s/" ROOTOVL, tmp);
rm_rf(path);

// Unshare magiskd
xunshare(CLONE_NEWNS);
// Hide magisk internal mount point
xmount(nullptr, tmp, nullptr, MS_PRIVATE | MS_REC, nullptr);
// Fix sdcardfs bug on old kernel
xmount(nullptr, "/mnt", nullptr, MS_SLAVE | MS_REC, nullptr);

// Use isolated devpts if kernel support
if (access("/dev/pts/ptmx", F_OK) == 0) {
ssprintf(path, sizeof(path), "%s/" SHELLPTS, tmp);
Expand Down
2 changes: 1 addition & 1 deletion native/src/core/deny/revert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void revert_unmount() {
// Unmount dummy skeletons and MAGISKTMP
// since mirror nodes are always mounted under skeleton, we don't have to specifically unmount
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
targets.insert(info.target);
}
Expand Down
6 changes: 5 additions & 1 deletion native/src/core/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ void tmpfs_node::mount() {
dir_node::mount();
VLOGD(replace() ? "replace" : "move", worker_dir.data(), node_path().data());
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 {
const string dest = worker_path();
// We don't need another layer of tmpfs if parent is tmpfs
Expand Down Expand Up @@ -328,8 +329,11 @@ void load_modules() {
root->mount();
}

// cleanup mounts
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);
}

/************************
Expand Down

0 comments on commit 4a144b4

Please sign in to comment.