From: giyeol.ok Date: Fri, 31 May 2013 05:15:29 +0000 (+0900) Subject: insert umount checking routine to support stable format X-Git-Tag: submit/tizen_ivi_release/20140401.030119~43 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ec8e0489195737d84623cc87d4555d4756a3cbe7;p=platform%2Fcore%2Fsystem%2Fsystem-server.git insert umount checking routine to support stable format Change-Id: Iba5d15c1016193423646a7fa0ef6245dffaba9fd Signed-off-by: giyeol.ok --- diff --git a/src/mmc/mmc-handler.c b/src/mmc/mmc-handler.c index 90f574c..e458cc3 100644 --- a/src/mmc/mmc-handler.c +++ b/src/mmc/mmc-handler.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "core/log.h" #include "core/common.h" @@ -55,6 +56,8 @@ #define MMC_32GB_SIZE 61315072 +#define UNMOUNT_RETRY 5 + #define get_mmc_fs(ptr, type, member) \ ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member))) @@ -360,17 +363,47 @@ static void launch_syspopup(const char *str) bundle_free(b); } +static int mmc_check(char* path) +{ + int ret = false; + struct mntent* mnt; + const char* table = "/etc/mtab"; + FILE* fp; + + fp = setmntent(table, "r"); + if (!fp) + return ret; + while (mnt=getmntent(fp)) { + if (!strcmp(mnt->mnt_dir, path)) { + ret = true; + break; + } + } + endmntent(fp); + return ret; +} + +static int mmc_check_and_unmount(char *path) +{ + int ret = 0; + if (mmc_check(path)) + ret = umount(path); + return ret; +} + static int mmc_umount(int option) { - int r, retry = 5; + int r, retry = UNMOUNT_RETRY; if (!check_mount_state()) return 0; _I("Mounted, will be unmounted"); - r = umount(MMC_MOUNT_POINT); - if (!r || option == UNMOUNT_NORMAL) + r = mmc_check_and_unmount(MMC_MOUNT_POINT); + if (!r || option == UNMOUNT_NORMAL) { + _I("unmount mmc card, ret = %d, option = %d", r, option); return r; + } _I("Execute force unmount!"); @@ -381,11 +414,13 @@ static int mmc_umount(int option) usleep(500000); while (--retry) { - r = umount2(MMC_MOUNT_POINT, MNT_DETACH); + r = mmc_check_and_unmount(MMC_MOUNT_POINT); if (!r) break; usleep(500000); _I("umount retry : %d", retry); + if (retry == UNMOUNT_RETRY -2) + kill_app_accessing_mmc(); } return r;