Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
fdc27465
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
1 年多 前同步成功
通知
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看板
提交
fdc27465
编写于
6月 22, 2022
作者:
M
Mupceet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
init: fix bugs
Signed-off-by:
N
Mupceet
<
laiguizhong@huawei.com
>
上级
0af5095c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
19 addition
and
17 deletion
+19
-17
interfaces/innerkits/control_fd/control_fd_service.c
interfaces/innerkits/control_fd/control_fd_service.c
+17
-15
services/etc/init.without_two_stages.cfg
services/etc/init.without_two_stages.cfg
+1
-1
services/etc/watchdog.cfg
services/etc/watchdog.cfg
+1
-1
未找到文件。
interfaces/innerkits/control_fd/control_fd_service.c
浏览文件 @
fdc27465
...
...
@@ -13,6 +13,7 @@
* limitations under the License.
*/
#include <fcntl.h>
#include <limits.h>
#include <stdbool.h>
#include <sys/wait.h>
#include <unistd.h>
...
...
@@ -41,15 +42,20 @@ static void CmdOnSendMessageComplete(const TaskHandle task, const BufferHandle h
BEGET_LOGI
(
"[control_fd] CmdOnSendMessageComplete "
);
}
static
int
OpenFifo
(
bool
read
,
const
char
*
pipe
Path
)
static
int
ReadFifoPath
(
const
char
*
name
,
bool
read
,
pid_t
pid
,
char
*
resolved
Path
)
{
// create pipe for cmd
if
(
pipePath
==
NULL
)
{
if
((
name
==
NULL
)
||
(
pid
<
0
)
||
resolvedPath
==
NULL
)
{
return
-
1
;
}
int
flag
=
read
?
1
:
0
;
char
path
[
PATH_MAX
]
=
{
0
};
int
ret
=
sprintf_s
(
path
,
sizeof
(
path
)
-
1
,
"/dev/fifo/%s%d.%d"
,
name
,
flag
,
pid
);
BEGET_ERROR_CHECK
(
ret
>
0
,
return
-
1
,
"[control_fd] Failed sprintf_s err=%d"
,
errno
);
char
*
realPath
=
realpath
(
path
,
resolvedPath
);
BEGET_ERROR_CHECK
(
realPath
!=
NULL
,
return
-
1
,
"[control_fd] Failed get real path %s, err=%d"
,
path
,
errno
);
int
flags
=
read
?
(
O_RDONLY
|
O_TRUNC
|
O_NONBLOCK
)
:
(
O_WRONLY
|
O_TRUNC
);
return
open
(
pipePath
,
flags
);
int
fd
=
open
(
resolvedPath
,
flags
);
return
fd
;
}
static
void
CmdOnRecvMessage
(
const
TaskHandle
task
,
const
uint8_t
*
buffer
,
uint32_t
buffLen
)
...
...
@@ -64,17 +70,13 @@ static void CmdOnRecvMessage(const TaskHandle task, const uint8_t *buffer, uint3
BEGET_LOGE
(
"[control_fd] Failed msg "
);
return
;
}
char
readPath
[
FIFO_PATH_SIZE
]
=
{
0
};
int
ret
=
sprintf_s
(
readPath
,
sizeof
(
readPath
)
-
1
,
"/dev/fifo/%s1.%d"
,
msg
->
fifoName
,
msg
->
pid
);
BEGET_ERROR_CHECK
(
ret
>
0
,
return
,
"[control_fd] Failed sprintf_s err=%d"
,
errno
);
int
reader
=
OpenFifo
(
true
,
readPath
);
// read
BEGET_ERROR_CHECK
(
reader
>
0
,
return
,
"[control_fd] Failed to open filo"
);
char
readPath
[
PATH_MAX
]
=
{
0
};
int
reader
=
ReadFifoPath
(
msg
->
fifoName
,
true
,
msg
->
pid
,
readPath
);
// read
BEGET_ERROR_CHECK
(
reader
>
0
,
return
,
"[control_fd] Failed to open fifo read, err=%d"
,
errno
);
char
writePath
[
FIFO_PATH_SIZE
]
=
{
0
};
ret
=
sprintf_s
(
writePath
,
sizeof
(
writePath
)
-
1
,
"/dev/fifo/%s0.%d"
,
msg
->
fifoName
,
msg
->
pid
);
BEGET_ERROR_CHECK
(
ret
>
0
,
return
,
"[control_fd] Failed sprintf_s err=%d"
,
errno
);
int
writer
=
OpenFifo
(
false
,
writePath
);
// write
BEGET_ERROR_CHECK
(
writer
>
0
,
return
,
"[control_fd] Failed to open filo"
);
char
writePath
[
PATH_MAX
]
=
{
0
};
int
writer
=
ReadFifoPath
(
msg
->
fifoName
,
false
,
msg
->
pid
,
writePath
);
// write
BEGET_ERROR_CHECK
(
writer
>
0
,
return
,
"[control_fd] Failed to open fifo write, err=%d"
,
errno
);
pid_t
pid
=
fork
();
if
(
pid
==
0
)
{
...
...
services/etc/init.without_two_stages.cfg
浏览文件 @
fdc27465
...
...
@@ -280,7 +280,7 @@
"start-mode" : "condition"
}, {
"name" : "watchdog_service",
"path" : ["/system/bin/watchdog_service", "10", "
2
"],
"path" : ["/system/bin/watchdog_service", "10", "
15
"],
"disabled" : 1,
"uid" : "watchdog",
"gid" : ["watchdog", "log", "readproc"],
...
...
services/etc/watchdog.cfg
浏览文件 @
fdc27465
...
...
@@ -2,7 +2,7 @@
"services" : [{
"name" : "watchdog_service",
"start-mode" : "condition",
"path" : ["/system/bin/watchdog_service", "10", "
2
"],
"path" : ["/system/bin/watchdog_service", "10", "
15
"],
"disabled" : 1,
"sandbox" : 0,
"uid" : "watchdog",
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录