提交 f41476fe 编写于 作者: O openharmony_ci 提交者: Gitee

!73 修改mkdir cmd

Merge pull request !73 from 熊磊/init0729
...@@ -359,14 +359,18 @@ out: ...@@ -359,14 +359,18 @@ out:
static void DoMkDir(const char* cmdContent, int maxArg) static void DoMkDir(const char* cmdContent, int maxArg)
{ {
// format: mkdir /xxx/xxx/xxx or mkdir /xxx/xxx/xxx mode owner group // mkdir support format:
// 1.mkdir path
// 2.mkdir path mode
// 3.mkdir path mode owner group
struct CmdArgs *ctx = GetCmd(cmdContent, " ", maxArg); struct CmdArgs *ctx = GetCmd(cmdContent, " ", maxArg);
if (ctx == NULL || ctx->argv == NULL || ctx->argc < 1) { if (ctx == NULL || ctx->argv == NULL || ctx->argc < 1) {
INIT_LOGE("DoMkDir invalid arguments :%s", cmdContent); INIT_LOGE("DoMkDir invalid arguments :%s", cmdContent);
goto out; goto out;
} }
if (ctx->argc != 1 && ctx->argc != maxArg) { const int withModeArg = 2;
if (ctx->argc != 1 && ctx->argc != maxArg && ctx->argc != withModeArg) {
INIT_LOGE("DoMkDir invalid arguments: %s", cmdContent); INIT_LOGE("DoMkDir invalid arguments: %s", cmdContent);
goto out; goto out;
} }
...@@ -382,6 +386,9 @@ static void DoMkDir(const char* cmdContent, int maxArg) ...@@ -382,6 +386,9 @@ static void DoMkDir(const char* cmdContent, int maxArg)
if (chmod(ctx->argv[0], mode) != 0) { if (chmod(ctx->argv[0], mode) != 0) {
INIT_LOGE("DoMkDir failed for %s, err %d.", cmdContent, errno); INIT_LOGE("DoMkDir failed for %s, err %d.", cmdContent, errno);
} }
if (ctx->argc == withModeArg) {
goto out;
}
const int ownerPos = 2; const int ownerPos = 2;
const int groupPos = 3; const int groupPos = 3;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册