From f59fbd5dca50ffec6e24ee2e13439681aef8b21e Mon Sep 17 00:00:00 2001 From: LoveSy Date: Thu, 2 Mar 2023 23:16:02 +0800 Subject: [PATCH] Filter duplicate mount points This prevents umounting existing overlay mount points --- native/src/zygisk/deny/revert.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/native/src/zygisk/deny/revert.cpp b/native/src/zygisk/deny/revert.cpp index 05ac97786..47ccd7634 100644 --- a/native/src/zygisk/deny/revert.cpp +++ b/native/src/zygisk/deny/revert.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -13,14 +14,24 @@ static void lazy_unmount(const char* mountpoint) { } void revert_unmount() { - vector targets; + set targets; // 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 info.root.starts_with("/adb/modules")) { // bind mount from data partition - targets.push_back(info.target); + targets.insert(info.target); + } + } + + if (targets.empty()) return; + + for (auto last_target = targets.cbegin(), iter = next(targets.cbegin()); iter != targets.cend();) { + if (iter->starts_with(*last_target)) { + iter = targets.erase(iter); + } else { + last_target = iter++; } }