Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
c96253d2
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看板
未验证
提交
c96253d2
编写于
9月 08, 2022
作者:
O
openharmony_ci
提交者:
Gitee
9月 08, 2022
浏览文件
操作
浏览文件
下载
差异文件
!1205 解析cfg后,打印trigger信息
Merge pull request !1205 from cheng_jinsong/triggerdump
上级
dfe5bb3d
3a8cefe5
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
67 addition
and
15 deletion
+67
-15
services/begetctl/param_cmd.c
services/begetctl/param_cmd.c
+2
-2
services/include/param/init_param.h
services/include/param/init_param.h
+2
-2
services/init/standard/init_control_fd_service.c
services/init/standard/init_control_fd_service.c
+1
-1
services/modules/init_hook/BUILD.gn
services/modules/init_hook/BUILD.gn
+4
-1
services/modules/init_hook/init_hook.c
services/modules/init_hook/init_hook.c
+25
-0
services/modules/reboot/BUILD.gn
services/modules/reboot/BUILD.gn
+4
-0
services/param/include/param_utils.h
services/param/include/param_utils.h
+2
-1
services/param/manager/param_manager.c
services/param/manager/param_manager.c
+14
-2
services/param/trigger/trigger_manager.c
services/param/trigger/trigger_manager.c
+9
-2
test/fuzztest/systemdumpparameters_fuzzer/systemdumpparameters_fuzzer.cpp
...stemdumpparameters_fuzzer/systemdumpparameters_fuzzer.cpp
+1
-1
test/unittest/param/client_unittest.cpp
test/unittest/param/client_unittest.cpp
+1
-1
test/unittest/param/param_unittest.cpp
test/unittest/param/param_unittest.cpp
+1
-1
test/unittest/param/paramservice_unittest.cpp
test/unittest/param/paramservice_unittest.cpp
+1
-1
未找到文件。
services/begetctl/param_cmd.c
浏览文件 @
c96253d2
...
...
@@ -359,9 +359,9 @@ static int32_t BShellParamCmdDump(BShellHandle shell, int32_t argc, char *argv[]
{
BSH_CHECK
(
shell
!=
NULL
,
return
BSH_INVALID_PARAM
,
"Invalid shell env"
);
if
(
argc
>=
2
&&
strcmp
(
argv
[
1
],
"verbose"
)
==
0
)
{
// 2 min arg
SystemDumpParameters
(
1
);
SystemDumpParameters
(
1
,
printf
);
}
else
{
SystemDumpParameters
(
0
);
SystemDumpParameters
(
0
,
printf
);
}
return
0
;
}
...
...
services/include/param/init_param.h
浏览文件 @
c96253d2
...
...
@@ -146,7 +146,7 @@ void RegisterBootStateChange(void (*bootStateChange)(const char *));
* dump 参数和trigger信息
*
*/
void
SystemDumpTriggers
(
int
verbose
);
void
SystemDumpTriggers
(
int
verbose
,
int
(
*
dump
)(
const
char
*
fmt
,
...)
);
#endif
/**
...
...
@@ -217,7 +217,7 @@ int SystemWatchParameter(const char *keyprefix, ParameterChangePtr change, void
int
SystemCheckParamExist
(
const
char
*
name
);
long
long
GetSystemCommitId
(
void
);
void
SystemDumpParameters
(
int
verbose
);
void
SystemDumpParameters
(
int
verbose
,
int
(
*
dump
)(
const
char
*
fmt
,
...)
);
int
WatchParamCheck
(
const
char
*
keyprefix
);
...
...
services/init/standard/init_control_fd_service.c
浏览文件 @
c96253d2
...
...
@@ -190,7 +190,7 @@ static void ProcessDumpServiceControlFd(uint16_t type, const char *serviceCmd)
}
if
(
strcmp
(
serviceCmd
,
"parameter_service"
)
==
0
)
{
if
(
cmd
!=
NULL
&&
strcmp
(
cmd
,
"trigger"
)
==
0
)
{
SystemDumpTriggers
(
0
);
SystemDumpTriggers
(
0
,
printf
);
}
return
;
}
...
...
services/modules/init_hook/BUILD.gn
浏览文件 @
c96253d2
...
...
@@ -37,7 +37,10 @@ if (defined(ohos_lite)) {
}
} else {
ohos_source_set("inithook") {
defines = [ "_GNU_SOURCE" ]
defines = [
"_GNU_SOURCE",
"PARAM_SUPPORT_TRIGGER",
]
include_dirs = comm_include
sources = [
"init_hook.c",
...
...
services/modules/init_hook/init_hook.c
浏览文件 @
c96253d2
...
...
@@ -21,6 +21,7 @@
#include "securec.h"
#include "init_module_engine.h"
#include "init_group_manager.h"
#include "init_param.h"
#include "hookmgr.h"
#include "bootstage.h"
...
...
@@ -127,7 +128,31 @@ static int ParamSetBootEventHook(const HOOK_INFO *hookInfo, void *cookie)
return
0
;
}
static
int
DumpTrigger
(
const
char
*
fmt
,
...)
{
va_list
vargs
;
va_start
(
vargs
,
fmt
);
InitLog
(
INIT_INFO
,
INIT_LOG_DOMAIN
,
INIT_LOG_TAG
,
fmt
,
vargs
);
va_end
(
vargs
);
return
0
;
}
static
int
DumpServiceHook
(
const
HOOK_INFO
*
info
,
void
*
cookie
)
{
// check and dump all jobs
char
dump
[
8
]
=
{
0
};
// 8 len
uint32_t
len
=
sizeof
(
dump
);
int
ret
=
SystemReadParam
(
"persist.init.debug.dump.trigger"
,
dump
,
&
len
);
PLUGIN_LOGV
(
"boot dump %s ret %d"
,
dump
,
ret
);
if
(
ret
==
0
&&
strcmp
(
dump
,
"1"
)
==
0
)
{
SystemDumpTriggers
(
1
,
DumpTrigger
);
}
return
0
;
}
MODULE_CONSTRUCTOR
(
void
)
{
InitAddGlobalInitHook
(
0
,
ParamSetBootEventHook
);
// Depends on parameter service
InitAddPostPersistParamLoadHook
(
0
,
DumpServiceHook
);
}
services/modules/reboot/BUILD.gn
浏览文件 @
c96253d2
...
...
@@ -36,6 +36,10 @@ ohos_shared_library("rebootmodule") {
} else {
module_install_dir = "lib/init"
}
install_images = [
"system",
"updater",
]
}
ohos_source_set("libreboot_static") {
...
...
services/param/include/param_utils.h
浏览文件 @
c96253d2
...
...
@@ -129,7 +129,8 @@ INIT_LOCAL_API void ParamWorBaseLog(InitLogLevel logLevel, uint32_t domain, cons
exper
;
\
}
#define PARAM_DUMP printf
typedef
int
(
*
DUMP_PRINTF
)(
const
char
*
fmt
,
...);
#define PARAM_DUMP g_printf
#define MAX_LABEL_LEN 256
#define PARAM_BUFFER_SIZE 256
...
...
services/param/manager/param_manager.c
浏览文件 @
c96253d2
...
...
@@ -23,6 +23,7 @@
#include "param_trie.h"
#include "param_utils.h"
#include "securec.h"
static
DUMP_PRINTF
g_printf
=
printf
;
ParamNode
*
SystemCheckMatchParamWait
(
const
char
*
name
,
const
char
*
value
)
{
...
...
@@ -162,8 +163,13 @@ static void HashNodeTraverseForDump(WorkSpace *workSpace, int verbose)
PARAMSPACE_AREA_RW_UNLOCK
(
workSpace
);
}
void
SystemDumpParameters
(
int
verbose
)
void
SystemDumpParameters
(
int
verbose
,
int
(
*
dump
)(
const
char
*
fmt
,
...)
)
{
if
(
dump
!=
NULL
)
{
g_printf
=
dump
;
}
else
{
g_printf
=
printf
;
}
ParamWorkSpace
*
paramSpace
=
GetParamWorkSpace
();
PARAM_CHECK
(
paramSpace
!=
NULL
,
return
,
"Invalid paramSpace"
);
PARAM_WORKSPACE_CHECK
(
paramSpace
,
return
,
"Invalid space"
);
...
...
@@ -173,10 +179,16 @@ void SystemDumpParameters(int verbose)
if
(
ret
!=
PARAM_CODE_NOT_FOUND
&&
ret
!=
0
&&
ret
!=
PARAM_CODE_NODE_EXIST
)
{
PARAM_CHECK
(
ret
==
0
,
return
,
"Forbid to dump parameters"
);
}
#ifdef PARAM_SUPPORT_SELINUX // load security label
ParamSecurityOps
*
ops
=
GetParamSecurityOps
(
PARAM_SECURITY_SELINUX
);
if
(
ops
!=
NULL
&&
ops
->
securityGetLabel
!=
NULL
)
{
ops
->
securityGetLabel
(
NULL
);
}
#endif
PARAM_DUMP
(
"Dump all parameters begin ...
\n
"
);
if
(
verbose
)
{
PARAM_DUMP
(
"Local sercurity information
\n
"
);
PARAM_DUMP
(
"
\t
pid: %d uid: %u gid: %u
\n
"
,
PARAM_DUMP
(
"pid: %d uid: %u gid: %u
\n
"
,
paramSpace
->
securityLabel
.
cred
.
pid
,
paramSpace
->
securityLabel
.
cred
.
uid
,
paramSpace
->
securityLabel
.
cred
.
gid
);
...
...
services/param/trigger/trigger_manager.c
浏览文件 @
c96253d2
...
...
@@ -23,6 +23,8 @@
#include "trigger_checker.h"
#include "securec.h"
static
DUMP_PRINTF
g_printf
=
printf
;
int
AddCommand
(
JobNode
*
trigger
,
uint32_t
cmdKeyIndex
,
const
char
*
content
)
{
PARAM_CHECK
(
trigger
!=
NULL
,
return
-
1
,
"trigger is null"
);
...
...
@@ -41,7 +43,7 @@ int AddCommand(JobNode *trigger, uint32_t cmdKeyIndex, const char *content)
PARAM_CHECK
(
ret
==
EOK
,
free
(
node
);
return
0
,
"Failed to copy command"
);
}
// 插入队列
if
(
trigger
->
firstCmd
==
NULL
)
{
trigger
->
firstCmd
=
node
;
trigger
->
lastCmd
=
node
;
...
...
@@ -518,8 +520,13 @@ static void DumpTrigger_(const TriggerWorkSpace *workSpace, int type)
}
}
void
SystemDumpTriggers
(
int
verbose
)
void
SystemDumpTriggers
(
int
verbose
,
int
(
*
dump
)(
const
char
*
fmt
,
...)
)
{
if
(
dump
!=
NULL
)
{
g_printf
=
dump
;
}
else
{
g_printf
=
printf
;
}
TriggerWorkSpace
*
workSpace
=
GetTriggerWorkSpace
();
PARAM_CHECK
(
workSpace
!=
NULL
,
return
,
"Invalid workSpace "
);
PARAM_DUMP
(
"workspace queue BOOT info:
\n
"
);
...
...
test/fuzztest/systemdumpparameters_fuzzer/systemdumpparameters_fuzzer.cpp
浏览文件 @
c96253d2
...
...
@@ -24,7 +24,7 @@ namespace OHOS {
CloseStdout
();
std
::
string
str
(
reinterpret_cast
<
const
char
*>
(
data
),
size
);
int
verbose
=
atoi
(
str
.
c_str
());
SystemDumpParameters
(
verbose
);
SystemDumpParameters
(
verbose
,
nullptr
);
return
true
;
}
}
...
...
test/unittest/param/client_unittest.cpp
浏览文件 @
c96253d2
...
...
@@ -209,7 +209,7 @@ HWTEST_F(ClientUnitTest, TestClient_03, TestSize.Level0)
{
// 3 Traversal test
TestParamTraversal
();
SystemDumpParameters
(
1
);
SystemDumpParameters
(
1
,
NULL
);
}
HWTEST_F
(
ClientUnitTest
,
TestClient_04
,
TestSize
.
Level0
)
...
...
test/unittest/param/param_unittest.cpp
浏览文件 @
c96253d2
...
...
@@ -298,7 +298,7 @@ public:
int
TestDumpParamMemory
()
{
SystemDumpParameters
(
1
);
SystemDumpParameters
(
1
,
NULL
);
return
0
;
}
};
...
...
test/unittest/param/paramservice_unittest.cpp
浏览文件 @
c96253d2
...
...
@@ -429,7 +429,7 @@ public:
char
buffer
[]
=
"testbuff"
;
CheckTrigger
(
GetTriggerWorkSpace
(),
TRIGGER_PARAM_WATCH
,
buffer
,
strlen
(
buffer
),
TestTriggerExecute
);
#ifdef PARAM_SUPPORT_TRIGGER
SystemDumpTriggers
(
1
);
SystemDumpTriggers
(
1
,
NULL
);
#endif
AddWatch
(
MSG_DEL_WATCHER
,
name
,
value
);
return
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录