Mount system and vendor for A/B installs for backuptool to work

Also bind mount a copy of /sbin/sh over /system/bin/sh

Change-Id: I58026af425b07b50a4377ab843192578e0d45587
(cherry picked from commit 7bf8df5086c561cbc9da9b32afa678ebe966f5c1)
This commit is contained in:
Chaosmaster
2020-05-11 18:16:56 +00:00
committed by bigbiff
parent a34befa5c8
commit 6c1477d974
+15
View File
@@ -28,6 +28,7 @@
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/mount.h>
#include <unistd.h>
#include <string.h>
@@ -442,7 +443,21 @@ int TWinstall_zip(const char* path, int* wipe_cache) {
} else {
if (Zip.EntryExists(AB_OTA)) {
LOGINFO("AB zip\n");
// We need this so backuptool can do its magic
bool system_mount_state = PartitionManager.Is_Mounted_By_Path(PartitionManager.Get_Android_Root_Path());
bool vendor_mount_state = PartitionManager.Is_Mounted_By_Path("/vendor");
PartitionManager.Mount_By_Path(PartitionManager.Get_Android_Root_Path(), true);
PartitionManager.Mount_By_Path("/vendor", true);
TWFunc::Exec_Cmd("cp -f /sbin/sh /tmp/sh");
mount("/tmp/sh", "/system/bin/sh", "auto", MS_BIND, NULL);
ret_val = Run_Update_Binary(path, &Zip, wipe_cache, AB_OTA_ZIP_TYPE);
umount("/system/bin/sh");
unlink("/tmp/sh");
if (!vendor_mount_state)
PartitionManager.UnMount_By_Path("/vendor", true);
if (!system_mount_state)
PartitionManager.UnMount_By_Path(PartitionManager.Get_Android_Root_Path(), true);
} else {
if (Zip.EntryExists("ui.xml")) {
LOGINFO("TWRP theme zip\n");