Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
8cb57654
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看板
提交
8cb57654
编写于
5月 30, 2022
作者:
M
Mupceet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
init: add dump service
Signed-off-by:
N
Mupceet
<
laiguizhong@huawei.com
>
上级
9c0259f6
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
76 addition
and
32 deletion
+76
-32
services/begetctl/BUILD.gn
services/begetctl/BUILD.gn
+1
-0
services/begetctl/dump_service.c
services/begetctl/dump_service.c
+48
-0
services/init/init_service_manager.c
services/init/init_service_manager.c
+27
-27
services/init/lite/init.c
services/init/lite/init.c
+0
-5
未找到文件。
services/begetctl/BUILD.gn
浏览文件 @
8cb57654
...
@@ -61,6 +61,7 @@ if (defined(ohos_lite)) {
...
@@ -61,6 +61,7 @@ if (defined(ohos_lite)) {
ohos_executable("begetctl") {
ohos_executable("begetctl") {
sources = [
sources = [
"bootchart_cmd.c",
"bootchart_cmd.c",
"dump_service.c",
"init_cmd_reboot.c",
"init_cmd_reboot.c",
"main.c",
"main.c",
"misc_daemon.cpp",
"misc_daemon.cpp",
...
...
services/begetctl/dump_service.c
0 → 100644
浏览文件 @
8cb57654
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include "begetctl.h"
#include "control_fd.h"
#include "init_utils.h"
#define DUMP_SERVICE_INFO_CMD_ARGS 2
static
int
main_cmd
(
BShellHandle
shell
,
int
argc
,
char
**
argv
)
{
if
(
argc
!=
DUMP_SERVICE_INFO_CMD_ARGS
)
{
BShellCmdHelp
(
shell
,
argc
,
argv
);
return
0
;
}
if
(
strcmp
(
argv
[
0
],
"dump_service"
)
==
0
)
{
printf
(
"dump service info
\n
"
);
CmdClientInit
(
INIT_CONTROL_FD_SOCKET_PATH
,
ACTION_DUMP
,
argv
[
1
],
"FIFO"
);
}
else
{
BShellCmdHelp
(
shell
,
argc
,
argv
);
}
return
0
;
}
MODULE_CONSTRUCTOR
(
void
)
{
CmdInfo
infos
[]
=
{
{
"dump_service"
,
main_cmd
,
"dump one service info by serviceName"
,
"dump_service serviceName"
,
NULL
},
{
"dump_service"
,
main_cmd
,
"dump all services info"
,
"dump_service all"
,
NULL
},
};
for
(
size_t
i
=
0
;
i
<
sizeof
(
infos
)
/
sizeof
(
infos
[
0
]);
i
++
)
{
BShellEnvRegitsterCmd
(
GetShellHandle
(),
&
infos
[
i
]);
}
}
services/init/init_service_manager.c
浏览文件 @
8cb57654
...
@@ -46,40 +46,40 @@ static const int CRITICAL_CONFIG_ARRAY_LEN = 3;
...
@@ -46,40 +46,40 @@ static const int CRITICAL_CONFIG_ARRAY_LEN = 3;
#ifdef OHOS_SERVICE_DUMP
#ifdef OHOS_SERVICE_DUMP
static
void
DumpServiceArgs
(
const
char
*
info
,
const
ServiceArgs
*
args
)
static
void
DumpServiceArgs
(
const
char
*
info
,
const
ServiceArgs
*
args
)
{
{
printf
(
"
\t
service %s count %d"
,
info
,
args
->
count
);
printf
(
"
\t
service %s count %d
\n
"
,
info
,
args
->
count
);
for
(
int
j
=
0
;
j
<
args
->
count
;
j
++
)
{
for
(
int
j
=
0
;
j
<
args
->
count
;
j
++
)
{
if
(
args
->
argv
[
j
]
!=
NULL
)
{
if
(
args
->
argv
[
j
]
!=
NULL
)
{
printf
(
"
\t\t
info [%d] %s"
,
j
,
args
->
argv
[
j
]);
printf
(
"
\t\t
info [%d] %s
\n
"
,
j
,
args
->
argv
[
j
]);
}
}
}
}
}
}
static
void
DumpServiceJobs
(
const
Service
*
service
)
static
void
DumpServiceJobs
(
const
Service
*
service
)
{
{
printf
(
"
\t
service job info"
);
printf
(
"
\t
service job info
\n
"
);
if
(
service
->
serviceJobs
.
jobsName
[
JOB_ON_BOOT
]
!=
NULL
)
{
if
(
service
->
serviceJobs
.
jobsName
[
JOB_ON_BOOT
]
!=
NULL
)
{
printf
(
"
\t\t
service boot job %s"
,
service
->
serviceJobs
.
jobsName
[
JOB_ON_BOOT
]);
printf
(
"
\t\t
service boot job %s
\n
"
,
service
->
serviceJobs
.
jobsName
[
JOB_ON_BOOT
]);
}
}
if
(
service
->
serviceJobs
.
jobsName
[
JOB_ON_START
]
!=
NULL
)
{
if
(
service
->
serviceJobs
.
jobsName
[
JOB_ON_START
]
!=
NULL
)
{
printf
(
"
\t\t
service start job %s"
,
service
->
serviceJobs
.
jobsName
[
JOB_ON_START
]);
printf
(
"
\t\t
service start job %s
\n
"
,
service
->
serviceJobs
.
jobsName
[
JOB_ON_START
]);
}
}
if
(
service
->
serviceJobs
.
jobsName
[
JOB_ON_STOP
]
!=
NULL
)
{
if
(
service
->
serviceJobs
.
jobsName
[
JOB_ON_STOP
]
!=
NULL
)
{
printf
(
"
\t\t
service stop job %s"
,
service
->
serviceJobs
.
jobsName
[
JOB_ON_STOP
]);
printf
(
"
\t\t
service stop job %s
\n
"
,
service
->
serviceJobs
.
jobsName
[
JOB_ON_STOP
]);
}
}
if
(
service
->
serviceJobs
.
jobsName
[
JOB_ON_RESTART
]
!=
NULL
)
{
if
(
service
->
serviceJobs
.
jobsName
[
JOB_ON_RESTART
]
!=
NULL
)
{
printf
(
"
\t\t
service restart job %s"
,
service
->
serviceJobs
.
jobsName
[
JOB_ON_RESTART
]);
printf
(
"
\t\t
service restart job %s
\n
"
,
service
->
serviceJobs
.
jobsName
[
JOB_ON_RESTART
]);
}
}
}
}
static
void
DumpServiceSocket
(
const
Service
*
service
)
static
void
DumpServiceSocket
(
const
Service
*
service
)
{
{
printf
(
"
\t
service socket info"
);
printf
(
"
\t
service socket info
\n
"
);
ServiceSocket
*
sockopt
=
service
->
socketCfg
;
ServiceSocket
*
sockopt
=
service
->
socketCfg
;
while
(
sockopt
!=
NULL
)
{
while
(
sockopt
!=
NULL
)
{
printf
(
"
\t\t
socket name: %s"
,
sockopt
->
name
);
printf
(
"
\t\t
socket name: %s
\n
"
,
sockopt
->
name
);
printf
(
"
\t\t
socket type: %d"
,
sockopt
->
type
);
printf
(
"
\t\t
socket type: %d
\n
"
,
sockopt
->
type
);
printf
(
"
\t\t
socket uid: %d"
,
sockopt
->
uid
);
printf
(
"
\t\t
socket uid: %d
\n
"
,
sockopt
->
uid
);
printf
(
"
\t\t
socket gid: %d"
,
sockopt
->
gid
);
printf
(
"
\t\t
socket gid: %d
\n
"
,
sockopt
->
gid
);
sockopt
=
sockopt
->
next
;
sockopt
=
sockopt
->
next
;
}
}
}
}
...
@@ -93,33 +93,33 @@ void DumpOneService(const Service *service)
...
@@ -93,33 +93,33 @@ void DumpOneService(const Service *service)
};
};
int
size
=
0
;
int
size
=
0
;
const
InitArgInfo
*
statusMap
=
GetServieStatusMap
(
&
size
);
const
InitArgInfo
*
statusMap
=
GetServieStatusMap
(
&
size
);
printf
(
"
\t
service name: [%s]"
,
service
->
name
);
printf
(
"
\t
service name: [%s]
\n
"
,
service
->
name
);
printf
(
"
\t
service pid: [%d]"
,
service
->
pid
);
printf
(
"
\t
service pid: [%d]
\n
"
,
service
->
pid
);
printf
(
"
\t
service crashCnt: [%d]"
,
service
->
crashCnt
);
printf
(
"
\t
service crashCnt: [%d]
\n
"
,
service
->
crashCnt
);
printf
(
"
\t
service attribute: [%d]"
,
service
->
attribute
);
printf
(
"
\t
service attribute: [%d]
\n
"
,
service
->
attribute
);
printf
(
"
\t
service importance: [%d]"
,
service
->
importance
);
printf
(
"
\t
service importance: [%d]
\n
"
,
service
->
importance
);
printf
(
"
\t
service startMode: [%s]"
,
startModeMap
[
service
->
status
].
name
);
printf
(
"
\t
service startMode: [%s]
\n
"
,
startModeMap
[
service
->
status
].
name
);
printf
(
"
\t
service status: [%s]"
,
statusMap
[
service
->
status
].
name
);
printf
(
"
\t
service status: [%s]
\n
"
,
statusMap
[
service
->
status
].
name
);
printf
(
"
\t
service perms uID [%d]"
,
service
->
servPerm
.
uID
);
printf
(
"
\t
service perms uID [%d]
\n
"
,
service
->
servPerm
.
uID
);
DumpServiceArgs
(
"path arg"
,
&
service
->
pathArgs
);
DumpServiceArgs
(
"path arg"
,
&
service
->
pathArgs
);
DumpServiceArgs
(
"writepid file"
,
&
service
->
writePidArgs
);
DumpServiceArgs
(
"writepid file"
,
&
service
->
writePidArgs
);
DumpServiceJobs
(
service
);
DumpServiceJobs
(
service
);
DumpServiceSocket
(
service
);
DumpServiceSocket
(
service
);
printf
(
"
\t
service perms groupId %d"
,
service
->
servPerm
.
gIDCnt
);
printf
(
"
\t
service perms groupId %d
\n
"
,
service
->
servPerm
.
gIDCnt
);
for
(
int
i
=
0
;
i
<
service
->
servPerm
.
gIDCnt
;
i
++
)
{
for
(
int
i
=
0
;
i
<
service
->
servPerm
.
gIDCnt
;
i
++
)
{
printf
(
"
\t\t
service perms groupId %d"
,
service
->
servPerm
.
gIDArray
[
i
]);
printf
(
"
\t\t
service perms groupId %d
\n
"
,
service
->
servPerm
.
gIDArray
[
i
]);
}
}
printf
(
"
\t
service perms capability %d"
,
service
->
servPerm
.
capsCnt
);
printf
(
"
\t
service perms capability %d
\n
"
,
service
->
servPerm
.
capsCnt
);
for
(
int
i
=
0
;
i
<
(
int
)
service
->
servPerm
.
capsCnt
;
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
service
->
servPerm
.
capsCnt
;
i
++
)
{
printf
(
"
\t\t
service perms capability %d"
,
service
->
servPerm
.
caps
[
i
]);
printf
(
"
\t\t
service perms capability %d
\n
"
,
service
->
servPerm
.
caps
[
i
]);
}
}
}
}
void
DumpAllServices
()
void
DumpAllServices
()
{
{
printf
(
"Ready to dump all services:"
);
printf
(
"Ready to dump all services:
\n
"
);
printf
(
"total service number: %d"
,
g_serviceSpace
.
serviceCount
);
printf
(
"total service number: %d
\n
"
,
g_serviceSpace
.
serviceCount
);
InitGroupNode
*
node
=
GetNextGroupNode
(
NODE_TYPE_SERVICES
,
NULL
);
InitGroupNode
*
node
=
GetNextGroupNode
(
NODE_TYPE_SERVICES
,
NULL
);
while
(
node
!=
NULL
)
{
while
(
node
!=
NULL
)
{
if
(
node
->
data
.
service
==
NULL
)
{
if
(
node
->
data
.
service
==
NULL
)
{
...
@@ -130,7 +130,7 @@ void DumpAllServices()
...
@@ -130,7 +130,7 @@ void DumpAllServices()
DumpOneService
(
service
);
DumpOneService
(
service
);
node
=
GetNextGroupNode
(
NODE_TYPE_SERVICES
,
node
);
node
=
GetNextGroupNode
(
NODE_TYPE_SERVICES
,
node
);
}
}
printf
(
"Dump all services finished"
);
printf
(
"Dump all services finished
\n
"
);
}
}
#endif
#endif
...
...
services/init/lite/init.c
浏览文件 @
8cb57654
...
@@ -65,11 +65,6 @@ void SystemConfig(void)
...
@@ -65,11 +65,6 @@ void SystemConfig(void)
// read config
// read config
ReadConfig
();
ReadConfig
();
// dump config
#ifdef OHOS_SERVICE_DUMP
DumpAllServices
();
#endif
// execute init
// execute init
DoJob
(
"pre-init"
);
DoJob
(
"pre-init"
);
#ifndef __LINUX__
#ifndef __LINUX__
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录