From ee7b7ffba41e1ac16b22f4742c301ffff14bc3da Mon Sep 17 00:00:00 2001 From: bigbiff Date: Mon, 23 Mar 2020 15:08:27 -0400 Subject: [PATCH] super partition: mount super partitions using fs_mgr We are now requiring fstab v2 for android-10+ trees. You can specify twrp flags using /etc/twrp.flags to label and annotate partitions. This patchset uses fs_mgr to load the super partition and build device mapper blocks off vendor and system depending on the slot in use. These are mapped to partitions in TWRP and allowed to be mounted read-only. The super partition is also mapped into a TWRP partition in order to backup the entire partition. You cannot backup individual device mapper blocks due to the device can only be read-only. Therefore you cannot write back to the device mapper. Change-Id: Icc1d895dcf96ad5ba03989c9bf759419d83673a3 --- Android.mk | 24 +++++-- data.cpp | 5 ++ gui/partitionlist.cpp | 1 + gui/theme/common/landscape.xml | 10 ++- gui/theme/common/portrait.xml | 10 ++- gui/theme/common/watch.xml | 10 ++- openrecoveryscript.cpp | 2 + orscmd/orscmd.cpp | 1 + partition.cpp | 55 +++++++++++++-- partitionmanager.cpp | 123 +++++++++++++++++++++++++++++++-- partitions.hpp | 18 +++-- twrp-functions.cpp | 47 +++++++++---- twrp-functions.hpp | 4 +- twrp.cpp | 34 +++++---- variables.h | 3 +- 15 files changed, 296 insertions(+), 51 deletions(-) mode change 100644 => 100755 gui/partitionlist.cpp mode change 100644 => 100755 orscmd/orscmd.cpp mode change 100644 => 100755 partition.cpp mode change 100644 => 100755 variables.h diff --git a/Android.mk b/Android.mk index 6875d036..0bbad69e 100755 --- a/Android.mk +++ b/Android.mk @@ -52,6 +52,9 @@ TWHTCD_PATH := $(TWRES_PATH)htcd/ TARGET_RECOVERY_GUI := true +LOCAL_STATIC_LIBRARIES := +LOCAL_SHARED_LIBRARIES := + ifneq ($(TW_DEVICE_VERSION),) LOCAL_CFLAGS += -DTW_DEVICE_VERSION='"-$(TW_DEVICE_VERSION)"' else @@ -77,6 +80,19 @@ LOCAL_SRC_FILES := \ tarWrite.c \ twrpAdbBuFifo.cpp +ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 29; echo $$?),0) + LOCAL_STATIC_LIBRARIES += libavb + LOCAL_SHARED_LIBRARIES += libfs_mgr libinit + LOCAL_C_INCLUDES += \ + system/core/fs_mgr/libfs_avb/include/ \ + system/core/fs_mgr/include_fstab/ \ + system/core/fs_mgr/include/ \ + system/core/fs_mgr/libdm/include/ \ + system/core/fs_mgr/liblp/include/ \ + system/gsid/include/ \ + system/core/init/ +endif + ifneq ($(TARGET_RECOVERY_REBOOT_SRC),) LOCAL_SRC_FILES += $(TARGET_RECOVERY_REBOOT_SRC) endif @@ -117,9 +133,6 @@ else LOCAL_C_INCLUDES += external/boringssl/include external/libcxx/include endif -LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := - LOCAL_STATIC_LIBRARIES += libguitwrp LOCAL_SHARED_LIBRARIES += libz libc libcutils libstdc++ libtar libblkid libminuitwrp libminadbd libmtdutils libtwadbbu libbootloader_message_twrp LOCAL_SHARED_LIBRARIES += libcrecovery libtwadbbu libtwrpdigest libc++ libaosprecovery @@ -153,7 +166,6 @@ ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26; echo $$?),0) else LOCAL_SHARED_LIBRARIES += libziparchive LOCAL_C_INCLUDES += system/core/libziparchive/include - LOCAL_C_FLAGS += -DUSE_ endif else LOCAL_SHARED_LIBRARIES += libminzip @@ -190,6 +202,10 @@ ifeq ($(AB_OTA_UPDATER),true) TWRP_REQUIRED_MODULES += libhardware endif +ifeq ($(PRODUCT_USE_DYNAMIC_PARTITIONS),true) + LOCAL_CFLAGS += -DPRODUCT_USE_DYNAMIC_PARTITIONS=1 +endif + LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin ifeq ($(TARGET_RECOVERY_TWRP_LIB),) diff --git a/data.cpp b/data.cpp index 85834d28..6ba278fa 100755 --- a/data.cpp +++ b/data.cpp @@ -777,8 +777,12 @@ void DataManager::SetDefaultValues() #ifdef TW_HAS_NO_BOOT_PARTITION mPersist.SetValue("tw_backup_list", "/system;/data;"); +#else +#ifdef PRODUCT_USE_DYNAMIC_PARTITIONS + mPersist.SetValue("tw_backup_list", "/data;"); #else mPersist.SetValue("tw_backup_list", "/system;/data;/boot;"); +#endif #endif mConst.SetValue(TW_MIN_SYSTEM_VAR, TW_MIN_SYSTEM_SIZE); mData.SetValue(TW_BACKUP_NAME, "(Auto Generate)"); @@ -814,6 +818,7 @@ void DataManager::SetDefaultValues() mData.SetValue("tw_background_thread_running", "0"); mData.SetValue(TW_RESTORE_FILE_DATE, "0"); mPersist.SetValue("tw_military_time", "0"); + mData.SetValue(TW_IS_SUPER, "0"); #ifdef TW_INCLUDE_CRYPTO mPersist.SetValue(TW_USE_SHA2, "1"); diff --git a/gui/partitionlist.cpp b/gui/partitionlist.cpp old mode 100644 new mode 100755 index 16e09977..570b16aa --- a/gui/partitionlist.cpp +++ b/gui/partitionlist.cpp @@ -142,6 +142,7 @@ int GUIPartitionList::NotifyVarChange(const std::string& varName, const std::str currentValue = value; SetPosition(); } else if (ListType == "backup") { + updateList = true; MatchList(); } else if (ListType == "restore") { updateList = true; diff --git a/gui/theme/common/landscape.xml b/gui/theme/common/landscape.xml index 3af174ee..85b65b84 100755 --- a/gui/theme/common/landscape.xml +++ b/gui/theme/common/landscape.xml @@ -2485,7 +2485,10 @@