Fix all mis-used types about large file support
[platform/core/security/ode.git] / server / engine / encryption / ecryptfs-engine.cpp
index b78e614..51fb925 100644 (file)
@@ -133,14 +133,14 @@ namespace ode {
 
 namespace {
 
-unsigned long long getAvailableSpace(const std::string& mountPoint)
+off_t getAvailableSpace(const std::string& mountPoint)
 {
        struct statfs statbuf;
        if (::statfs(mountPoint.c_str(), &statbuf)) {
                throw runtime::Exception("Failed to access " + mountPoint);
        }
 
-       return (unsigned long long)statbuf.f_bfree * statbuf.f_bsize;
+       return statbuf.f_bfree * statbuf.f_bsize;
 }
 
 bool wasEncrypted(const std::string &path)
@@ -167,9 +167,9 @@ bool wasEncrypted(const std::string &path)
 #endif
 }
 
-unsigned long long getEncryptedSize(const runtime::File &file) {
-       unsigned long long originalSize = file.size();
-       unsigned long long result = 0;
+off_t getEncryptedSize(const runtime::File &file) {
+       off_t originalSize = file.size();
+       off_t result = 0;
 
        if (originalSize % 4096) {
                originalSize = (1 + originalSize / 4096) * 4096;
@@ -187,7 +187,7 @@ unsigned long long getEncryptedSize(const runtime::File &file) {
 
        //TODO : block size have to not hard-coded.
        //       If there is a better way, the followings have to be changed.
-       unsigned int blockSize = 4096;
+       blksize_t blockSize = 4096;
        if (result % blockSize) {
                result = (1 + result / blockSize) * blockSize;
        }
@@ -195,9 +195,9 @@ unsigned long long getEncryptedSize(const runtime::File &file) {
        return result;
 }
 
-unsigned long long getDecryptedSize(const runtime::File &file) {
-       unsigned long long originalSize = file.size();
-       unsigned long long result = originalSize;
+off_t getDecryptedSize(const runtime::File &file) {
+       off_t originalSize = file.size();
+       off_t result = originalSize;
 
        if (wasEncrypted(file.getPath())) {
                if (originalSize > 2 * 4096) {
@@ -209,7 +209,7 @@ unsigned long long getDecryptedSize(const runtime::File &file) {
 
        //TODO : block size have to not hard-coded.
        //       If there is a better way, the followings have to be changed.
-       unsigned int blockSize = 4096;
+       blksize_t blockSize = 4096;
        if (result % blockSize) {
                result = (1 + result / blockSize) * blockSize;
        }
@@ -218,9 +218,9 @@ unsigned long long getDecryptedSize(const runtime::File &file) {
 }
 
 bool isEnoughToCopyInPlace(const std::string& path,
-       const std::function<unsigned long long(const runtime::File&)> getSizeFunc)
+       const std::function<off_t(const runtime::File&)> getSizeFunc)
 {
-       unsigned long long availableSpace = getAvailableSpace(path);
+       off_t availableSpace = getAvailableSpace(path);
 
        std::function<bool(const std::string &path)> check;
        check = [&check, &getSizeFunc, availableSpace](const std::string &path) {
@@ -245,7 +245,7 @@ bool isEnoughToCopyInPlace(const std::string& path,
 void copyInPlace(const std::string& source, const std::string& destination,
                                        const std::string& temp,
                                        const std::function<bool(const std::string&)> &isTarget,
-                                       const std::function<void(unsigned long long)> &addProgress)
+                                       const std::function<void(off_t)> &addProgress)
 {
        for (runtime::DirectoryIterator iter(source), end;
                        iter != end; ++iter) {
@@ -383,7 +383,7 @@ void EcryptfsEngine::encrypt(const data &key, unsigned int options)
        }
 
        try {
-               unsigned long long totalSize = getAvailableSpace(source), current;
+               off_t totalSize = getAvailableSpace(source), current;
            runtime::File tempDir(destination + "/" ENCRYPTION_TMP_DIR);
 
                if (tempDir.exists()) {
@@ -396,7 +396,7 @@ void EcryptfsEngine::encrypt(const data &key, unsigned int options)
                                        [](const std::string &file) {
                                                return true;
                                        },
-                                       [&current, &totalSize, this](unsigned long long size) {
+                                       [&current, &totalSize, this](off_t size) {
                                                current += size;
                                                this->progress.update(current * 100 / totalSize);
                                        });
@@ -424,7 +424,7 @@ void EcryptfsEngine::decrypt(const data &key, unsigned int options)
        progress.update(0);
 
        try {
-               unsigned long long totalSize = getAvailableSpace(source), current;
+               off_t totalSize = getAvailableSpace(source), current;
            runtime::File tempDir(source + "/" ENCRYPTION_TMP_DIR);
                runtime::File tempMountpoint(tempDir.getPath() + "/mount");
 
@@ -438,7 +438,7 @@ void EcryptfsEngine::decrypt(const data &key, unsigned int options)
 
                copyInPlace(tempMountpoint.getPath(), source,
                                        tempDir.getPath(), wasEncrypted,
-                                       [&current, &totalSize, this](unsigned long long size) {
+                                       [&current, &totalSize, this](off_t size) {
                                                current += size;
                                                this->progress.update(current * 100 / totalSize);
                                        });