Handle storage devices that are slow to mount
diff --git a/partition.cpp b/partition.cpp
index 505e310..a7adf99 100644
--- a/partition.cpp
+++ b/partition.cpp
@@ -249,6 +249,7 @@
Removable = true;
#ifndef RECOVERY_SDCARD_ON_DATA
Setup_AndSec();
+ Mount_Storage_Retry();
#endif
}
#endif
@@ -258,6 +259,7 @@
Storage_Path = EXPAND(TW_INTERNAL_STORAGE_PATH);
#ifndef RECOVERY_SDCARD_ON_DATA
Setup_AndSec();
+ Mount_Storage_Retry();
#endif
}
#else
@@ -266,6 +268,7 @@
Storage_Path = "/emmc";
#ifndef RECOVERY_SDCARD_ON_DATA
Setup_AndSec();
+ Mount_Storage_Retry();
#endif
}
#endif
@@ -444,6 +447,18 @@
}
}
+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];