Move devpts mount to magiskinit

This commit is contained in:
LoveSy
2024-08-13 21:34:32 +08:00
committed by John Wu
parent 554eda8fe1
commit 838e1e254d
2 changed files with 13 additions and 15 deletions

View File

@@ -249,5 +249,18 @@ void MagiskInit::setup_tmp(const char *path) {
xmount(".", path, nullptr, MS_BIND, nullptr);
chdir(path);
// Use isolated devpts if kernel support
if (access("/dev/pts/ptmx", F_OK) == 0) {
xmkdirs(SHELLPTS, 0755);
xmount("devpts", SHELLPTS, "devpts", MS_NOSUID | MS_NOEXEC, "newinstance");
xmount(nullptr, SHELLPTS, nullptr, MS_PRIVATE, nullptr);
if (access(SHELLPTS "/ptmx", F_OK)) {
umount2(SHELLPTS, MNT_DETACH);
rmdir(SHELLPTS);
}
}
chdir("/");
}