wait for cryptfs device node to come up
this is to prevent a race condition to occur when mounting an adopted
storage volume just after it was decrypted. After setting up the
decrypted volume using cryptfs_setup_ext_volume(), Decrypt_Adopted()
immediately calls Mount(), which will call Check_FS_Type(), which will
fail in blkid_new_probe_from_filename, as the device node was not
created yet.
Change-Id: Ic5a274c2066ab278c9b7f1c8b83b820e552ca344
diff --git a/partition.cpp b/partition.cpp
index bf87de3..89650db 100644
--- a/partition.cpp
+++ b/partition.cpp
@@ -836,7 +836,7 @@
Backup_Path = Symlink_Mount_Point;
Make_Dir("/and-sec", true);
Recreate_AndSec_Folder();
- Mount_Storage_Retry();
+ Mount_Storage_Retry(true);
}
void TWPartition::Setup_Data_Media() {
@@ -900,16 +900,17 @@
}
}
-void TWPartition::Mount_Storage_Retry(void) {
+bool TWPartition::Mount_Storage_Retry(bool Display_Error) {
// On some devices, storage doesn't want to mount right away, retry and sleep
- if (!Mount(true)) {
+ if (!Mount(Display_Error)) {
int retry_count = 5;
while (retry_count > 0 && !Mount(false)) {
usleep(500000);
retry_count--;
}
- Mount(true);
+ return Mount(Display_Error);
}
+ return true;
}
bool TWPartition::Find_MTD_Block_Device(string MTD_Name) {
@@ -2806,7 +2807,7 @@
Is_Decrypted = true;
Is_Encrypted = true;
Find_Actual_Block_Device();
- if (!Mount(false)) {
+ if (!Mount_Storage_Retry(false)) {
LOGERR("Failed to mount decrypted adopted storage device\n");
Is_Decrypted = false;
Is_Encrypted = false;