summaryrefslogtreecommitdiffstats
path: root/partition.cpp
diff options
context:
space:
mode:
authorEthan Yonker <dees_troy@teamw.in>2014-05-26 04:41:08 +0200
committerGerrit Code Review <gerrit2@gerrit>2014-06-04 15:46:32 +0200
commit87c7bac9c9a2875feb8cf67284f3530fc371c468 (patch)
treed36289e8510d5ad294cb03e0652e34bbba3dc2f5 /partition.cpp
parentFix crash while loading config due to incorrect tw_storage_path (diff)
downloadandroid_bootable_recovery-87c7bac9c9a2875feb8cf67284f3530fc371c468.tar
android_bootable_recovery-87c7bac9c9a2875feb8cf67284f3530fc371c468.tar.gz
android_bootable_recovery-87c7bac9c9a2875feb8cf67284f3530fc371c468.tar.bz2
android_bootable_recovery-87c7bac9c9a2875feb8cf67284f3530fc371c468.tar.lz
android_bootable_recovery-87c7bac9c9a2875feb8cf67284f3530fc371c468.tar.xz
android_bootable_recovery-87c7bac9c9a2875feb8cf67284f3530fc371c468.tar.zst
android_bootable_recovery-87c7bac9c9a2875feb8cf67284f3530fc371c468.zip
Diffstat (limited to 'partition.cpp')
-rw-r--r--partition.cpp96
1 files changed, 95 insertions, 1 deletions
diff --git a/partition.cpp b/partition.cpp
index e554ac7eb..e92fccfd2 100644
--- a/partition.cpp
+++ b/partition.cpp
@@ -1105,7 +1105,7 @@ bool TWPartition::Wipe(string New_File_System) {
else
unlink("/.layout_version");
- if (Has_Data_Media) {
+ if (Has_Data_Media && Current_File_System == New_File_System) {
wiped = Wipe_Data_Without_Wiping_Media();
} else {
@@ -1185,6 +1185,100 @@ bool TWPartition::Wipe_AndSec(void) {
return true;
}
+bool TWPartition::Can_Repair() {
+ if (Current_File_System == "vfat" && TWFunc::Path_Exists("/sbin/dosfsck"))
+ return true;
+ else if ((Current_File_System == "ext2" || Current_File_System == "ext3" || Current_File_System == "ext4") && TWFunc::Path_Exists("/sbin/e2fsck"))
+ return true;
+ else if (Current_File_System == "exfat" && TWFunc::Path_Exists("/sbin/fsck.exfat"))
+ return true;
+ else if (Current_File_System == "f2fs" && TWFunc::Path_Exists("/sbin/fsck.f2fs"))
+ return true;
+ return false;
+}
+
+bool TWPartition::Repair() {
+ string command;
+
+ if (Current_File_System == "vfat") {
+ if (!TWFunc::Path_Exists("/sbin/dosfsck")) {
+ gui_print("dosfsck does not exist! Cannot repair!\n");
+ return false;
+ }
+ if (!UnMount(true))
+ return false;
+ gui_print("Repairing %s using dosfsck...\n", Display_Name.c_str());
+ Find_Actual_Block_Device();
+ command = "/sbin/dosfsck -y " + Actual_Block_Device;
+ LOGINFO("Repair command: %s\n", command.c_str());
+ if (TWFunc::Exec_Cmd(command) == 0) {
+ gui_print("Done.\n");
+ return true;
+ } else {
+ LOGERR("Unable to repair '%s'.\n", Mount_Point.c_str());
+ return false;
+ }
+ }
+ if (Current_File_System == "ext2" || Current_File_System == "ext3" || Current_File_System == "ext4") {
+ if (!TWFunc::Path_Exists("/sbin/e2fsck")) {
+ gui_print("e2fsck does not exist! Cannot repair!\n");
+ return false;
+ }
+ if (!UnMount(true))
+ return false;
+ gui_print("Repairing %s using e2fsck...\n", Display_Name.c_str());
+ Find_Actual_Block_Device();
+ command = "/sbin/e2fsck -p " + Actual_Block_Device;
+ LOGINFO("Repair command: %s\n", command.c_str());
+ if (TWFunc::Exec_Cmd(command) == 0) {
+ gui_print("Done.\n");
+ return true;
+ } else {
+ LOGERR("Unable to repair '%s'.\n", Mount_Point.c_str());
+ return false;
+ }
+ }
+ if (Current_File_System == "exfat") {
+ if (!TWFunc::Path_Exists("/sbin/fsck.exfat")) {
+ gui_print("fsck.exfat does not exist! Cannot repair!\n");
+ return false;
+ }
+ if (!UnMount(true))
+ return false;
+ gui_print("Repairing %s using fsck.exfat...\n", Display_Name.c_str());
+ Find_Actual_Block_Device();
+ command = "/sbin/fsck.exfat " + Actual_Block_Device;
+ LOGINFO("Repair command: %s\n", command.c_str());
+ if (TWFunc::Exec_Cmd(command) == 0) {
+ gui_print("Done.\n");
+ return true;
+ } else {
+ LOGERR("Unable to repair '%s'.\n", Mount_Point.c_str());
+ return false;
+ }
+ }
+ if (Current_File_System == "f2fs") {
+ if (!TWFunc::Path_Exists("/sbin/fsck.f2fs")) {
+ gui_print("fsck.f2fs does not exist! Cannot repair!\n");
+ return false;
+ }
+ if (!UnMount(true))
+ return false;
+ gui_print("Repairing %s using fsck.f2fs...\n", Display_Name.c_str());
+ Find_Actual_Block_Device();
+ command = "/sbin/fsck.f2fs " + Actual_Block_Device;
+ LOGINFO("Repair command: %s\n", command.c_str());
+ if (TWFunc::Exec_Cmd(command) == 0) {
+ gui_print("Done.\n");
+ return true;
+ } else {
+ LOGERR("Unable to repair '%s'.\n", Mount_Point.c_str());
+ return false;
+ }
+ }
+ return false;
+}
+
bool TWPartition::Backup(string backup_folder) {
if (Backup_Method == FILES)
return Backup_Tar(backup_folder);