Handle storage devices that are slow to mount

This commit is contained in:
Dees_Troy
2012-10-13 22:07:49 -04:00
parent 7a47e7f4d2
commit 8e337f3605
2 changed files with 16 additions and 0 deletions
+15
View File
@@ -249,6 +249,7 @@ bool TWPartition::Process_Fstab_Line(string Line, bool Display_Error) {
Removable = true;
#ifndef RECOVERY_SDCARD_ON_DATA
Setup_AndSec();
Mount_Storage_Retry();
#endif
}
#endif
@@ -258,6 +259,7 @@ bool TWPartition::Process_Fstab_Line(string Line, bool Display_Error) {
Storage_Path = EXPAND(TW_INTERNAL_STORAGE_PATH);
#ifndef RECOVERY_SDCARD_ON_DATA
Setup_AndSec();
Mount_Storage_Retry();
#endif
}
#else
@@ -266,6 +268,7 @@ bool TWPartition::Process_Fstab_Line(string Line, bool Display_Error) {
Storage_Path = "/emmc";
#ifndef RECOVERY_SDCARD_ON_DATA
Setup_AndSec();
Mount_Storage_Retry();
#endif
}
#endif
@@ -444,6 +447,18 @@ void TWPartition::Find_Real_Block_Device(string& Block, bool Display_Error) {
}
}
void TWPartition::Mount_Storage_Retry(void) {
// On some devices, storage doesn't want to mount right away, retry and sleep
if (!Mount(false)) {
int retry_count = 5;
while (retry_count > 0 && !Mount(false)) {
usleep(500000);
retry_count--;
}
Mount(true);
}
}
bool TWPartition::Find_MTD_Block_Device(string MTD_Name) {
FILE *fp = NULL;
char line[255];