summaryrefslogtreecommitdiffstats
path: root/partitionmanager.cpp
diff options
context:
space:
mode:
authorDees_Troy <dees_troy@teamw.in>2012-10-14 04:17:20 +0200
committerDees_Troy <dees_troy@teamw.in>2012-10-14 04:17:20 +0200
commitf4ca6128b73d3d1f358c2ee0cbf9b1aada22d931 (patch)
tree6dc2904f66fc35997349e477bf9926ab8f7af9d8 /partitionmanager.cpp
parentHandle storage devices that are slow to mount (diff)
downloadandroid_bootable_recovery-f4ca6128b73d3d1f358c2ee0cbf9b1aada22d931.tar
android_bootable_recovery-f4ca6128b73d3d1f358c2ee0cbf9b1aada22d931.tar.gz
android_bootable_recovery-f4ca6128b73d3d1f358c2ee0cbf9b1aada22d931.tar.bz2
android_bootable_recovery-f4ca6128b73d3d1f358c2ee0cbf9b1aada22d931.tar.lz
android_bootable_recovery-f4ca6128b73d3d1f358c2ee0cbf9b1aada22d931.tar.xz
android_bootable_recovery-f4ca6128b73d3d1f358c2ee0cbf9b1aada22d931.tar.zst
android_bootable_recovery-f4ca6128b73d3d1f358c2ee0cbf9b1aada22d931.zip
Diffstat (limited to 'partitionmanager.cpp')
-rw-r--r--partitionmanager.cpp94
1 files changed, 60 insertions, 34 deletions
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index fdc3fba44..9b4de4e07 100644
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -1625,48 +1625,74 @@ int TWPartitionManager::usb_storage_enable(void) {
DataManager::GetValue(TW_HAS_DUAL_STORAGE, has_dual);
DataManager::GetValue(TW_HAS_DATA_MEDIA, has_data_media);
if (has_dual == 1 && has_data_media == 0) {
- Part = Find_Partition_By_Path(DataManager::GetSettingsStoragePath());
- if (Part == NULL) {
- LOGE("Unable to locate volume information.");
- return false;
- }
- if (!Part->UnMount(true))
- return false;
+ sprintf(lun_file, CUSTOM_LUN_FILE, 1);
+ if (!TWFunc::Path_Exists(lun_file)) {
+ // Device doesn't have multiple lun files, mount current storage
+ Part = Find_Partition_By_Path(DataManager::GetCurrentStoragePath());
+ if (Part == NULL) {
+ LOGE("Unable to locate volume information for USB storage mode.");
+ return false;
+ }
+ if (!Part->UnMount(true))
+ return false;
- sprintf(lun_file, CUSTOM_LUN_FILE, 0);
- if ((fd = open(lun_file, O_WRONLY)) < 0) {
- LOGE("Unable to open ums lunfile '%s': (%s)\n", lun_file, strerror(errno));
- return false;
- }
+ sprintf(lun_file, CUSTOM_LUN_FILE, 0);
+ if ((fd = open(lun_file, O_WRONLY)) < 0) {
+ LOGE("Unable to open ums lunfile '%s': (%s)\n", lun_file, strerror(errno));
+ return false;
+ }
- if (write(fd, Part->Actual_Block_Device.c_str(), Part->Actual_Block_Device.size()) < 0) {
- LOGE("Unable to write to ums lunfile '%s': (%s)\n", lun_file, strerror(errno));
+ if (write(fd, Part->Actual_Block_Device.c_str(), Part->Actual_Block_Device.size()) < 0) {
+ LOGE("Unable to write to ums lunfile '%s': (%s)\n", lun_file, strerror(errno));
+ close(fd);
+ return false;
+ }
close(fd);
- return false;
- }
- close(fd);
+ } else {
+ // Device has multiple lun files
+ Part = Find_Partition_By_Path(DataManager::GetSettingsStoragePath());
+ if (Part == NULL) {
+ LOGE("Unable to locate volume information.");
+ return false;
+ }
+ if (!Part->UnMount(true))
+ return false;
- DataManager::GetValue(TW_EXTERNAL_PATH, ext_path);
- Part = Find_Partition_By_Path(ext_path);
- if (Part == NULL) {
- LOGE("Unable to locate volume information.\n");
- return false;
- }
- if (!Part->UnMount(true))
- return false;
+ sprintf(lun_file, CUSTOM_LUN_FILE, 0);
+ if ((fd = open(lun_file, O_WRONLY)) < 0) {
+ LOGE("Unable to open ums lunfile '%s': (%s)\n", lun_file, strerror(errno));
+ return false;
+ }
- sprintf(lun_file, CUSTOM_LUN_FILE, 1);
- if ((fd = open(lun_file, O_WRONLY)) < 0) {
- LOGE("Unable to open ums lunfile '%s': (%s)\n", lun_file, strerror(errno));
- return false;
- }
+ if (write(fd, Part->Actual_Block_Device.c_str(), Part->Actual_Block_Device.size()) < 0) {
+ LOGE("Unable to write to ums lunfile '%s': (%s)\n", lun_file, strerror(errno));
+ close(fd);
+ return false;
+ }
+ close(fd);
- if (write(fd, Part->Actual_Block_Device.c_str(), Part->Actual_Block_Device.size()) < 0) {
- LOGE("Unable to write to ums lunfile '%s': (%s)\n", lun_file, strerror(errno));
+ DataManager::GetValue(TW_EXTERNAL_PATH, ext_path);
+ Part = Find_Partition_By_Path(ext_path);
+ if (Part == NULL) {
+ LOGE("Unable to locate volume information.\n");
+ return false;
+ }
+ if (!Part->UnMount(true))
+ return false;
+
+ sprintf(lun_file, CUSTOM_LUN_FILE, 1);
+ if ((fd = open(lun_file, O_WRONLY)) < 0) {
+ LOGE("Unable to open ums lunfile '%s': (%s)\n", lun_file, strerror(errno));
+ return false;
+ }
+
+ if (write(fd, Part->Actual_Block_Device.c_str(), Part->Actual_Block_Device.size()) < 0) {
+ LOGE("Unable to write to ums lunfile '%s': (%s)\n", lun_file, strerror(errno));
+ close(fd);
+ return false;
+ }
close(fd);
- return false;
}
- close(fd);
} else {
if (has_data_media == 0)
ext_path = DataManager::GetCurrentStoragePath();