return APP2EXT_SUCCESS;
}
-static int __app2sd_finalize_device_setup(const char *pkgid,
- const char *loopback_device, const char *application_path,
- uid_t uid)
-{
- char *device_node = NULL;
- int ret = APP2EXT_SUCCESS;
-
-#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
- device_node =
- _app2sd_find_associated_dmcrypt_device_node(pkgid, uid);
- if (!device_node) {
- _E("failed to find device node");
- return APP2EXT_ERROR_FIND_ASSOCIATED_DMCRYPT_DEVICE_NODE;
- }
-#else
- device_node = _app2sd_find_associated_device_node(loopback_device);
- if (NULL == device_node) {
- _E("failed to find device node");
- return APP2EXT_ERROR_FIND_ASSOCIATED_DEVICE_NODE;
- }
-#endif
-
- ret = _app2sd_unmount_app_content(application_path);
- if (ret) {
- if (device_node) {
- free(device_node);
- device_node = NULL;
- }
- _E("unable to unmount the app content (%d)", ret);
- return APP2EXT_ERROR_UNMOUNT;
- }
-
-#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
- ret = _app2sd_dmcrypt_close_device(pkgid, uid);
- if (ret) {
- if (device_node) {
- free(device_node);
- device_node = NULL;
- }
- _E("close dmcrypt device error(%d)", ret);
- return ret;
- }
-#else
- ret = _app2sd_remove_loopback_encryption_setup(loopback_device);
- if (ret) {
- if (device_node) {
- free(device_node);
- device_node = NULL;
- }
- _E("unable to detach the loopback encryption setup" \
- " for the application");
- return APP2EXT_ERROR_UNMOUNT;
- }
-#endif
-
- if (device_node) {
- free(device_node);
- device_node = NULL;
- }
-
- return ret;
-}
-
int app2sd_usr_pre_app_install(const char *pkgid, GList *dir_list, int size, uid_t uid)
{
int ret = 0;
int app2sd_usr_post_app_install(const char *pkgid,
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, };
tzplatform_reset_user();
}
free(encoded_id);
+ snprintf(application_mmc_path, FILENAME_MAX - 1, "%s/.mmc",
+ application_path);
+
+ /* get the associated device node for SD card applicationer */
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+ device_name =
+ _app2sd_find_associated_dmcrypt_device_node(pkgid, uid);
+ if (!device_name)
+ return APP2EXT_ERROR_FIND_ASSOCIATED_DMCRYPT_DEVICE_NODE;
+#else
+ device_name = _app2sd_find_associated_device_node(loopback_device);
+ if (NULL == device_name)
+ return APP2EXT_ERROR_FIND_ASSOCIATED_DEVICE_NODE;
+#endif
- ret = __app2sd_finalize_device_setup(pkgid, loopback_device,
- application_path, uid);
+ ret = _app2sd_unmount_app_content(application_path);
if (ret) {
- _E("failed to finalize device setup");
+ if (device_name) {
+ free(device_name);
+ device_name = NULL;
+ }
+ _E("unable to unmount the app content (%d)", ret);
+ return APP2EXT_ERROR_UNMOUNT;
+ }
+
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+ ret = _app2sd_dmcrypt_close_device(pkgid, uid);
+ if (ret) {
+ if (device_name) {
+ free(device_name);
+ device_name = NULL;
+ }
+ _E("close dmcrypt device error(%d)", ret);
return ret;
}
+#else
+ ret = _app2sd_remove_loopback_encryption_setup(loopback_device);
+ if (ret) {
+ if (device_name) {
+ free(device_name);
+ device_name = NULL;
+ }
+ _E("unable to detach the loopback encryption setup" \
+ " for the application");
+ return APP2EXT_ERROR_UNMOUNT;
+ }
+#endif
+
+ if (device_name) {
+ free(device_name);
+ device_name = NULL;
+ }
/* take appropriate action based on
* installation status of application package
if (ret)
_E("unable to delete info");
- snprintf(application_mmc_path, FILENAME_MAX - 1, "%s/.mmc",
- application_path);
ret = _app2sd_delete_directory(application_mmc_path);
if (ret)
_E("unable to delete the directory (%s)", application_path);
fclose(fp);
}
- ret = __app2sd_finalize_device_setup(pkgid, loopback_device,
- application_path, uid);
+ ret = _app2sd_unmount_app_content(application_path);
if (ret) {
- _E("failed to finalize device setup");
- return ret;
+ _E("unable to unmount the SD application");
+ return APP2EXT_ERROR_UNMOUNT;
}
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+ ret = _app2sd_dmcrypt_close_device(pkgid, uid);
+ if (ret)
+ _E("close dmcrypt device error(%d)", ret);
+#else
+ ret = _app2sd_remove_loopback_encryption_setup(loopback_device);
+ if (ret) {
+ _E("unable to remove loopback setup");
+ return APP2EXT_ERROR_DELETE_LOOPBACK_DEVICE;
+ }
+#endif
+
return ret;
}
tzplatform_reset_user();
}
free(encoded_id);
+ snprintf(application_mmc_path, FILENAME_MAX - 1, "%s/.mmc",
+ application_path);
- ret = __app2sd_finalize_device_setup(pkgid, loopback_device,
- application_path, uid);
+ /* unmount the loopback encrypted pseudo device from
+ * the application installation path
+ */
+ ret = _app2sd_unmount_app_content(application_path);
if (ret) {
- _E("failed to finalize device setup");
- return ret;
+ _E("unable to unmount the app content (%d)", ret);
+ ret = APP2EXT_ERROR_UNMOUNT;
+ goto END;
}
+ /* detach the loopback encryption setup for the application */
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+ ret = _app2sd_dmcrypt_close_device(pkgid, uid);
+ if (ret) {
+ _E("close dmcrypt device error(%d)", ret);
+ goto END;
+ }
+#else
+ ret = _app2sd_remove_loopback_encryption_setup(loopback_device);
+ if (ret) {
+ _E("unable to Detach the loopback encryption setup" \
+ " for the application");
+ ret = APP2EXT_ERROR_DETACH_LOOPBACK_DEVICE;
+ goto END;
+ }
+#endif
/* delete the loopback device from the SD card */
ret = _app2sd_delete_loopback_device(loopback_device);
goto END;
}
- snprintf(application_mmc_path, FILENAME_MAX - 1, "%s/.mmc",
- application_path);
ret = _app2sd_delete_directory(application_mmc_path);
if (ret) {
_E("unable to delete the directory (%s)",
tzplatform_reset_user();
}
- ret = __app2sd_finalize_device_setup(pkgid, loopback_device,
- application_path, uid);
- if (ret) {
- _E("failed to finalize device setup");
- return ret;
- }
+ ret = _app2sd_unmount_app_content(application_path);
+ if (ret)
+ _E("unmount error (%d)", ret);
+
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+ ret = _app2sd_dmcrypt_close_device(pkgid, uid);
+ if (ret)
+ _E("close dmcrypt device error(%d)", ret);
+#else
+ ret = _app2sd_remove_loopback_encryption_setup(loopback_device);
+ if (ret)
+ _E("unable to detach loopback setup for (%s)",
+ loopback_device);
+#endif
sync();
return APP2EXT_SUCCESS;
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;
int pkgmgr_ret = 0;
}
free(encoded_id);
- ret = __app2sd_finalize_device_setup(pkgid, loopback_device,
- application_path, uid);
+ /* get the associated device node for SD card applicationer */
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+ device_name =
+ _app2sd_find_associated_dmcrypt_device_node(pkgid, uid);
+ if (!device_name) {
+ _E("could not find associated dmcrypt device node" \
+ " (%s_%d)", pkgid, uid);
+ return APP2EXT_ERROR_FIND_ASSOCIATED_DMCRYPT_DEVICE_NODE;
+ }
+#else
+ device_name = _app2sd_find_associated_device_node(loopback_device);
+ if (NULL == device_name)
+ return APP2EXT_ERROR_FIND_ASSOCIATED_DEVICE_NODE;
+#endif
+
+ ret = _app2sd_unmount_app_content(application_path);
if (ret) {
- _E("failed to finalize device setup");
- return ret;
+ if (device_name) {
+ free(device_name);
+ device_name = NULL;
+ }
+ _E("unable to unmount the app content (%d)", ret);
+ return APP2EXT_ERROR_UNMOUNT;
}
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+ ret = _app2sd_dmcrypt_close_device(pkgid, uid);
+ if (ret) {
+ if (device_name) {
+ free(device_name);
+ device_name = NULL;
+ }
+ _E("close dmcrypt device error(%d)", ret);
+ return APP2EXT_ERROR_CLOSE_DMCRYPT_DEVICE;
+ }
+#else
+ ret = _app2sd_remove_loopback_encryption_setup(loopback_device);
+ if (ret) {
+ if (device_name) {
+ free(device_name);
+ device_name = NULL;
+ }
+ _E("unable to detach the loopback encryption " \
+ "setup for the application");
+ return APP2EXT_ERROR_UNMOUNT;
+ }
+#endif
+
pkgmgr_ret = pkgmgrinfo_pkginfo_set_usr_installed_storage(pkgid,
INSTALL_EXTERNAL, loopback_device, uid);
if (pkgmgr_ret < 0) {
return APP2EXT_ERROR_PKGMGR_ERROR;
}
+ if (device_name) {
+ free(device_name);
+ device_name = NULL;
+ }
+
sync();
return ret;
}