From da974805672e53c334b71480c5a6bc08f3e16109 Mon Sep 17 00:00:00 2001 From: Chaosmaster Date: Sun, 26 Jan 2020 21:09:28 +0100 Subject: [PATCH] Create/Remove system_root/system bind mount, when mounting System This will automatically create and remove a bind mount /system -> /system_root/system everytime "System" is mounted via the GUI or ORS. This should get rid of issues with ZIPs trying to mount the system-partition to /system on SAR-devices, while keeping the filesystem-layout in sync with AOSP from a user-perspective. Change-Id: I7f531d113b07c31b39d8f87edac76a7fc79075e7 --- partition.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/partition.cpp b/partition.cpp index 9012d497..8d86f694 100644 --- a/partition.cpp +++ b/partition.cpp @@ -1528,10 +1528,23 @@ bool TWPartition::Mount(bool Display_Error) { string Command = "mount -o bind '" + Symlink_Path + "' '" + Symlink_Mount_Point + "'"; TWFunc::Exec_Cmd(Command); } + + if (Mount_Point == "/system_root") { + unlink("/system"); + mkdir("/system", 0755); + mount("/system_root/system", "/system", "auto", MS_BIND, NULL); + } + return true; } bool TWPartition::UnMount(bool Display_Error) { + if (Mount_Point == "/system_root") { + if (umount("/system") == -1) + umount2("/system", MNT_DETACH); + rmdir("/system"); + symlink("/system_root/system", "/system"); + } if (Is_Mounted()) { int never_unmount_system;