summaryrefslogtreecommitdiffstats
path: root/media/mtp/MtpServer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'media/mtp/MtpServer.cpp')
-rw-r--r--media/mtp/MtpServer.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/media/mtp/MtpServer.cpp b/media/mtp/MtpServer.cpp
index d65845d..b371e41 100644
--- a/media/mtp/MtpServer.cpp
+++ b/media/mtp/MtpServer.cpp
@@ -104,10 +104,10 @@ MtpServer::MtpServer(int fd, MtpDatabase* database,
MtpServer::~MtpServer() {
}
-void MtpServer::addStorage(const char* filePath) {
+void MtpServer::addStorage(const char* filePath, uint64_t reserveSpace) {
int index = mStorages.size() + 1;
index |= index << 16; // set high and low part to our index
- MtpStorage* storage = new MtpStorage(index, filePath, mDatabase);
+ MtpStorage* storage = new MtpStorage(index, filePath, reserveSpace);
addStorage(storage);
}
@@ -687,6 +687,10 @@ MtpResponseCode MtpServer::doSendObjectInfo() {
if (access(path, R_OK) == 0)
return MTP_RESPONSE_GENERAL_ERROR;
+ // check space first
+ if (mSendObjectFileSize > storage->getFreeSpace())
+ return MTP_RESPONSE_STORAGE_FULL;
+
MtpObjectHandle handle = mDatabase->beginSendObject((const char*)path,
format, parent, storageID, mSendObjectFileSize, modifiedTime);
if (handle == kInvalidObjectHandle) {