Fix wrong available mem calculation of internal storage 15/118515/2 accepted/tizen/3.0/common/20170313.140408 accepted/tizen/3.0/ivi/20170313.085616 accepted/tizen/3.0/mobile/20170313.085537 accepted/tizen/3.0/tv/20170313.085547 accepted/tizen/3.0/wearable/20170313.085559 submit/tizen_3.0/20170313.023503
authorjongmyeongko <jongmyeong.ko@samsung.com>
Mon, 13 Mar 2017 02:20:25 +0000 (11:20 +0900)
committerjongmyeongko <jongmyeong.ko@samsung.com>
Mon, 13 Mar 2017 02:25:08 +0000 (11:25 +0900)
Change-Id: I3562eb06879c06744b38b93c110693f47cd77847
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
plugin/app2sd/server/app2sd_internals.c
plugin/app2sd/server/app2sd_internals_utils.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
index 3843349..705d52f 100644 (file)
@@ -106,8 +106,8 @@ int _app2sd_check_mmc_status(char **sdpath)
 }
 
 /*
- * This function returns the available free memory in the SD Card.
- * param [in]: sd_path: This is sd card access path.
+ * This function returns the available free memory in the storage.
+ * param [in]: mmc_path: This is storage access path.
  * param [out]: free_mem: Result will be available in this.
  * User has to pass valid memory address.
  * return: On success, it will return 0.
@@ -128,7 +128,7 @@ int _app2sd_get_available_free_memory(char *mmc_path, int *free_mem)
 
        ret = statvfs(mmc_path, &buf);
        if (ret) {
-               _E("unable to get SD Card memory information");
+               _E("unable to get memory information");
                return APP2EXT_ERROR_MMC_INFORMATION;
        }