mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-22 07:57:39 +00:00
Fix switch_root implementation
This commit is contained in:
parent
3e70a61e33
commit
3b8ea599f0
@ -128,7 +128,7 @@ static void switch_root(const string &path) {
|
|||||||
return true;
|
return true;
|
||||||
// Do not include subtrees
|
// Do not include subtrees
|
||||||
for (const auto &m : mounts) {
|
for (const auto &m : mounts) {
|
||||||
if (strncmp(me->mnt_dir, m.data(), m.length()) == 0)
|
if (strncmp(me->mnt_dir, m.data(), m.length()) == 0 && me->mnt_dir[m.length()] == '/')
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
mounts.emplace_back(me->mnt_dir);
|
mounts.emplace_back(me->mnt_dir);
|
||||||
@ -137,7 +137,7 @@ static void switch_root(const string &path) {
|
|||||||
for (auto &dir : mounts) {
|
for (auto &dir : mounts) {
|
||||||
auto new_path = path + dir;
|
auto new_path = path + dir;
|
||||||
mkdir(new_path.data(), 0755);
|
mkdir(new_path.data(), 0755);
|
||||||
xmount(dir.data(), new_path.c_str(), nullptr, MS_MOVE, nullptr);
|
xmount(dir.data(), new_path.data(), nullptr, MS_MOVE, nullptr);
|
||||||
}
|
}
|
||||||
chdir(path.data());
|
chdir(path.data());
|
||||||
xmount(path.data(), "/", nullptr, MS_MOVE, nullptr);
|
xmount(path.data(), "/", nullptr, MS_MOVE, nullptr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user