Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
f8b19b1e
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
接近 2 年 前同步成功
通知
3
Star
37
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Startup Init Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f8b19b1e
编写于
5月 11, 2022
作者:
M
Mupceet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add: syncexec command
Signed-off-by:
N
Mupceet
<
laiguizhong@huawei.com
>
上级
b0aae888
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
37 addition
and
22 deletion
+37
-22
services/init/standard/init_cmds.c
services/init/standard/init_cmds.c
+37
-22
未找到文件。
services/init/standard/init_cmds.c
浏览文件 @
f8b19b1e
...
...
@@ -89,6 +89,32 @@ int GetParamValue(const char *symValue, unsigned int symLen, char *paramValue, u
return
0
;
}
static
int
SyncExecCommand
(
int
argc
,
char
*
const
*
argv
)
{
if
(
argc
==
0
||
argv
==
NULL
||
argv
[
0
]
==
NULL
)
{
return
-
1
;
}
pid_t
pid
=
fork
();
if
(
pid
<
0
)
{
INIT_LOGE
(
"Fork new process to format failed: %d"
,
errno
);
return
-
1
;
}
if
(
pid
==
0
)
{
INIT_CHECK_ONLY_ELOG
(
execv
(
argv
[
0
],
argv
)
==
0
,
"execv %s failed! err %d."
,
argv
[
0
],
errno
);
exit
(
-
1
);
}
int
status
;
pid_t
ret
=
waitpid
(
pid
,
&
status
,
0
);
if
(
ret
!=
pid
)
{
INIT_LOGE
(
"Failed to wait pid %d, errno %d"
,
pid
,
errno
);
return
ret
;
}
if
(
!
WIFEXITED
(
status
)
||
WEXITSTATUS
(
status
)
!=
0
)
{
INIT_LOGE
(
"Command %s failed with status %d"
,
argv
[
0
],
WEXITSTATUS
(
status
));
}
return
0
;
}
static
void
DoIfup
(
const
struct
CmdArgs
*
ctx
)
{
struct
ifreq
interface
;
...
...
@@ -172,6 +198,16 @@ static void DoLoadDefaultParams(const struct CmdArgs *ctx)
LoadDefaultParams
(
ctx
->
argv
[
0
],
mode
);
}
static
void
DoSyncExec
(
const
struct
CmdArgs
*
ctx
)
{
// format: syncexec /xxx/xxx/xxx xxx
INIT_ERROR_CHECK
(
ctx
!=
NULL
&&
ctx
->
argv
[
0
]
!=
NULL
,
return
,
"DoSyncExec: invalid arguments to exec
\"
%s
\"
"
,
ctx
->
argv
[
0
]);
int
ret
=
SyncExecCommand
(
ctx
->
argc
,
ctx
->
argv
);
INIT_LOGI
(
"DoSyncExec end with ret %d"
,
ret
);
return
;
}
static
void
DoExec
(
const
struct
CmdArgs
*
ctx
)
{
// format: exec /xxx/xxx/xxx xxx
...
...
@@ -383,28 +419,6 @@ static void DoTimerStop(const struct CmdArgs *ctx)
ServiceStopTimer
(
service
);
}
static
int
SyncExecCommand
(
int
argc
,
char
*
const
*
argv
)
{
if
(
argc
==
0
||
argv
==
NULL
||
argv
[
0
]
==
NULL
)
{
return
-
1
;
}
pid_t
pid
=
fork
();
if
(
pid
<
0
)
{
INIT_LOGE
(
"Fork new process to format failed: %d"
,
errno
);
return
-
1
;
}
if
(
pid
==
0
)
{
execv
(
argv
[
0
],
argv
);
exit
(
-
1
);
}
int
status
;
waitpid
(
pid
,
&
status
,
0
);
if
(
!
WIFEXITED
(
status
)
||
WEXITSTATUS
(
status
)
!=
0
)
{
INIT_LOGE
(
"Command %s failed with status %d"
,
argv
[
0
],
WEXITSTATUS
(
status
));
}
return
WEXITSTATUS
(
status
);
}
static
void
DoInitGlobalKey
(
const
struct
CmdArgs
*
ctx
)
{
INIT_LOGI
(
"DoInitGlobalKey: start"
);
...
...
@@ -526,6 +540,7 @@ static void DoMkSandbox(const struct CmdArgs *ctx)
}
static
const
struct
CmdTable
g_cmdTable
[]
=
{
{
"syncexec "
,
1
,
10
,
DoSyncExec
},
{
"exec "
,
1
,
10
,
DoExec
},
{
"mknode "
,
1
,
5
,
DoMakeNode
},
{
"makedev "
,
2
,
2
,
DoMakeDevice
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录