diff options
-rw-r--r-- | data.cpp | 16 | ||||
-rw-r--r-- | partitionmanager.cpp | 4 | ||||
-rw-r--r-- | variables.h | 4 |
3 files changed, 19 insertions, 5 deletions
@@ -675,9 +675,23 @@ void DataManager::SetDefaultValues() mConstValues.insert(make_pair(TW_DONT_UNMOUNT_SYSTEM, "0")); #endif #ifdef TW_NO_USB_STORAGE + printf("TW_NO_USB_STORAGE := true\n"); mConstValues.insert(make_pair(TW_HAS_USB_STORAGE, "0")); #else - mConstValues.insert(make_pair(TW_HAS_USB_STORAGE, "1")); + char lun_file[255]; + string Lun_File_str = CUSTOM_LUN_FILE; + size_t found = Lun_File_str.find("%"); + if (found != string::npos) { + sprintf(lun_file, CUSTOM_LUN_FILE, 0); + Lun_File_str = lun_file; + } + if (!TWFunc::Path_Exists(Lun_File_str)) { + LOGI("Lun file '%s' does not exist, USB storage mode disabled\n", Lun_File_str.c_str()); + mConstValues.insert(make_pair(TW_HAS_USB_STORAGE, "0")); + } else { + LOGI("Lun file '%s'\n", Lun_File_str.c_str()); + mConstValues.insert(make_pair(TW_HAS_USB_STORAGE, "1")); + } #endif #ifdef TW_INCLUDE_INJECTTWRP mConstValues.insert(make_pair(TW_HAS_INJECTTWRP, "1")); diff --git a/partitionmanager.cpp b/partitionmanager.cpp index c39a7d10d..5230810f1 100644 --- a/partitionmanager.cpp +++ b/partitionmanager.cpp @@ -1709,10 +1709,6 @@ int TWPartitionManager::Fix_Permissions(void) { } //partial kangbang from system/vold -#ifndef CUSTOM_LUN_FILE -#define CUSTOM_LUN_FILE "/sys/devices/platform/usb_mass_storage/lun%d/file" -#endif - int TWPartitionManager::Open_Lun_File(string Partition_Path, string Lun_File) { int fd; TWPartition* Part = Find_Partition_By_Path(Partition_Path); diff --git a/variables.h b/variables.h index 91c1f2c13..0b1c7ab58 100644 --- a/variables.h +++ b/variables.h @@ -167,4 +167,8 @@ // Max archive size for tar backups before we split (1.5GB) #define MAX_ARCHIVE_SIZE 1610612736LLU +#ifndef CUSTOM_LUN_FILE +#define CUSTOM_LUN_FILE "/sys/devices/platform/usb_mass_storage/lun%d/file" +#endif + #endif // _VARIABLES_HEADER_ |