From a2719156c236c8be02403ef028490f001d393d8e Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Thu, 28 May 2015 09:44:41 -0500 Subject: Add resize2fs and ability to run resize2fs via GUI Note: Only works on ext2/3/4 partitions. Only tested on ext4. We can use this in some cases to resize the data partition if an incorrect fstab caused recovery to not reserve the 16KB for a crypto footer. Sometimes the BoardConfig for a custom ROM does not have the correct size for the system partition and if the ROM flashes a raw system image, that image will not take up the full block device. Running resize2fs can fix the size and may allow more room in the system partition for customizations like busybox or a larger gapps package. Sometimes flashing a factory image may flash userdata with an image with a file system that does not take up the full size of the block device (e.g. factory images for the Nexus 6 will flash userdata with a ~24GB userdata image, wasting ~30GB of space). Using resize2fs we can easily fix this issue without having to do a full format data. Change-Id: I631f5c6f567bbc6a9241e5dd95f1e435820a1b13 --- partitionmanager.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'partitionmanager.cpp') diff --git a/partitionmanager.cpp b/partitionmanager.cpp index 055f73697..572cd7c93 100644 --- a/partitionmanager.cpp +++ b/partitionmanager.cpp @@ -1259,6 +1259,34 @@ int TWPartitionManager::Repair_By_Path(string Path, bool Display_Error) { return false; } +int TWPartitionManager::Resize_By_Path(string Path, bool Display_Error) { + std::vector::iterator iter; + int ret = false; + bool found = false; + string Local_Path = TWFunc::Get_Root_Path(Path); + + if (Local_Path == "/tmp" || Local_Path == "/") + return true; + + // Iterate through all partitions + for (iter = Partitions.begin(); iter != Partitions.end(); iter++) { + if ((*iter)->Mount_Point == Local_Path || (!(*iter)->Symlink_Mount_Point.empty() && (*iter)->Symlink_Mount_Point == Local_Path)) { + ret = (*iter)->Resize(); + found = true; + } else if ((*iter)->Is_SubPartition && (*iter)->SubPartition_Of == Local_Path) { + (*iter)->Resize(); + } + } + if (found) { + return ret; + } else if (Display_Error) { + LOGERR("Resize: Unable to find partition for path '%s'\n", Local_Path.c_str()); + } else { + LOGINFO("Resize: Unable to find partition for path '%s'\n", Local_Path.c_str()); + } + return false; +} + void TWPartitionManager::Update_System_Details(void) { std::vector::iterator iter; int data_size = 0; -- cgit v1.2.3