From 78ca281313a440204793ede70f11625dcbf479d6 Mon Sep 17 00:00:00 2001 From: sun_fan Date: Thu, 16 Sep 2021 18:30:43 +0800 Subject: [PATCH 1/2] init: fix mkdir bugs Signed-off-by: sun_fan --- services/src/init_cmds.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/services/src/init_cmds.c b/services/src/init_cmds.c index 9663b4349..ff271f459 100644 --- a/services/src/init_cmds.c +++ b/services/src/init_cmds.c @@ -528,10 +528,12 @@ static void DoMkDir(const char *cmdContent, int maxArg) break; } index = index + 1; - if ((ctx->argv[index] != NULL) && (ctx->argv[index + 1] != NULL)) { - rc = Chown(ctx->argv[0], ctx->argv[index], ctx->argv[index + 1]); - } else { - rc = -1; + if (ctx->argv[index] != NULL) { + if (ctx->argv[index + 1] != NULL) { + rc = Chown(ctx->argv[0], ctx->argv[index], ctx->argv[index + 1]); + } else { + rc = -1; + } } } } while (0); @@ -1306,4 +1308,4 @@ const char *GetCmdKey(unsigned int index) return NULL; } return CMD_TABLE[index].name; -} \ No newline at end of file +} -- Gitee From ba23c702d4fc46811f3a7c03deebba7331648b6b Mon Sep 17 00:00:00 2001 From: sun_fan Date: Thu, 16 Sep 2021 18:36:20 +0800 Subject: [PATCH 2/2] init: add log Signed-off-by: sun_fan --- services/src/init_cmds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/src/init_cmds.c b/services/src/init_cmds.c index ff271f459..754e1ae46 100644 --- a/services/src/init_cmds.c +++ b/services/src/init_cmds.c @@ -539,7 +539,7 @@ static void DoMkDir(const char *cmdContent, int maxArg) } while (0); if (rc < 0) { - INIT_LOGE("Run command mkdir failed err = %d", errno); + INIT_LOGE("Run command mkdir %s failed err = %d", ctx->argv[0], errno); (void)rmdir(ctx->argv[0]); } FreeCmd(ctx); -- Gitee