add function to partition.cpp to return max file size to mtp responder
Change-Id: If8114b5eac741db6c512fb35cb48e3825c2ff098
This commit is contained in:
+4
-2
@@ -1078,8 +1078,10 @@ MtpResponseCode MtpServer::doSendObject() {
|
||||
unlink(mSendObjectFilePath);
|
||||
if (errno == ECANCELED)
|
||||
result = MTP_RESPONSE_TRANSACTION_CANCELLED;
|
||||
else
|
||||
else {
|
||||
MTPD("errno: %d\n", errno);
|
||||
result = MTP_RESPONSE_GENERAL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
@@ -1093,7 +1095,7 @@ done:
|
||||
mSendObjectHandle = kInvalidObjectHandle;
|
||||
MTPD("result: %d\n", result);
|
||||
mSendObjectFormat = 0;
|
||||
return MTP_RESPONSE_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
static void deleteRecursive(const char* path) {
|
||||
|
||||
@@ -123,7 +123,7 @@ void twmtp_MtpServer::add_storage()
|
||||
int storageID = stores->at(i)->mtpid;
|
||||
long reserveSpace = 1;
|
||||
bool removable = false;
|
||||
long maxFileSize = 1000000000L;
|
||||
long maxFileSize = stores->at(i)->maxFileSize;
|
||||
if (descriptionStr != "") {
|
||||
MtpStorage* storage = new MtpStorage(storageID, &pathStr[0], &descriptionStr[0], reserveSpace, removable, maxFileSize, refserver);
|
||||
server->addStorage(storage);
|
||||
|
||||
@@ -36,6 +36,7 @@ typedef struct Storage {
|
||||
std::string display;
|
||||
std::string mount;
|
||||
int mtpid;
|
||||
uint64_t maxFileSize;
|
||||
} storage;
|
||||
|
||||
typedef std::vector<storage*> storages;
|
||||
|
||||
+2
-1
@@ -107,11 +107,12 @@ pid_t twrpMtp::forkserver(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void twrpMtp::addStorage(std::string display, std::string path, int mtpid) {
|
||||
void twrpMtp::addStorage(std::string display, std::string path, int mtpid, uint64_t maxFileSize) {
|
||||
s = new storage;
|
||||
s->display = display;
|
||||
s->mount = path;
|
||||
s->mtpid = mtpid;
|
||||
s->maxFileSize = maxFileSize;
|
||||
MTPD("twrpMtp mtpid: %d\n", s->mtpid);
|
||||
mtpstorages->push_back(s);
|
||||
}
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ class twrpMtp {
|
||||
twrpMtp(int debug_enabled /* = 0 */);
|
||||
pthread_t threadserver(void);
|
||||
pid_t forkserver(void);
|
||||
void addStorage(std::string display, std::string path, int mtpid);
|
||||
void addStorage(std::string display, std::string path, int mtpid, uint64_t maxFileSize);
|
||||
private:
|
||||
int start(void);
|
||||
typedef int (twrpMtp::*ThreadPtr)(void);
|
||||
|
||||
@@ -2035,3 +2035,28 @@ void TWPartition::Recreate_AndSec_Folder(void) {
|
||||
PartitionManager.UnMount_By_Path(Symlink_Mount_Point, true);
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t TWPartition::Get_Max_FileSize() {
|
||||
uint64_t maxFileSize = 0;
|
||||
const uint64_t constGB = (uint64_t) 1024 * 1024 * 1024;
|
||||
const uint64_t constTB = (uint64_t) constGB * 1024;
|
||||
const uint64_t constPB = (uint64_t) constTB * 1024;
|
||||
const uint64_t constEB = (uint64_t) constPB * 1024;
|
||||
|
||||
if (Current_File_System == "ext4")
|
||||
maxFileSize = 16 * constTB; //16 TB
|
||||
else if (Current_File_System == "vfat")
|
||||
maxFileSize = 4 * constGB; //4 GB
|
||||
else if (Current_File_System == "ntfs")
|
||||
maxFileSize = 256 * constTB; //256 TB
|
||||
if (Current_File_System == "exfat")
|
||||
maxFileSize = 16 * constPB; //16 PB
|
||||
else if (Current_File_System == "ext3")
|
||||
maxFileSize = 2 * constTB; //2 TB
|
||||
else if (Current_File_System == "f2fs")
|
||||
maxFileSize = 3.94 * constTB; //3.94 TB
|
||||
else
|
||||
maxFileSize = 100000000L;
|
||||
return maxFileSize - 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1914,7 +1914,7 @@ bool TWPartitionManager::Enable_MTP(void) {
|
||||
if ((*iter)->Is_Storage && (*iter)->Is_Present && (*iter)->Mount(false)) {
|
||||
++storageid;
|
||||
printf("twrp addStorage %s, mtpstorageid: %u\n", (*iter)->Storage_Path.c_str(), storageid);
|
||||
mtp->addStorage((*iter)->Storage_Name, (*iter)->Storage_Path, storageid);
|
||||
mtp->addStorage((*iter)->Storage_Name, (*iter)->Storage_Path, storageid, (*iter)->Get_Max_FileSize());
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ public:
|
||||
bool Wipe(); // Wipes the partition
|
||||
bool Wipe_AndSec(); // Wipes android secure
|
||||
bool Can_Repair(); // Checks to see if we have everything needed to be able to repair the current file system
|
||||
uint64_t Get_Max_FileSize(); //get partition maxFileSie
|
||||
bool Repair(); // Repairs the current file system
|
||||
bool Backup(string backup_folder, const unsigned long long *overall_size, const unsigned long long *other_backups_size); // Backs up the partition to the folder specified
|
||||
bool Check_MD5(string restore_folder); // Checks MD5 of a backup
|
||||
|
||||
Reference in New Issue
Block a user