提交 4a4531bc 编写于 作者: C chengjinsong

umount

Signed-off-by: Nchengjinsong <chengjinsong2@huawei.com>
Change-Id: I471baaeec48230713df6cb48b03044cdc32e8fbd
上级 e5331167
...@@ -342,14 +342,18 @@ static void DoStopAllServices(const struct CmdArgs *ctx) ...@@ -342,14 +342,18 @@ static void DoStopAllServices(const struct CmdArgs *ctx)
static void DoUmount(const struct CmdArgs *ctx) static void DoUmount(const struct CmdArgs *ctx)
{ {
INIT_LOGI("DoUmount %s", ctx->argv[0]); INIT_LOGI("DoUmount %s", ctx->argv[0]);
int ret = GetMountStatusForMountPoint(ctx->argv[0]); MountStatus status = GetMountStatusForMountPoint(ctx->argv[0]);
if (ret == 0) { if (status == MOUNT_MOUNTED) {
ret = umount(ctx->argv[0]); int ret = umount(ctx->argv[0]);
if ((ret != 0) && (ctx->argc > 1) && (strcmp(ctx->argv[1], "MNT_FORCE") == 0)) { if ((ret != 0) && (ctx->argc > 1) && (strcmp(ctx->argv[1], "MNT_FORCE") == 0)) {
ret = umount2(ctx->argv[0], MNT_FORCE); ret = umount2(ctx->argv[0], MNT_FORCE);
} }
INIT_CHECK_ONLY_ELOG(ret == 0, "Failed to umount %s, errno %d", ctx->argv[0], errno);
} else if (status == MOUNT_UMOUNTED) {
INIT_LOGI("%s is already umounted", ctx->argv[0]);
} else {
INIT_LOGE("Failed to get %s mount status", ctx->argv[0]);
} }
INIT_ERROR_CHECK(ret == 0, return, "Failed to umount %s errno = %d.", ctx->argv[0], errno);
} }
static void DoSync(const struct CmdArgs *ctx) static void DoSync(const struct CmdArgs *ctx)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册