Fix wrong available mem calculation of internal storage 17/118517/1
authorjongmyeongko <jongmyeong.ko@samsung.com>
Mon, 13 Mar 2017 02:20:25 +0000 (11:20 +0900)
committerjongmyeong ko <jongmyeong.ko@samsung.com>
Mon, 13 Mar 2017 02:27:14 +0000 (19:27 -0700)
Change-Id: I3562eb06879c06744b38b93c110693f47cd77847
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
(cherry picked from commit c4063451edc4c8d8ee6d199e22e8fdbdef0db9db)

plugin/app2sd/server/app2sd_internals.c
plugin/app2sd/server/app2sd_internals_utils.c

index 5b01427..2efddc5 100644 (file)
@@ -1122,7 +1122,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;
@@ -1148,14 +1147,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+");
@@ -1175,7 +1173,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 4b50944..3387b49 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;
        }