Fix the storage size calculation bug.
authorSung-jae Park <nicesj.park@samsung.com>
Fri, 26 Apr 2013 09:14:59 +0000 (18:14 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Fri, 26 Apr 2013 09:14:59 +0000 (18:14 +0900)
Change-Id: I8913179327eb67129d918554006b2d251a36f572

include/util.h
packaging/data-provider-master.spec
src/util.c

index 75e4715..bd26e2a 100644 (file)
@@ -22,7 +22,7 @@ extern int util_unlink(const char *filename);
 extern int util_unlink_files(const char *folder);
 extern char *util_slavename(void);
 extern const char *util_basename(const char *name);
-extern unsigned long util_free_space(const char *path);
+extern unsigned long long util_free_space(const char *path);
 extern char *util_replace_string(const char *src, const char *pattern, const char *replace);
 extern const char *util_uri_to_path(const char *uri);
 extern void *util_timer_add(double interval, Eina_Bool (*cb)(void *data), void *data);
index 1a6aef1..9f634f3 100755 (executable)
@@ -1,6 +1,6 @@
 Name: data-provider-master
 Summary: Master service provider for liveboxes.
-Version: 0.22.1
+Version: 0.22.2
 Release: 1
 Group: HomeTF/Livebox
 License: Flora License
index b9c62bf..bb185ea 100644 (file)
@@ -20,7 +20,7 @@
 #include <errno.h>
 #include <unistd.h>
 #include <stdlib.h>
-#include <sys/statvfs.h>
+#include <sys/vfs.h>
 #include <sys/types.h>
 #include <dirent.h>
 #include <ctype.h>
@@ -191,18 +191,21 @@ HAPI const char *util_basename(const char *name)
        return length <= 0 ? name : (name + length + (name[length] == '/'));
 }
 
-HAPI unsigned long util_free_space(const char *path)
+/*!
+ * Return size of stroage in MegaBytes unit.
+ */
+HAPI unsigned long long util_free_space(const char *path)
 {
-       struct statvfs st;
-       unsigned long space;
+       struct statfs st;
+       unsigned long long space;
 
-       if (statvfs(path, &st) < 0) {
+       if (statfs(path, &st) < 0) {
                ErrPrint("statvfs: %s\n", strerror(errno));
                return 0lu;
        }
 
-       space = st.f_bsize * st.f_bfree;
-       DbgPrint("Available size: %lu, f_bsize: %lu, f_bfree: %lu\n", space, st.f_bsize, st.f_bfree);
+       space = (unsigned long long)st.f_bsize * (unsigned long long)st.f_bavail;
+       DbgPrint("Available size: %llu, f_bsize: %lu, f_bavail: %lu\n", space, st.f_bsize, st.f_bavail);
        /*!
         * \note
         * Must have to check the overflow