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 --- gui/action.cpp | 27 +++++++++++++++++++++++++++ gui/devices/landscape/res/landscape.xml | 19 +++++++++++++++++++ gui/devices/portrait/res/portrait.xml | 19 +++++++++++++++++++ gui/devices/watch/res/watch.xml | 19 +++++++++++++++++++ gui/objects.hpp | 1 + 5 files changed, 85 insertions(+) (limited to 'gui') diff --git a/gui/action.cpp b/gui/action.cpp index 7ecd0b46a..fc3973738 100644 --- a/gui/action.cpp +++ b/gui/action.cpp @@ -223,6 +223,7 @@ GUIAction::GUIAction(xml_node<>* node) ADD_ACTION(installsu); ADD_ACTION(decrypt_backup); ADD_ACTION(repair); + ADD_ACTION(resize); ADD_ACTION(changefilesystem); ADD_ACTION(flashimage); } @@ -872,6 +873,10 @@ int GUIAction::getpartitiondetails(std::string arg) DataManager::SetValue("tw_partition_can_repair", 1); else DataManager::SetValue("tw_partition_can_repair", 0); + if (Part->Can_Resize()) + DataManager::SetValue("tw_partition_can_resize", 1); + else + DataManager::SetValue("tw_partition_can_resize", 0); if (TWFunc::Path_Exists("/sbin/mkdosfs")) DataManager::SetValue("tw_partition_vfat", 1); else @@ -1651,6 +1656,28 @@ int GUIAction::repair(std::string arg) return 0; } +int GUIAction::resize(std::string arg) +{ + int op_status = 0; + + operation_start("Resize Partition"); + if (simulate) { + simulate_progress_bar(); + } else { + string part_path; + DataManager::GetValue("tw_partition_mount_point", part_path); + if (PartitionManager.Resize_By_Path(part_path, true)) { + op_status = 0; // success + } else { + LOGERR("Error resizing file system.\n"); + op_status = 1; // fail + } + } + + operation_end(op_status); + return 0; +} + int GUIAction::changefilesystem(std::string arg) { int op_status = 0; diff --git a/gui/devices/landscape/res/landscape.xml b/gui/devices/landscape/res/landscape.xml index 12c66290b..529aef79c 100644 --- a/gui/devices/landscape/res/landscape.xml +++ b/gui/devices/landscape/res/landscape.xml @@ -1380,6 +1380,25 @@ Backup Size: %tw_partition_backup_size%MB + + + + Resize + + tw_back=partitionoptions + tw_action=resize + tw_action_param=%tw_partition_mount_point% + tw_has_action2=1 + tw_action2=getpartitiondetails + tw_text1=Resize %tw_partition_name%? + tw_text2= + tw_action_text1=Resizing... + tw_complete_text1=Resize Complete + tw_slider_text=Swipe to Resize + confirm_action + + + diff --git a/gui/devices/portrait/res/portrait.xml b/gui/devices/portrait/res/portrait.xml index 997da9d23..9ffd6e44e 100644 --- a/gui/devices/portrait/res/portrait.xml +++ b/gui/devices/portrait/res/portrait.xml @@ -1117,6 +1117,25 @@ Backup Size: %tw_partition_backup_size%MB + + + + Resize + + tw_back=partitionoptions + tw_action=resize + tw_action_param=%tw_partition_mount_point% + tw_has_action2=1 + tw_action2=getpartitiondetails + tw_text1=Resize %tw_partition_name%? + tw_text2= + tw_action_text1=Resizing... + tw_complete_text1=Resize Complete + tw_slider_text=Swipe to Resize + confirm_action + + + diff --git a/gui/devices/watch/res/watch.xml b/gui/devices/watch/res/watch.xml index f0f383dcb..a8535c659 100644 --- a/gui/devices/watch/res/watch.xml +++ b/gui/devices/watch/res/watch.xml @@ -1095,6 +1095,25 @@ Backup Size: %tw_partition_backup_size%MB + + + + Resize + + tw_back=partitionoptions + tw_action=resize + tw_action_param=%tw_partition_mount_point% + tw_has_action2=1 + tw_action2=getpartitiondetails + tw_text1=Resize %tw_partition_name%? + tw_text2= + tw_action_text1=Resizing... + tw_complete_text1=Resize Complete + tw_slider_text=Swipe to Resize + confirm_action + + + diff --git a/gui/objects.hpp b/gui/objects.hpp index ee0f08b8f..1991877ee 100644 --- a/gui/objects.hpp +++ b/gui/objects.hpp @@ -354,6 +354,7 @@ protected: int fixsu(std::string arg); int decrypt_backup(std::string arg); int repair(std::string arg); + int resize(std::string arg); int changefilesystem(std::string arg); int startmtp(std::string arg); int stopmtp(std::string arg); -- cgit v1.2.3