From: Byungsoo Kim Date: Thu, 30 May 2013 12:50:13 +0000 (+0900) Subject: Fix mounting / unmounting problem X-Git-Tag: submit/tizen_ivi_release/20140401.030119~44 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4ce725335cf1093c92a96073dd0f8d0d437d8c29;p=platform%2Fcore%2Fsystem%2Fsystem-server.git Fix mounting / unmounting problem - remove unnecessary killing application logic - add to check sd card encryption status at mounting from setting app - fix unmounting problem Change-Id: I55db313b649d14a37e9937a399ddba788c27b31c Signed-off-by: Byungsoo Kim --- diff --git a/src/mmc/mmc-handler.c b/src/mmc/mmc-handler.c index a824545..90f574c 100644 --- a/src/mmc/mmc-handler.c +++ b/src/mmc/mmc-handler.c @@ -239,15 +239,6 @@ int get_mmcblk_num(void) return -1; } -static int mmc_umount(int option) -{ - int ret; - ret = umount2(MMC_MOUNT_POINT, option); - if (ret != 0) - _E("Failed to unmount mmc card"); - return ret; -} - static int mmc_check_fs_type(void) { int ret; @@ -328,7 +319,79 @@ static int create_partition(const char *dev_path) return 0; } -static int mmc_format_exec(const char *path) +static int kill_app_accessing_mmc(void) +{ + int pid; + char *argv[4] = {"/sbin/fuser", "-mk", MMC_MOUNT_POINT, NULL}; + char buf[256]; + int retry = 10; + + pid = exec_process(argv); + if (pid < 0) { + _E("%s fail"); + return -EINVAL; + } + + snprintf(buf, sizeof(buf), "%s%d", "/proc/", pid); + _D("child process : %s", buf); + while (--retry) { + usleep(100000); + _D("killing app...."); + if (access(buf, R_OK) != 0) + break; + } + + return 0; +} + +static void launch_syspopup(const char *str) +{ + bundle *b; + int ret; + b = bundle_create(); + if (!b) { + _E("error bundle_create()"); + return; + } + bundle_add(b, "_SYSPOPUP_CONTENT_", str); + ret = syspopup_launch("mmc-syspopup", b); + if (ret < 0) + _E("popup launch failed"); + bundle_free(b); +} + +static int mmc_umount(int option) +{ + int r, retry = 5; + + if (!check_mount_state()) + return 0; + + _I("Mounted, will be unmounted"); + r = umount(MMC_MOUNT_POINT); + if (!r || option == UNMOUNT_NORMAL) + return r; + + _I("Execute force unmount!"); + + /* it notify to other app who already access sdcard */ + vconf_set_int(VCONFKEY_SYSMAN_MMC_STATUS, VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED); + + /* it takes some seconds til other app completely clean up */ + usleep(500000); + + while (--retry) { + r = umount2(MMC_MOUNT_POINT, MNT_DETACH); + if (!r) + break; + usleep(500000); + _I("umount retry : %d", retry); + } + + return r; +} + +static int mmc_format_exec(char *path) { unsigned int size; int mkfs_pid;