static int __app2sd_create_app2sd_directories(uid_t uid)
{
int ret = 0;
- char app2sd_user_path[FILENAME_MAX] = { 0, };
mode_t mode = DIR_PERMS;
ret = mkdir(APP2SD_PATH, mode);
}
}
- if (!_is_global(uid)) {
- tzplatform_set_user(uid);
- snprintf(app2sd_user_path, FILENAME_MAX - 1, "%s/%s",
- APP2SD_PATH, tzplatform_getenv(TZ_USER_NAME));
- tzplatform_reset_user();
-
- ret = mkdir(app2sd_user_path, mode);
- if (ret) {
- if (errno != EEXIST) {
- _E("create directory failed," \
- " error no is (%d)", errno);
- return APP2EXT_ERROR_CREATE_DIRECTORY;
- }
- }
- }
-
return APP2EXT_SUCCESS;
}
char *result = NULL;
char application_path[FILENAME_MAX] = { 0, };
char loopback_device[FILENAME_MAX] = { 0, };
+ char *encoded_id = NULL;
int reqd_disk_size = size + ceil(size * 0.2);
/* validate the function parameter recieved */
return APP2EXT_ERROR_MMC_INSUFFICIENT_MEMORY;
}
+ encoded_id = _app2sd_get_encoded_name(pkgid, uid);
+ if (encoded_id == NULL) {
+ return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
+ }
if (_is_global(uid)) {
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
tzplatform_getenv(TZ_SYS_RW_APP), pkgid);
snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
- APP2SD_PATH, pkgid);
+ APP2SD_PATH, encoded_id);
} else {
tzplatform_set_user(uid);
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
tzplatform_getenv(TZ_USER_APP), pkgid);
- snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
- APP2SD_PATH, tzplatform_getenv(TZ_USER_NAME), pkgid);
+ snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
+ APP2SD_PATH, encoded_id);
tzplatform_reset_user();
}
+ free(encoded_id);
_D("application_path = (%s)", application_path);
_D("loopback_device = (%s)", loopback_device);
/* perform loopback encryption setup */
device_node = _app2sd_do_loopback_encryption_setup(pkgid,
- loopback_device);
+ loopback_device, uid);
if (!device_node) {
_E("loopback encryption setup failed");
_app2sd_delete_loopback_device(loopback_device);
char *device_name = NULL;
char application_path[FILENAME_MAX] = { 0, };
char loopback_device[FILENAME_MAX] = { 0, };
+ char *encoded_id = NULL;
int ret = APP2EXT_SUCCESS;
int pkgmgr_ret = 0;
}
sync();
+ encoded_id = _app2sd_get_encoded_name(pkgid, uid);
+ if (encoded_id == NULL) {
+ return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
+ }
if (_is_global(uid)) {
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
tzplatform_getenv(TZ_SYS_RW_APP), pkgid);
snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
- APP2SD_PATH, pkgid);
+ APP2SD_PATH, encoded_id);
} else {
tzplatform_set_user(uid);
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
tzplatform_getenv(TZ_USER_APP), pkgid);
- snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
- APP2SD_PATH, tzplatform_getenv(TZ_USER_NAME), pkgid);
+ snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
+ APP2SD_PATH, encoded_id);
tzplatform_reset_user();
}
+ free(encoded_id);
_D("application_path = (%s)", application_path);
_D("loopback_device = (%s)", loopback_device);
int ret = APP2EXT_SUCCESS;
char application_path[FILENAME_MAX] = { 0, };
char loopback_device[FILENAME_MAX] = { 0, };
+ char *encoded_id = NULL;
char *device_node = NULL;
char *result = NULL;
FILE *fp = NULL;
return APP2EXT_ERROR_MMC_STATUS;
}
+ encoded_id = _app2sd_get_encoded_name(pkgid, uid);
+ if (encoded_id == NULL) {
+ return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
+ }
/* check app entry is there in sd card or not. */
if (_is_global(uid)) {
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
tzplatform_getenv(TZ_SYS_RW_APP), pkgid);
snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
- APP2SD_PATH, pkgid);
+ APP2SD_PATH, encoded_id);
} else {
tzplatform_set_user(uid);
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
tzplatform_getenv(TZ_USER_APP), pkgid);
- snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
- APP2SD_PATH, tzplatform_getenv(TZ_USER_NAME), pkgid);
+ snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
+ APP2SD_PATH, encoded_id);
tzplatform_reset_user();
}
+ free(encoded_id);
_D("application_path = (%s)", application_path);
_D("loopback_device = (%s)", loopback_device);
/* do loopback setup */
device_node = _app2sd_do_loopback_encryption_setup(pkgid,
- loopback_device);
+ loopback_device, uid);
if (device_node == NULL) {
_E("loopback encryption setup failed");
return APP2EXT_ERROR_DO_LOSETUP;
int ret = APP2EXT_SUCCESS;
char application_path[FILENAME_MAX] = { 0, };
char loopback_device[FILENAME_MAX] = { 0, };
+ char *encoded_id = NULL;
FILE *fp = NULL;
/* validate the function parameter recieved */
return APP2EXT_ERROR_MMC_STATUS;
}
+ encoded_id = _app2sd_get_encoded_name(pkgid, uid);
+ if (encoded_id == NULL) {
+ return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
+ }
/* check app entry is there in sd card or not. */
if (_is_global(uid)) {
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
tzplatform_getenv(TZ_SYS_RW_APP), pkgid);
snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
- APP2SD_PATH, pkgid);
+ APP2SD_PATH, encoded_id);
} else {
tzplatform_set_user(uid);
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
tzplatform_getenv(TZ_USER_APP), pkgid);
- snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
- APP2SD_PATH, tzplatform_getenv(TZ_USER_NAME), pkgid);
+ snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
+ APP2SD_PATH, encoded_id);
tzplatform_reset_user();
}
+ free(encoded_id);
_D("application_path = (%s)", application_path);
_D("loopback_device = (%s)", loopback_device);
int ret = APP2EXT_SUCCESS;
char application_path[FILENAME_MAX] = { 0, };
char loopback_device[FILENAME_MAX] = { 0, };
+ char *encoded_id = NULL;
char *device_node = NULL;
FILE *fp = NULL;
goto END;
}
+ encoded_id = _app2sd_get_encoded_name(pkgid, uid);
+ if (encoded_id == NULL) {
+ return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
+ }
if (_is_global(uid)) {
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
tzplatform_getenv(TZ_SYS_RW_APP), pkgid);
snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
- APP2SD_PATH, pkgid);
+ APP2SD_PATH, encoded_id);
} else {
tzplatform_set_user(uid);
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
tzplatform_getenv(TZ_USER_APP), pkgid);
- snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
- APP2SD_PATH, tzplatform_getenv(TZ_USER_NAME), pkgid);
+ snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
+ APP2SD_PATH, encoded_id);
tzplatform_reset_user();
}
+ free(encoded_id);
_D("application_path = (%s)", application_path);
_D("loopback_device = (%s)", loopback_device);
if (NULL == device_node) {
/* do loopback setup */
device_node = _app2sd_do_loopback_encryption_setup(pkgid,
- loopback_device);
+ loopback_device, uid);
if (device_node == NULL) {
_E("loopback encryption setup failed");
ret = APP2EXT_ERROR_DO_LOSETUP;
{
char application_path[FILENAME_MAX] = { 0, };
char loopback_device[FILENAME_MAX] = { 0, };
+ char *encoded_id = NULL;
int ret = APP2EXT_SUCCESS;
/* validate the function parameter recieved */
goto END;
}
+ encoded_id = _app2sd_get_encoded_name(pkgid, uid);
+ if (encoded_id == NULL) {
+ return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
+ }
if (_is_global(uid)) {
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
tzplatform_getenv(TZ_SYS_RW_APP), pkgid);
snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
- APP2SD_PATH, pkgid);
+ APP2SD_PATH, encoded_id);
} else {
tzplatform_set_user(uid);
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
tzplatform_getenv(TZ_USER_APP), pkgid);
- snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
- APP2SD_PATH, tzplatform_getenv(TZ_USER_NAME), pkgid);
+ snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
+ APP2SD_PATH, encoded_id);
tzplatform_reset_user();
}
+ free(encoded_id);
_D("application_path = (%s)", application_path);
_D("loopback_device = (%s)", loopback_device);
int ret = APP2EXT_SUCCESS;
char loopback_device[FILENAME_MAX] = { 0, };
char application_path[FILENAME_MAX] = { 0, };
- char temp_pkgid[FILENAME_MAX] = { 0, };
- char temp_loopback_device[FILENAME_MAX] = { 0, };
- char temp_application_path[FILENAME_MAX] = { 0, };
+ char temp_uid[32] = { 0, };
+ char *temp_pkgid = NULL;
+ char *temp_loopback_device = NULL;
+ char *temp_application_path = NULL;
char *device_node = NULL;
+ char *encoded_id = NULL;
+ char *temp_encoded_id = NULL;
+ int len = 0;
unsigned long long curr_size = 0;
FILE *fp = NULL;
int reqd_disk_size = size + ceil(size * 0.2);
return APP2EXT_ERROR_MMC_STATUS;
}
+ encoded_id = _app2sd_get_encoded_name(pkgid, uid);
+ if (encoded_id == NULL) {
+ return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
+ }
if (_is_global(uid)) {
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
tzplatform_getenv(TZ_SYS_RW_APP), pkgid);
snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
- APP2SD_PATH, pkgid);
+ APP2SD_PATH, encoded_id);
} else {
tzplatform_set_user(uid);
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
tzplatform_getenv(TZ_USER_APP), pkgid);
- snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
- APP2SD_PATH, tzplatform_getenv(TZ_USER_NAME), pkgid);
+ snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
+ APP2SD_PATH, encoded_id);
tzplatform_reset_user();
}
+ free(encoded_id);
_D("application_path = (%s)", application_path);
_D("loopback_device = (%s)", loopback_device);
return APP2EXT_ERROR_LOOPBACK_DEVICE_UNAVAILABLE;
}
if ((int)curr_size < reqd_disk_size) {
- snprintf(temp_pkgid, FILENAME_MAX - 1, "%s.new", pkgid);
+ len = strlen(pkgid) + strlen(".new");
+ temp_pkgid = calloc(len + 1, sizeof(char));
+ if (temp_pkgid == NULL) {
+ _E("memory alloc failed");
+ return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
+ }
+ snprintf(temp_pkgid, len, "%s.new", pkgid);
+
if (_is_global(uid)) {
- snprintf(temp_application_path, FILENAME_MAX - 1,
- "%s/%s", tzplatform_getenv(TZ_SYS_RW_APP), temp_pkgid);
- snprintf(temp_loopback_device, FILENAME_MAX - 1,
- "%s/%s", APP2SD_PATH, temp_pkgid);
+ len = strlen(tzplatform_getenv(TZ_SYS_RW_APP)) + strlen(temp_pkgid) + 1;
+ temp_application_path = calloc(len + 1, sizeof(char));
+ if (temp_application_path == NULL) {
+ _E("memory alloc failed");
+ free(temp_pkgid);
+ return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
+ }
+ snprintf(temp_application_path, len, "%s/%s",
+ tzplatform_getenv(TZ_SYS_RW_APP), temp_pkgid);
+
+ temp_encoded_id = _app2sd_get_encoded_name((const char *)temp_pkgid, uid);
+ if (temp_encoded_id == NULL) {
+ free(temp_pkgid);
+ free(temp_application_path);
+ return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
+ }
+ len = strlen(APP2SD_PATH) + strlen(temp_encoded_id) + 1;
+ temp_loopback_device = calloc(len + 1, sizeof(char));
+ if (temp_loopback_device == NULL) {
+ _E("memory alloc failed");
+ free(temp_pkgid);
+ free(temp_application_path);
+ free(temp_encoded_id);
+ return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
+ }
+ snprintf(temp_loopback_device, len, "%s/%s",
+ APP2SD_PATH, temp_encoded_id);
+ free(temp_encoded_id);
} else {
tzplatform_set_user(uid);
- snprintf(temp_application_path, FILENAME_MAX - 1,
- "%s/%s", tzplatform_getenv(TZ_USER_APP), temp_pkgid);
- snprintf(temp_loopback_device, FILENAME_MAX - 1,
- "%s/%s/%s", APP2SD_PATH,
- tzplatform_getenv(TZ_USER_NAME), temp_pkgid);
+ len = strlen(tzplatform_getenv(TZ_USER_APP)) + strlen(temp_pkgid) + 1;
+ temp_application_path = calloc(len + 1, sizeof(char));
+ if (temp_application_path == NULL) {
+ _E("memory alloc failed");
+ free(temp_pkgid);
+ return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
+ }
+ snprintf(temp_application_path, len, "%s/%s",
+ tzplatform_getenv(TZ_USER_APP), temp_pkgid);
+
+ temp_encoded_id = _app2sd_get_encoded_name((const char*)temp_pkgid, uid);
+ if (temp_encoded_id == NULL) {
+ free(temp_pkgid);
+ free(temp_application_path);
+ return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
+ }
+ snprintf(temp_uid, 32, "%d", uid);
+ len = strlen(APP2SD_PATH) + strlen(temp_uid) + strlen(temp_encoded_id) + 2;
+ temp_loopback_device = calloc(len + 1, sizeof(char));
+ if (temp_loopback_device == NULL) {
+ _E("memory alloc failed");
+ free(temp_pkgid);
+ free(temp_application_path);
+ free(temp_encoded_id);
+ return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
+ }
+ snprintf(temp_loopback_device, len, "%s/%s",
+ APP2SD_PATH, temp_encoded_id);
+ free(temp_encoded_id);
tzplatform_reset_user();
}
ret = _app2sd_update_loopback_device_size(pkgid,
loopback_device, application_path, temp_pkgid,
temp_loopback_device, temp_application_path,
reqd_disk_size, dir_list, uid);
+ free(temp_pkgid);
+ free(temp_application_path);
+ free(temp_loopback_device);
if (APP2EXT_SUCCESS != ret) {
_E("failed to update loopback device size");
return ret;
if (NULL == device_node) {
/* do loopback setup */
device_node = _app2sd_do_loopback_encryption_setup(pkgid,
- loopback_device);
+ loopback_device, uid);
if (device_node == NULL) {
_E("loopback encryption setup failed");
return APP2EXT_ERROR_DO_LOSETUP;
char *device_name = NULL;
char loopback_device[FILENAME_MAX] = { 0, };
char application_path[FILENAME_MAX] = { 0, };
+ char *encoded_id = NULL;
int ret = APP2EXT_SUCCESS;
/* validate the function parameter recieved */
return APP2EXT_ERROR_MMC_STATUS;
}
+ encoded_id = _app2sd_get_encoded_name(pkgid, uid);
+ if (encoded_id == NULL) {
+ return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
+ }
if (_is_global(uid)) {
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
tzplatform_getenv(TZ_SYS_RW_APP), pkgid);
snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
- APP2SD_PATH, pkgid);
+ APP2SD_PATH, encoded_id);
} else {
tzplatform_set_user(uid);
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
tzplatform_getenv(TZ_USER_APP), pkgid);
- snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
- APP2SD_PATH, tzplatform_getenv(TZ_USER_NAME), pkgid);
+ snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
+ APP2SD_PATH, encoded_id);
tzplatform_reset_user();
}
+ free(encoded_id);
_D("application_path = (%s)", application_path);
_D("loopback_device = (%s)", loopback_device);
{
char loopback_device[FILENAME_MAX] = { 0, };
char application_path[FILENAME_MAX] = { 0, };
+ char *encoded_id = NULL;
int ret = APP2EXT_SUCCESS;
_D("start force_clean [%s]", pkgid);
sync();
+ encoded_id = _app2sd_get_encoded_name(pkgid, uid);
+ if (encoded_id == NULL) {
+ return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
+ }
if (_is_global(uid)) {
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
tzplatform_getenv(TZ_SYS_RW_APP), pkgid);
snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
- APP2SD_PATH, pkgid);
+ APP2SD_PATH, encoded_id);
} else {
tzplatform_set_user(uid);
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
tzplatform_getenv(TZ_USER_APP), pkgid);
- snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
- APP2SD_PATH, tzplatform_getenv(TZ_USER_NAME), pkgid);
+ snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
+ APP2SD_PATH, encoded_id);
tzplatform_reset_user();
}
+ free(encoded_id);
_D("application_path = (%s)", application_path);
_D("loopback_device = (%s)", loopback_device);