From c4063451edc4c8d8ee6d199e22e8fdbdef0db9db Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Mon, 13 Mar 2017 11:20:25 +0900 Subject: [PATCH] Fix wrong available mem calculation of internal storage Change-Id: I3562eb06879c06744b38b93c110693f47cd77847 Signed-off-by: jongmyeongko --- plugin/app2sd/server/app2sd_internals.c | 18 ++++++++---------- plugin/app2sd/server/app2sd_internals_utils.c | 6 +++--- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/plugin/app2sd/server/app2sd_internals.c b/plugin/app2sd/server/app2sd_internals.c index afff360..89931e5 100644 --- a/plugin/app2sd/server/app2sd_internals.c +++ b/plugin/app2sd/server/app2sd_internals.c @@ -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 diff --git a/plugin/app2sd/server/app2sd_internals_utils.c b/plugin/app2sd/server/app2sd_internals_utils.c index 3843349..705d52f 100644 --- a/plugin/app2sd/server/app2sd_internals_utils.c +++ b/plugin/app2sd/server/app2sd_internals_utils.c @@ -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; } -- 2.7.4