From 4a4531bca275d4ce0029acc3071ca4200806a2b5 Mon Sep 17 00:00:00 2001 From: chengjinsong Date: Thu, 8 Sep 2022 20:24:04 +0800 Subject: [PATCH] umount Signed-off-by: chengjinsong Change-Id: I471baaeec48230713df6cb48b03044cdc32e8fbd --- services/init/standard/init_cmds.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/services/init/standard/init_cmds.c b/services/init/standard/init_cmds.c index 01087249..d4051aed 100755 --- a/services/init/standard/init_cmds.c +++ b/services/init/standard/init_cmds.c @@ -342,14 +342,18 @@ static void DoStopAllServices(const struct CmdArgs *ctx) static void DoUmount(const struct CmdArgs *ctx) { INIT_LOGI("DoUmount %s", ctx->argv[0]); - int ret = GetMountStatusForMountPoint(ctx->argv[0]); - if (ret == 0) { - ret = umount(ctx->argv[0]); + MountStatus status = GetMountStatusForMountPoint(ctx->argv[0]); + if (status == MOUNT_MOUNTED) { + int ret = umount(ctx->argv[0]); if ((ret != 0) && (ctx->argc > 1) && (strcmp(ctx->argv[1], "MNT_FORCE") == 0)) { 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) -- GitLab