diff --git a/module/jni/main.cpp b/module/jni/main.cpp index ddde443..7544c9b 100644 --- a/module/jni/main.cpp +++ b/module/jni/main.cpp @@ -11,6 +11,7 @@ using zygisk::AppSpecializeArgs; using zygisk::ServerSpecializeArgs; void do_unmount(); +void do_remount(); DCL_HOOK_FUNC(static int, unshare, int flags) { @@ -84,6 +85,7 @@ public: } do_unmount(); + do_remount(); } void preServerSpecialize(ServerSpecializeArgs *args) override diff --git a/module/jni/unmount.cpp b/module/jni/unmount.cpp index 6f3b016..d50ef09 100644 --- a/module/jni/unmount.cpp +++ b/module/jni/unmount.cpp @@ -16,7 +16,7 @@ static bool shouldUnmount(const mountinfo_entry_t &mount_info) const auto &root = mount_info.getRoot(); // Unmount all module bind mounts - if (root.rfind("/adb/modules", 0) == 0) + if (root.rfind("/adb/", 0) == 0) return true; return false; @@ -95,3 +95,27 @@ void do_unmount() } } } + +void do_remount() +{ + std::vector mounts = parseMountsFromPath("/proc/self/mounts"); + auto data_mount_it = std::find_if(mounts.begin(), mounts.end(), [](const mount_entry_t &mount) + { return mount.getMountPoint() == "/data"; }); + if (data_mount_it != mounts.end()) + { + const auto &options = data_mount_it->getOptions(); + + // If errors=remount-ro, remount it with errors=continue + if (options.find("errors") != options.end() && options.at("errors") == "remount-ro") + { + if (mount(NULL, "/data", NULL, MS_REMOUNT, "errors=continue") == 0) + { + LOGD("mount(NULL, \"/data\", NULL, MS_REMOUNT, \"errors=continue\") returned 0"); + } + else + { + LOGE("mount(NULL, \"/data\", NULL, MS_REMOUNT, \"errors=continue\") returned -1: %d (%s)", errno, strerror(errno)); + } + } + } +}