Fix wrong available mem calculation of internal storage
[platform/core/appfw/app2sd.git] / plugin / app2sd / server / app2sd_internals.c
index afff360..89931e5 100644 (file)
@@ -1127,7 +1127,6 @@ static int _app2sd_move_app_to_internal(const char *pkgid, GList *dir_list,
        app2ext_dir_details *dir_detail = NULL;
        int reqd_size = 0;
        int free_internal_mem = 0;
-       struct statvfs buf = {0,};
        unsigned long long temp = 0;
        char err_buf[1024] = {0,};
        char *encoded_id = NULL;
@@ -1160,14 +1159,13 @@ static int _app2sd_move_app_to_internal(const char *pkgid, GList *dir_list,
                fp = NULL;
        }
 
-       memset((void *)&buf, '\0', sizeof(struct statvfs));
-       ret = statvfs(INTERNAL_STORAGE_PATH, &buf);
-       if (0 == ret) {
-               temp = (buf.f_bsize * buf.f_bavail) / (1024 * 1024);
-               free_internal_mem = (int)temp;
-       } else {
-               _E("unable to get internal storage size");
-               return APP2EXT_ERROR_MMC_INSUFFICIENT_MEMORY;
+       /* find avialable free memory in the internal storage */
+       ret = _app2sd_get_available_free_memory(INTERNAL_STORAGE_PATH,
+               &free_internal_mem);
+       if (ret) {
+               _E("unable to get available free memory in internal (%d)",
+                       ret);
+               return APP2EXT_ERROR_MMC_STATUS;
        }
 
        fp = fopen(loopback_device, "r+");
@@ -1187,7 +1185,7 @@ static int _app2sd_move_app_to_internal(const char *pkgid, GList *dir_list,
                return APP2EXT_ERROR_LOOPBACK_DEVICE_UNAVAILABLE;
        }
 
-       _D("reqd size: (%d)MB, free internal mem: (%d)MB",
+       _I("reqd size: (%d)MB, free internal mem: (%d)MB",
                reqd_size, free_internal_mem);
 
        /* if avaialalbe free memory in internal storage is