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
diff --git a/twrp.cpp b/twrp.cpp
index 2b84cbb..6d6e5ba 100755
--- a/twrp.cpp
+++ b/twrp.cpp
@@ -198,6 +198,10 @@
 		return -1;
 	}
 	PartitionManager.Output_Partition_Logging();
+
+	if (PartitionManager.Get_Super_Status())
+		PartitionManager.Setup_Super_Devices();
+
 	// Load up all the resources
 	gui_loadResources();
 
@@ -374,23 +378,29 @@
 	TWPartition* ven = PartitionManager.Find_Partition_By_Path("/vendor");
 
 	if (sys) {
-		if ((DataManager::GetIntValue("tw_mount_system_ro") == 0 && sys->Check_Lifetime_Writes() == 0) || DataManager::GetIntValue("tw_mount_system_ro") == 2) {
-			if (DataManager::GetIntValue("tw_never_show_system_ro_page") == 0) {
-				DataManager::SetValue("tw_back", "main");
-				if (gui_startPage("system_readonly", 1, 1) != 0) {
-					LOGERR("Failed to start system_readonly GUI page.\n");
+		if (sys->Get_Super_Status()) {
+			if (!PartitionManager.Prepare_All_Super_Volumes()) {
+				LOGERR("Unable to prepare super volumes.\n");
+			}
+		} else {
+			if ((DataManager::GetIntValue("tw_mount_system_ro") == 0 && sys->Check_Lifetime_Writes() == 0) || DataManager::GetIntValue("tw_mount_system_ro") == 2) {
+				if (DataManager::GetIntValue("tw_never_show_system_ro_page") == 0) {
+					DataManager::SetValue("tw_back", "main");
+					if (gui_startPage("system_readonly", 1, 1) != 0) {
+						LOGERR("Failed to start system_readonly GUI page.\n");
+					}
+				} else if (DataManager::GetIntValue("tw_mount_system_ro") == 0) {
+					sys->Change_Mount_Read_Only(false);
+					if (ven)
+						ven->Change_Mount_Read_Only(false);
 				}
-			} else if (DataManager::GetIntValue("tw_mount_system_ro") == 0) {
+			} else if (DataManager::GetIntValue("tw_mount_system_ro") == 1) {
+				// Do nothing, user selected to leave system read only
+			} else {
 				sys->Change_Mount_Read_Only(false);
 				if (ven)
 					ven->Change_Mount_Read_Only(false);
 			}
-		} else if (DataManager::GetIntValue("tw_mount_system_ro") == 1) {
-			// Do nothing, user selected to leave system read only
-		} else {
-			sys->Change_Mount_Read_Only(false);
-			if (ven)
-				ven->Change_Mount_Read_Only(false);
 		}
 	}
 #endif