From 4b315bedf9493b3efe020b811edcaf2003bf4844 Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Fri, 26 Apr 2013 18:14:59 +0900 Subject: [PATCH] Fix the storage size calculation bug. Change-Id: I8913179327eb67129d918554006b2d251a36f572 --- include/util.h | 2 +- packaging/data-provider-master.spec | 2 +- src/util.c | 17 ++++++++++------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/include/util.h b/include/util.h index 75e4715..bd26e2a 100644 --- a/include/util.h +++ b/include/util.h @@ -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); diff --git a/packaging/data-provider-master.spec b/packaging/data-provider-master.spec index 1a6aef1..9f634f3 100755 --- a/packaging/data-provider-master.spec +++ b/packaging/data-provider-master.spec @@ -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 diff --git a/src/util.c b/src/util.c index b9c62bf..bb185ea 100644 --- a/src/util.c +++ b/src/util.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include @@ -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 -- 2.7.4