Add options to repair or change file system
Change-Id: I9043e98e1e1ed4722f05c13a60b43d2d0bf739f6
This commit is contained in:
committed by
Gerrit Code Review
parent
93cb1ef2eb
commit
87c7bac9c9
+95
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user