Added remount function and changed bind mount...

prefix.
This commit is contained in:
snake-4
2024-04-14 16:23:38 +02:00
parent ac910f0ebe
commit 6e333581fb
2 changed files with 27 additions and 1 deletions

View File

@@ -11,6 +11,7 @@ using zygisk::AppSpecializeArgs;
using zygisk::ServerSpecializeArgs; using zygisk::ServerSpecializeArgs;
void do_unmount(); void do_unmount();
void do_remount();
DCL_HOOK_FUNC(static int, unshare, int flags) DCL_HOOK_FUNC(static int, unshare, int flags)
{ {
@@ -84,6 +85,7 @@ public:
} }
do_unmount(); do_unmount();
do_remount();
} }
void preServerSpecialize(ServerSpecializeArgs *args) override void preServerSpecialize(ServerSpecializeArgs *args) override

View File

@@ -16,7 +16,7 @@ static bool shouldUnmount(const mountinfo_entry_t &mount_info)
const auto &root = mount_info.getRoot(); const auto &root = mount_info.getRoot();
// Unmount all module bind mounts // Unmount all module bind mounts
if (root.rfind("/adb/modules", 0) == 0) if (root.rfind("/adb/", 0) == 0)
return true; return true;
return false; return false;
@@ -95,3 +95,27 @@ void do_unmount()
} }
} }
} }
void do_remount()
{
std::vector<mount_entry_t> 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));
}
}
}
}