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
@@ -1096,6 +1096,69 @@ int TWPartitionManager::Wipe_By_Name(string Name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int TWPartitionManager::Wipe_By_Path(string Path, string New_File_System) {
|
||||
std::vector<TWPartition*>::iterator iter;
|
||||
int ret = false;
|
||||
bool found = false;
|
||||
string Local_Path = TWFunc::Get_Root_Path(Path);
|
||||
|
||||
// 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)) {
|
||||
if (Path == "/and-sec")
|
||||
ret = (*iter)->Wipe_AndSec();
|
||||
else
|
||||
ret = (*iter)->Wipe(New_File_System);
|
||||
found = true;
|
||||
} else if ((*iter)->Is_SubPartition && (*iter)->SubPartition_Of == Local_Path) {
|
||||
(*iter)->Wipe(New_File_System);
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
return ret;
|
||||
} else
|
||||
LOGERR("Wipe: Unable to find partition for path '%s'\n", Local_Path.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
int TWPartitionManager::Wipe_By_Block(string Block, string New_File_System) {
|
||||
TWPartition* Part = Find_Partition_By_Block(Block);
|
||||
|
||||
if (Part) {
|
||||
if (Part->Has_SubPartition) {
|
||||
std::vector<TWPartition*>::iterator subpart;
|
||||
|
||||
for (subpart = Partitions.begin(); subpart != Partitions.end(); subpart++) {
|
||||
if ((*subpart)->Is_SubPartition && (*subpart)->SubPartition_Of == Part->Mount_Point)
|
||||
(*subpart)->Wipe(New_File_System);
|
||||
}
|
||||
return Part->Wipe(New_File_System);
|
||||
} else
|
||||
return Part->Wipe(New_File_System);
|
||||
}
|
||||
LOGERR("Wipe: Unable to find partition for block '%s'\n", Block.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
int TWPartitionManager::Wipe_By_Name(string Name, string New_File_System) {
|
||||
TWPartition* Part = Find_Partition_By_Name(Name);
|
||||
|
||||
if (Part) {
|
||||
if (Part->Has_SubPartition) {
|
||||
std::vector<TWPartition*>::iterator subpart;
|
||||
|
||||
for (subpart = Partitions.begin(); subpart != Partitions.end(); subpart++) {
|
||||
if ((*subpart)->Is_SubPartition && (*subpart)->SubPartition_Of == Part->Mount_Point)
|
||||
(*subpart)->Wipe();
|
||||
}
|
||||
return Part->Wipe(New_File_System);
|
||||
} else
|
||||
return Part->Wipe(New_File_System);
|
||||
}
|
||||
LOGERR("Wipe: Unable to find partition for name '%s'\n", Name.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
int TWPartitionManager::Factory_Reset(void) {
|
||||
std::vector<TWPartition*>::iterator iter;
|
||||
int ret = true;
|
||||
@@ -1234,6 +1297,78 @@ int TWPartitionManager::Wipe_Media_From_Data(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int TWPartitionManager::Repair_By_Path(string Path, bool Display_Error) {
|
||||
std::vector<TWPartition*>::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)->Repair();
|
||||
found = true;
|
||||
} else if ((*iter)->Is_SubPartition && (*iter)->SubPartition_Of == Local_Path) {
|
||||
(*iter)->Repair();
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
return ret;
|
||||
} else if (Display_Error) {
|
||||
LOGERR("Repair: Unable to find partition for path '%s'\n", Local_Path.c_str());
|
||||
} else {
|
||||
LOGINFO("Repair: Unable to find partition for path '%s'\n", Local_Path.c_str());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int TWPartitionManager::Repair_By_Block(string Block, bool Display_Error) {
|
||||
TWPartition* Part = Find_Partition_By_Block(Block);
|
||||
|
||||
if (Part) {
|
||||
if (Part->Has_SubPartition) {
|
||||
std::vector<TWPartition*>::iterator subpart;
|
||||
|
||||
for (subpart = Partitions.begin(); subpart != Partitions.end(); subpart++) {
|
||||
if ((*subpart)->Is_SubPartition && (*subpart)->SubPartition_Of == Part->Mount_Point)
|
||||
(*subpart)->Repair();
|
||||
}
|
||||
return Part->Repair();
|
||||
} else
|
||||
return Part->Repair();
|
||||
}
|
||||
if (Display_Error)
|
||||
LOGERR("Repair: Unable to find partition for block '%s'\n", Block.c_str());
|
||||
else
|
||||
LOGINFO("Repair: Unable to find partition for block '%s'\n", Block.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
int TWPartitionManager::Repair_By_Name(string Name, bool Display_Error) {
|
||||
TWPartition* Part = Find_Partition_By_Name(Name);
|
||||
|
||||
if (Part) {
|
||||
if (Part->Has_SubPartition) {
|
||||
std::vector<TWPartition*>::iterator subpart;
|
||||
|
||||
for (subpart = Partitions.begin(); subpart != Partitions.end(); subpart++) {
|
||||
if ((*subpart)->Is_SubPartition && (*subpart)->SubPartition_Of == Part->Mount_Point)
|
||||
(*subpart)->Repair();
|
||||
}
|
||||
return Part->Repair();
|
||||
} else
|
||||
return Part->Repair();
|
||||
}
|
||||
if (Display_Error)
|
||||
LOGERR("Repair: Unable to find partition for name '%s'\n", Name.c_str());
|
||||
else
|
||||
LOGINFO("Repair: Unable to find partition for name '%s'\n", Name.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
void TWPartitionManager::Refresh_Sizes(void) {
|
||||
Update_System_Details();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user