MOUNT_TYPE_RW_REMOUNT
} mount_type;
-/*Checks whether mmc is present or not*/
-int _app2sd_check_mmc_status(void);
+/* checks whether mmc is present or not */
+/* sd_path should be freed after use */
+int _app2sd_check_mmc_status(char **sd_path);
-/*this function is similar to system()*/
+/* this function is similar to system() */
int _xsystem(const char *argv[]);
-/*this function will return the free available memory on the SD Card*/
-int _app2sd_get_available_free_memory(const char *sd_path, int *free_mem);
+/* this function will return the free available memory on the SD Card */
+int _app2sd_get_available_free_memory(char *mmc_path, int *free_mem);
-/*Function to move the application from/to SD Card*/
+/* function to move the application from/to SD Card */
int _app2sd_usr_move_app(const char *pkgid, app2ext_move_type move_cmd,
- GList *dir_list, uid_t uid);
+ GList *dir_list, uid_t uid, char *mmc_path);
-/*utility to delete symbolic link*/
+/* utility to delete symbolic link */
void _app2sd_delete_symlink(const char *dirname);
-/*utility to calculate the size of a directory in MB*/
+/* utility to calculate the size of a directory in MB */
unsigned long long _app2sd_calculate_dir_size(char *dirname);
-/*utility to calculate the size of a file in MB*/
+/* utility to calculate the size of a file in MB */
unsigned long long _app2sd_calculate_file_size(const char *filename);
-/*Utility to copy a directory*/
+/* utility to copy a directory */
int _app2sd_copy_dir(const char *src, const char *dest);
-/*Utility to rename a directory*/
+/* utility to rename a directory */
int _app2sd_rename_dir(const char *old_name, const char *new_name);
-/* Utility to create symlinks */
+/* utility to create symlinks */
int _app2sd_create_symlink(char *pkgid);
-/*This function finds the associated device node for the app*/
+/* this function finds the associated device node for the app */
char *_app2sd_find_associated_device_node(const char *loopback_device);
-/*This function does the loopback encryption for app*/
+/* this function does the loopback encryption for app */
char *_app2sd_do_loopback_encryption_setup(const char *pkgid,
const char *loopback_device, uid_t uid);
-/*This function detaches the loopback device*/
+/* this function detaches the loopback device */
char *_app2sd_detach_loop_device(const char *device);
-/*This function finds loopback device associated with the app*/
+/* this function finds loopback device associated with the app */
char *_app2sd_find_associated_device(const char *loopback_device);
-/*This function creates loopback device*/
+/* this function creates loopback device */
int _app2sd_create_loopback_device(const char *pkgid,
const char *loopback_device, int size);
-/*This function deletes loopback device associated with the app*/
+/* this function deletes loopback device associated with the app */
int _app2sd_delete_loopback_device(const char *loopback_device);
-/*This function creates ext4 FS on the device path*/
+/* this function creates ext4 FS on the device path */
int _app2sd_create_file_system(const char *device_path);
-/*This function mounts the app content on the device node*/
+/* this function mounts the app content on the device node */
int _app2sd_mount_app_content(const char *application_path, const char *pkgid,
const char *dev, int mount_type, GList* dir_list,
app2sd_cmd cmd, uid_t uid);
-/*This function unmounts the app content */
+/* this function unmounts the app content */
int _app2sd_unmount_app_content(const char *application_path);
-/*This function removes the loopbck encryption setup for the app*/
+/* this function removes the loopbck encryption setup for the app */
int _app2sd_remove_loopback_encryption_setup(const char *loopback_device);
-/*This function removes all of loopbck encryption setup for the app*/
+/* this function removes all of loopbck encryption setup for the app */
int _app2sd_remove_all_loopback_encryption_setups(const char *loopback_device);
-/*This function updates loopback device size*/
+/* this function updates loopback device size */
int _app2sd_update_loopback_device_size(const char *pkgid,
const char *loopback_device, const char *application_path,
const char *temp_pkgid, const char *temp_loopback_device,
const char *temp_application_path, int size, GList* dir_list,
uid_t uid);
-/* This generates password */
+/* this generates password */
char *_app2sd_generate_password(const char *pkgid);
-/*This function encrypts device*/
+/* this function encrypts device */
char *_app2sd_encrypt_device(const char *device, const char *loopback_device,
char *passwd);
-/*This function finds free device*/
+/* this function finds free device */
char *_app2sd_find_free_device(void);
-/*This function initializes app2sd DB*/
+/* this function initializes app2sd DB */
int _app2sd_initialize_db();
-/*This function is used to get password from db*/
+/* this function is used to get password from db */
char *_app2sd_get_password_from_db(const char *pkgid, uid_t uid);
-/*This function removes info from db */
+/* this function removes info from db */
int _app2sd_remove_info_from_db(const char *pkgid, uid_t uid);
-/* This functions save info in db */
+/* this functions save info in db */
int _app2sd_set_info_in_db(const char *pkgid, const char *passwd,
const char *loopback_device, uid_t uid);
const char *loopback_device, uid_t uid);
#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
-/*This function setup dmcrypt header in the app2sd file */
+/* this function setup dmcrypt header in the app2sd file */
int _app2sd_dmcrypt_setup_device(const char *pkgid,
const char *loopback_device, bool is_dup, uid_t uid);
-/*This function maps the app2sd file with a dmcrypt device node */
+/* this function maps the app2sd file with a dmcrypt device node */
int _app2sd_dmcrypt_open_device(const char *pkgid, const char *loopback_device,
bool is_dup, uid_t uid, char **dev_node);
-/*This function remove dmcrypt device node */
+/* this function remove dmcrypt device node */
int _app2sd_dmcrypt_close_device(const char *pkgid, uid_t uid);
-/*This function find associated dmcrypt device node */
+/* this function find associated dmcrypt device node */
char *_app2sd_find_associated_dmcrypt_device_node(const char *pkgid, uid_t uid);
#endif
#include "app2sd_internals.h"
-static int __app2sd_create_app2sd_directories(uid_t uid)
+static int __app2sd_create_app2sd_directories(uid_t uid, char *mmc_path)
{
int ret = 0;
+ char app2sd_path[FILENAME_MAX] = { 0, };
mode_t mode = DIR_PERMS;
- ret = mkdir(APP2SD_PATH, mode);
+ snprintf(app2sd_path, FILENAME_MAX - 1, "%s/%s",
+ mmc_path, EXTIMG_DIR);
+ ret = mkdir(app2sd_path, mode);
if (ret) {
if (errno != EEXIST) {
_E("create directory failed," \
{
int ret = 0;
int free_mmc_mem = 0;
+ char *sdpath = NULL;
char *device_node = NULL;
#if !defined(TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION)
char *devi = NULL;
+ char *result = NULL;
#endif
+ char mmc_path[FILENAME_MAX] = { 0, };
char application_path[FILENAME_MAX] = { 0, };
char loopback_device[FILENAME_MAX] = { 0, };
char *encoded_id = NULL;
}
/* check whether MMC is present or not */
- ret = _app2sd_check_mmc_status();
+ ret = _app2sd_check_mmc_status(&sdpath);
if (ret) {
- _E("MMC not preset OR Not ready (%d)", ret);
+ _E("MMC not present OR Not ready (%d)", ret);
return APP2EXT_ERROR_MMC_STATUS;
}
+ snprintf(mmc_path, FILENAME_MAX - 1, "%s", sdpath);
+ free(sdpath);
+ sync();
/* find available free memory in the MMC card */
- ret = _app2sd_get_available_free_memory(MMC_PATH, &free_mmc_mem);
+ ret = _app2sd_get_available_free_memory(mmc_path, &free_mmc_mem);
if (ret) {
- _E("unable to get available free memory in MMC (%d)",
- ret);
+ _E("unable to get available free memory in MMC (%d)", ret);
return APP2EXT_ERROR_MMC_STATUS;
}
_D("size details for application installation:" \
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, encoded_id);
+ snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
+ mmc_path, EXTIMG_DIR, 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",
- APP2SD_PATH, encoded_id);
+ snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
+ mmc_path, EXTIMG_DIR, encoded_id);
tzplatform_reset_user();
}
free(encoded_id);
- ret = __app2sd_create_app2sd_directories(uid);
+ ret = __app2sd_create_app2sd_directories(uid, mmc_path);
if (ret) {
_E("failed to create app2sd dirs");
return ret;
}
#endif
+ sync();
return ret;
}
app2ext_status install_status, uid_t uid)
{
char *device_name = NULL;
+ char *sdpath = NULL;
+ char mmc_path[FILENAME_MAX] = { 0, };
char application_path[FILENAME_MAX] = { 0, };
char application_mmc_path[FILENAME_MAX] = { 0, };
char loopback_device[FILENAME_MAX] = { 0, };
}
/* check whether MMC is present or not */
- ret = _app2sd_check_mmc_status();
+ ret = _app2sd_check_mmc_status(&sdpath);
if (ret) {
_E("MMC not present OR Not ready (%d)", ret);
return APP2EXT_ERROR_MMC_STATUS;
}
+ snprintf(mmc_path, FILENAME_MAX - 1, "%s", sdpath);
+ free(sdpath);
sync();
encoded_id = _app2sd_get_encoded_name(pkgid, uid);
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, encoded_id);
+ snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
+ mmc_path, EXTIMG_DIR, 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",
- APP2SD_PATH, encoded_id);
+ snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
+ mmc_path, EXTIMG_DIR, encoded_id);
tzplatform_reset_user();
}
free(encoded_id);
}
}
+ sync();
return ret;
}
int app2sd_usr_on_demand_setup_init(const char *pkgid, uid_t uid)
{
int ret = APP2EXT_SUCCESS;
+ char mmc_path[FILENAME_MAX] = { 0, };
char application_path[FILENAME_MAX] = { 0, };
char loopback_device[FILENAME_MAX] = { 0, };
+ char *sdpath = NULL;
char *encoded_id = NULL;
char *device_node = NULL;
#if !defined(TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION)
}
/* check whether MMC is present or not */
- ret = _app2sd_check_mmc_status();
+ ret = _app2sd_check_mmc_status(&sdpath);
if (ret) {
- _E("MMC not preset OR Not ready (%d)", ret);
+ _E("MMC not present OR Not ready (%d)", ret);
return APP2EXT_ERROR_MMC_STATUS;
}
+ snprintf(mmc_path, FILENAME_MAX - 1, "%s", sdpath);
+ free(sdpath);
encoded_id = _app2sd_get_encoded_name(pkgid, uid);
if (encoded_id == NULL)
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, encoded_id);
+ snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
+ mmc_path, EXTIMG_DIR, 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",
- APP2SD_PATH, encoded_id);
+ snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
+ mmc_path, EXTIMG_DIR, encoded_id);
tzplatform_reset_user();
}
free(encoded_id);
int app2sd_usr_on_demand_setup_exit(const char *pkgid, uid_t uid)
{
int ret = APP2EXT_SUCCESS;
+ char mmc_path[FILENAME_MAX] = { 0, };
char application_path[FILENAME_MAX] = { 0, };
char loopback_device[FILENAME_MAX] = { 0, };
+ char *sdpath = NULL;
char *encoded_id = NULL;
FILE *fp = NULL;
int mmc_present = 1;
_app2sd_kill_running_app(pkgid, uid);
/* check whether MMC is present or not */
- ret = _app2sd_check_mmc_status();
+ ret = _app2sd_check_mmc_status(&sdpath);
if (ret) {
- _W("MMC not preset OR Not ready (%d)", ret);
+ _W("MMC not present OR Not ready (%d)", ret);
mmc_present = 0;
}
+ snprintf(mmc_path, FILENAME_MAX - 1, "%s", sdpath);
+ free(sdpath);
encoded_id = _app2sd_get_encoded_name(pkgid, uid);
if (encoded_id == NULL)
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, encoded_id);
+ snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
+ mmc_path, EXTIMG_DIR, 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",
- APP2SD_PATH, encoded_id);
+ snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
+ mmc_path, EXTIMG_DIR, encoded_id);
tzplatform_reset_user();
}
free(encoded_id);
int app2sd_usr_pre_app_uninstall(const char *pkgid, uid_t uid)
{
int ret = APP2EXT_SUCCESS;
+ char mmc_path[FILENAME_MAX] = { 0, };
char application_path[FILENAME_MAX] = { 0, };
char loopback_device[FILENAME_MAX] = { 0, };
+ char *sdpath = NULL;
char *encoded_id = NULL;
char *device_node = NULL;
FILE *fp = NULL;
}
/* check whether MMC is present or not */
- ret = _app2sd_check_mmc_status();
+ ret = _app2sd_check_mmc_status(&sdpath);
if (ret) {
- _E("MMC not preset OR Not ready (%d)", ret);
+ _E("MMC not present OR Not ready (%d)", ret);
ret = APP2EXT_ERROR_MMC_STATUS;
goto END;
}
+ snprintf(mmc_path, FILENAME_MAX - 1, "%s", sdpath);
+ free(sdpath);
+ sync();
encoded_id = _app2sd_get_encoded_name(pkgid, uid);
if (encoded_id == NULL)
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, encoded_id);
+ snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
+ mmc_path, EXTIMG_DIR, 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",
- APP2SD_PATH, encoded_id);
+ snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
+ mmc_path, EXTIMG_DIR, encoded_id);
tzplatform_reset_user();
}
free(encoded_id);
}
END:
+ sync();
return ret;
}
int app2sd_usr_post_app_uninstall(const char *pkgid, uid_t uid)
{
+ char mmc_path[FILENAME_MAX] = { 0, };
char application_path[FILENAME_MAX] = { 0, };
char application_mmc_path[FILENAME_MAX] = { 0, };
char loopback_device[FILENAME_MAX] = { 0, };
+ char *sdpath = NULL;
char *encoded_id = NULL;
int ret = APP2EXT_SUCCESS;
}
/* check whether MMC is present or not */
- ret = _app2sd_check_mmc_status();
+ ret = _app2sd_check_mmc_status(&sdpath);
if (ret) {
- _E("MMC not preset OR Not ready (%d)", ret);
+ _E("MMC not present OR Not ready (%d)", ret);
ret = APP2EXT_ERROR_MMC_STATUS;
goto END;
}
+ snprintf(mmc_path, FILENAME_MAX - 1, "%s", sdpath);
+ free(sdpath);
+ sync();
encoded_id = _app2sd_get_encoded_name(pkgid, uid);
if (encoded_id == NULL)
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, encoded_id);
+ snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
+ mmc_path, EXTIMG_DIR, 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",
- APP2SD_PATH, encoded_id);
+ snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
+ mmc_path, EXTIMG_DIR, encoded_id);
tzplatform_reset_user();
}
free(encoded_id);
}
END:
+ sync();
return ret;
}
{
int ret = 0;
int pkgmgr_ret = 0;
+ char *sdpath = NULL;
+ char mmc_path[FILENAME_MAX] = { 0, };
/* validate function arguments */
if (pkgid == NULL || dir_list == NULL
return APP2EXT_ERROR_INVALID_ARGUMENTS;
}
- ret = __app2sd_create_app2sd_directories(uid);
+ /* check whether MMC is present or not */
+ ret = _app2sd_check_mmc_status(&sdpath);
+ if (ret) {
+ _E("MMC not present OR Not ready(%d)", ret);
+ return APP2EXT_ERROR_MMC_STATUS;
+ }
+ snprintf(mmc_path, FILENAME_MAX - 1, "%s", sdpath);
+ free(sdpath);
+ sync();
+
+ ret = __app2sd_create_app2sd_directories(uid, mmc_path);
if (ret) {
_E("failed to create app2sd dirs");
return ret;
}
- ret = _app2sd_usr_move_app(pkgid, move_type, dir_list, uid);
+ ret = _app2sd_usr_move_app(pkgid, move_type, dir_list, uid, mmc_path);
if (ret) {
_D("unable to move application");
return ret;
app2ext_move_type move_type, uid_t uid)
{
int ret = 0;
+ char mmc_path[FILENAME_MAX] = { 0, };
char application_path[FILENAME_MAX] = { 0, };
char loopback_device[FILENAME_MAX] = { 0, };
+ char *sdpath = NULL;
char *encoded_id = NULL;
/* validate function arguments */
return APP2EXT_SUCCESS;
/* check whether MMC is present or not */
- ret = _app2sd_check_mmc_status();
+ ret = _app2sd_check_mmc_status(&sdpath);
if (ret) {
- _E("MMC not preset OR Not ready(%d)", ret);
+ _E("MMC not present OR Not ready(%d)", ret);
return APP2EXT_ERROR_MMC_STATUS;
}
+ snprintf(mmc_path, FILENAME_MAX - 1, "%s", sdpath);
+ free(sdpath);
+ sync();
encoded_id = _app2sd_get_encoded_name(pkgid, uid);
if (encoded_id == NULL)
return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
- snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
- APP2SD_PATH, encoded_id);
+ snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
+ mmc_path, EXTIMG_DIR, encoded_id);
free(encoded_id);
if (_is_global(uid)) {
snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
int size, uid_t uid)
{
int ret = APP2EXT_SUCCESS;
+ char app2sd_path[FILENAME_MAX] = { 0, };
char loopback_device[FILENAME_MAX] = { 0, };
char application_path[FILENAME_MAX] = { 0, };
char temp_uid[32] = { 0, };
+ char *sdpath = NULL;
char *temp_pkgid = NULL;
char *temp_loopback_device = NULL;
char *temp_application_path = NULL;
}
/* check whether MMC is present or not */
- ret = _app2sd_check_mmc_status();
+ ret = _app2sd_check_mmc_status(&sdpath);
if (ret) {
- _E("MMC not preset OR Not ready (%d)", ret);
+ _E("MMC not present OR Not ready (%d)", ret);
return APP2EXT_ERROR_MMC_STATUS;
}
+ snprintf(app2sd_path, FILENAME_MAX - 1, "%s/%s",
+ sdpath, EXTIMG_DIR);
+ free(sdpath);
+ sync();
encoded_id = _app2sd_get_encoded_name(pkgid, uid);
if (encoded_id == NULL)
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, encoded_id);
+ 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",
- APP2SD_PATH, encoded_id);
+ app2sd_path, encoded_id);
tzplatform_reset_user();
}
free(encoded_id);
free(temp_application_path);
return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
}
- len = strlen(APP2SD_PATH) + strlen(temp_encoded_id) + 1;
+ 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");
return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
}
snprintf(temp_loopback_device, len + 1, "%s/%s",
- APP2SD_PATH, temp_encoded_id);
+ app2sd_path, temp_encoded_id);
free(temp_encoded_id);
} else {
tzplatform_set_user(uid);
return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
}
snprintf(temp_uid, 32, "%d", uid);
- len = strlen(APP2SD_PATH) + strlen(temp_uid) + strlen(temp_encoded_id) + 2;
+ 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");
return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
}
snprintf(temp_loopback_device, len + 1, "%s/%s",
- APP2SD_PATH, temp_encoded_id);
+ app2sd_path, temp_encoded_id);
free(temp_encoded_id);
tzplatform_reset_user();
}
free(device_node);
device_node = NULL;
}
+
+ sync();
return ret;
}
int app2sd_usr_post_app_upgrade(const char *pkgid,
app2ext_status install_status, uid_t uid)
{
- char *device_name = NULL;
+ char mmc_path[FILENAME_MAX] = { 0, };
char loopback_device[FILENAME_MAX] = { 0, };
char application_path[FILENAME_MAX] = { 0, };
+ char *sdpath = NULL;
+ char *device_name = NULL;
char *encoded_id = NULL;
int ret = APP2EXT_SUCCESS;
}
/* check whether MMC is present or not */
- ret = _app2sd_check_mmc_status();
+ ret = _app2sd_check_mmc_status(&sdpath);
if (ret) {
- _E("MMC not preset OR Not ready (%d)", ret);
+ _E("MMC not present OR Not ready (%d)", ret);
return APP2EXT_ERROR_MMC_STATUS;
}
+ snprintf(mmc_path, FILENAME_MAX - 1, "%s", sdpath);
+ free(sdpath);
+ sync();
encoded_id = _app2sd_get_encoded_name(pkgid, uid);
if (encoded_id == NULL)
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, encoded_id);
+ snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
+ mmc_path, EXTIMG_DIR, 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",
- APP2SD_PATH, encoded_id);
+ snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
+ mmc_path, EXTIMG_DIR, encoded_id);
tzplatform_reset_user();
}
free(encoded_id);
device_name = NULL;
}
+ sync();
return ret;
}
int app2sd_usr_force_clean(const char *pkgid, uid_t uid)
{
+ char mmc_path[FILENAME_MAX] = { 0, };
char loopback_device[FILENAME_MAX] = { 0, };
char application_path[FILENAME_MAX] = { 0, };
+ char *sdpath = NULL;
char *encoded_id = NULL;
int ret = APP2EXT_SUCCESS;
return APP2EXT_ERROR_INVALID_ARGUMENTS;
}
+ /* check whether MMC is present or not */
+ ret = _app2sd_check_mmc_status(&sdpath);
+ if (ret) {
+ _E("MMC not present OR Not ready (%d)", ret);
+ return APP2EXT_ERROR_MMC_STATUS;
+ }
+ snprintf(mmc_path, FILENAME_MAX - 1, "%s", sdpath);
+ free(sdpath);
sync();
encoded_id = _app2sd_get_encoded_name(pkgid, uid);
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, encoded_id);
+ snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
+ mmc_path, EXTIMG_DIR, 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",
- APP2SD_PATH, encoded_id);
+ snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s/%s",
+ mmc_path, EXTIMG_DIR, encoded_id);
tzplatform_reset_user();
}
free(encoded_id);
ret = _app2sd_force_clean(pkgid, application_path, loopback_device, uid);
+ sync();
return ret;
}
int ret = APP2EXT_SUCCESS;
int rc = 0;
char buf[FILENAME_MAX] = { 0, };
+ char app2sd_path[FILENAME_MAX] = { 0, };
char loopback_device[FILENAME_MAX] = { 0, };
+ char *sdpath = NULL;
+ char *pkgid = NULL;
DIR *dir = NULL;
struct dirent entry;
struct dirent *result = NULL;
- char *pkgid = NULL;
uid_t uid = 0;
- dir = opendir(APP2SD_PATH);
+ /* check whether MMC is present or not */
+ ret = _app2sd_check_mmc_status(&sdpath);
+ if (ret) {
+ _E("MMC not present OR Not ready (%d)", ret);
+ return APP2EXT_ERROR_MMC_STATUS;
+ }
+ snprintf(app2sd_path, FILENAME_MAX - 1, "%s/%s",
+ sdpath, EXTIMG_DIR);
+ free(sdpath);
+
+ dir = opendir(app2sd_path);
if (!dir) {
strerror_r(errno, buf, sizeof(buf));
_E("failed to opendir (%s)", buf);
strcmp(entry.d_name, "..") == 0)
continue;
snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
- APP2SD_PATH, entry.d_name);
+ app2sd_path, entry.d_name);
ret = _app2sd_get_info_from_db(loopback_device,
&pkgid, &uid);
if (ret) {
}
closedir(dir);
+ sync();
return ret;
}
if (ret)
_E("disable full pkg error(%d)", ret);
+ sync();
return ret;
}