diff --git a/native/jni/init/mount.cpp b/native/jni/init/mount.cpp index 82f80e89e..929c0f3ae 100644 --- a/native/jni/init/mount.cpp +++ b/native/jni/init/mount.cpp @@ -128,7 +128,7 @@ static void switch_root(const string &path) { return true; // Do not include subtrees 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; } mounts.emplace_back(me->mnt_dir); @@ -137,7 +137,7 @@ static void switch_root(const string &path) { for (auto &dir : mounts) { auto new_path = path + dir; 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()); xmount(path.data(), "/", nullptr, MS_MOVE, nullptr);