Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
4b8fde96
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看板
未验证
提交
4b8fde96
编写于
5月 31, 2022
作者:
O
openharmony_ci
提交者:
Gitee
5月 31, 2022
浏览文件
操作
浏览文件
下载
差异文件
!732 增加 dump service 命令
Merge pull request !732 from Mupceet/init530_1
上级
2163eada
3118c289
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
84 addition
and
46 deletion
+84
-46
services/begetctl/BUILD.gn
services/begetctl/BUILD.gn
+2
-0
services/begetctl/dump_service.c
services/begetctl/dump_service.c
+48
-0
services/init/include/init_service_manager.h
services/init/include/init_service_manager.h
+1
-4
services/init/init_service_manager.c
services/init/init_service_manager.c
+28
-30
services/init/lite/init.c
services/init/lite/init.c
+0
-5
services/init/standard/init.c
services/init/standard/init.c
+5
-5
services/init/standard/init_control_fd_service.c
services/init/standard/init_control_fd_service.c
+0
-2
未找到文件。
services/begetctl/BUILD.gn
浏览文件 @
4b8fde96
...
...
@@ -61,6 +61,7 @@ if (defined(ohos_lite)) {
ohos_executable("begetctl") {
sources = [
"bootchart_cmd.c",
"dump_service.c",
"init_cmd_reboot.c",
"main.c",
"misc_daemon.cpp",
...
...
@@ -129,6 +130,7 @@ if (defined(ohos_lite)) {
"stop_service",
"service",
"sandbox",
"dump_service",
]
install_images = [ "system" ]
...
...
services/begetctl/dump_service.c
0 → 100644
浏览文件 @
4b8fde96
/*
* 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/include/init_service_manager.h
浏览文件 @
4b8fde96
...
...
@@ -63,11 +63,8 @@ void ReleaseService(Service *service);
void
StartAllServices
(
int
startMode
);
void
LoadAccessTokenId
(
void
);
Service
*
AddService
(
const
char
*
name
);
#ifdef OHOS_SERVICE_DUMP
void
DumpAllServices
();
void
DumpAllServices
(
void
);
void
DumpOneService
(
const
Service
*
service
);
#endif
#ifdef __cplusplus
#if __cplusplus
}
...
...
services/init/init_service_manager.c
浏览文件 @
4b8fde96
...
...
@@ -43,43 +43,42 @@ static const int CRITICAL_DEFAULT_CRASH_TIME = 20;
static
const
int
CRITICAL_DEFAULT_CRASH_COUNT
=
4
;
static
const
int
CRITICAL_CONFIG_ARRAY_LEN
=
3
;
#ifdef OHOS_SERVICE_DUMP
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
++
)
{
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
)
{
printf
(
"
\t
service job info"
);
printf
(
"
\t
service job info
\n
"
);
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
)
{
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
)
{
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
)
{
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
)
{
printf
(
"
\t
service socket info"
);
printf
(
"
\t
service socket info
\n
"
);
ServiceSocket
*
sockopt
=
service
->
socketCfg
;
while
(
sockopt
!=
NULL
)
{
printf
(
"
\t\t
socket name: %s"
,
sockopt
->
name
);
printf
(
"
\t\t
socket type: %d"
,
sockopt
->
type
);
printf
(
"
\t\t
socket uid: %d"
,
sockopt
->
uid
);
printf
(
"
\t\t
socket gid: %d"
,
sockopt
->
gid
);
printf
(
"
\t\t
socket name: %s
\n
"
,
sockopt
->
name
);
printf
(
"
\t\t
socket type: %d
\n
"
,
sockopt
->
type
);
printf
(
"
\t\t
socket uid: %d
\n
"
,
sockopt
->
uid
);
printf
(
"
\t\t
socket gid: %d
\n
"
,
sockopt
->
gid
);
sockopt
=
sockopt
->
next
;
}
}
...
...
@@ -93,33 +92,33 @@ void DumpOneService(const Service *service)
};
int
size
=
0
;
const
InitArgInfo
*
statusMap
=
GetServieStatusMap
(
&
size
);
printf
(
"
\t
service name: [%s]"
,
service
->
name
);
printf
(
"
\t
service pid: [%d]"
,
service
->
pid
);
printf
(
"
\t
service crashCnt: [%d]"
,
service
->
crashCnt
);
printf
(
"
\t
service attribute: [%d]"
,
service
->
attribute
);
printf
(
"
\t
service importance: [%d]"
,
service
->
importance
);
printf
(
"
\t
service startMode: [%s]"
,
startModeMap
[
service
->
status
].
name
);
printf
(
"
\t
service status: [%s]"
,
statusMap
[
service
->
status
].
name
);
printf
(
"
\t
service perms uID [%d]"
,
service
->
servPerm
.
uID
);
printf
(
"
\t
service name: [%s]
\n
"
,
service
->
name
);
printf
(
"
\t
service pid: [%d]
\n
"
,
service
->
pid
);
printf
(
"
\t
service crashCnt: [%d]
\n
"
,
service
->
crashCnt
);
printf
(
"
\t
service attribute: [%d]
\n
"
,
service
->
attribute
);
printf
(
"
\t
service importance: [%d]
\n
"
,
service
->
importance
);
printf
(
"
\t
service startMode: [%s]
\n
"
,
startModeMap
[
service
->
status
].
name
);
printf
(
"
\t
service status: [%s]
\n
"
,
statusMap
[
service
->
status
].
name
);
printf
(
"
\t
service perms uID [%d]
\n
"
,
service
->
servPerm
.
uID
);
DumpServiceArgs
(
"path arg"
,
&
service
->
pathArgs
);
DumpServiceArgs
(
"writepid file"
,
&
service
->
writePidArgs
);
DumpServiceJobs
(
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
++
)
{
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
++
)
{
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
(
void
)
{
printf
(
"Ready to dump all services:"
);
printf
(
"total service number: %d"
,
g_serviceSpace
.
serviceCount
);
printf
(
"Ready to dump all services:
\n
"
);
printf
(
"total service number: %d
\n
"
,
g_serviceSpace
.
serviceCount
);
InitGroupNode
*
node
=
GetNextGroupNode
(
NODE_TYPE_SERVICES
,
NULL
);
while
(
node
!=
NULL
)
{
if
(
node
->
data
.
service
==
NULL
)
{
...
...
@@ -130,9 +129,8 @@ void DumpAllServices()
DumpOneService
(
service
);
node
=
GetNextGroupNode
(
NODE_TYPE_SERVICES
,
node
);
}
printf
(
"Dump all services finished"
);
printf
(
"Dump all services finished
\n
"
);
}
#endif
static
void
FreeServiceArg
(
ServiceArgs
*
arg
)
{
...
...
services/init/lite/init.c
浏览文件 @
4b8fde96
...
...
@@ -65,11 +65,6 @@ void SystemConfig(void)
// read config
ReadConfig
();
// dump config
#ifdef OHOS_SERVICE_DUMP
DumpAllServices
();
#endif
// execute init
DoJob
(
"pre-init"
);
#ifndef __LINUX__
...
...
services/init/standard/init.c
浏览文件 @
4b8fde96
...
...
@@ -266,7 +266,6 @@ static int SystemDump(int id, const char *name, int argc, const char **argv)
{
INIT_ERROR_CHECK
(
argv
!=
NULL
&&
argc
>=
1
,
return
0
,
"Invalid install parameter"
);
INIT_LOGI
(
"Dump system info %s"
,
argv
[
0
]);
DumpAllServices
();
SystemDumpParameters
(
1
);
SystemDumpTriggers
(
1
);
return
0
;
...
...
@@ -324,18 +323,19 @@ static void InitPreHook(const HOOK_INFO *hookInfo)
static
void
InitPostHook
(
const
HOOK_INFO
*
hookInfo
)
{
long
long
diff
;
const
long
long
baseTime
=
1000
;
HOOK_TIMING_STAT
*
stat
=
(
HOOK_TIMING_STAT
*
)
hookInfo
->
cookie
;
clock_gettime
(
CLOCK_MONOTONIC
,
&
(
stat
->
endTime
));
diff
=
(
long
long
)((
stat
->
endTime
.
tv_sec
-
stat
->
startTime
.
tv_sec
)
/
1000
);
diff
=
(
long
long
)((
stat
->
endTime
.
tv_sec
-
stat
->
startTime
.
tv_sec
)
/
baseTime
);
if
(
stat
->
endTime
.
tv_nsec
>
stat
->
startTime
.
tv_nsec
)
{
diff
+=
(
stat
->
endTime
.
tv_nsec
-
stat
->
startTime
.
tv_nsec
)
*
1000
;
diff
+=
(
stat
->
endTime
.
tv_nsec
-
stat
->
startTime
.
tv_nsec
)
*
baseTime
;
}
else
{
diff
-=
(
stat
->
endTime
.
tv_nsec
-
stat
->
startTime
.
tv_nsec
)
*
1000
;
diff
-=
(
stat
->
endTime
.
tv_nsec
-
stat
->
startTime
.
tv_nsec
)
*
baseTime
;
}
INIT_LOGV
(
"Executing hook [%d:%d:%p] cost [%lld]ms, return %d."
,
hookInfo
->
stage
,
hookInfo
->
prio
,
hookInfo
->
hook
,
diff
,
hookInfo
->
retVal
);
hookInfo
->
stage
,
hookInfo
->
prio
,
hookInfo
->
hook
,
diff
,
hookInfo
->
retVal
);
}
void
SystemConfig
(
void
)
...
...
services/init/standard/init_control_fd_service.c
浏览文件 @
4b8fde96
...
...
@@ -47,11 +47,9 @@ static void ProcessDumpServiceControlFd(uint16_t type, const char *serviceCmd)
Service
*
service
=
GetServiceByName
(
serviceCmd
);
if
(
service
==
NULL
)
{
#ifdef OHOS_SERVICE_DUMP
DumpAllServices
();
}
else
{
DumpOneService
(
service
);
#endif
}
return
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录