Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
bf433961
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看板
未验证
提交
bf433961
编写于
11月 23, 2022
作者:
O
openharmony_ci
提交者:
Gitee
11月 23, 2022
浏览文件
操作
浏览文件
下载
差异文件
!1546 系统优化:commit相关接口移到base
Merge pull request !1546 from yichengzhao/cherry-pick-1669120720
上级
e5bdc477
f5dabfb0
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
81 addition
and
73 deletion
+81
-73
services/include/param/init_param.h
services/include/param/init_param.h
+0
-25
services/include/param/sys_param.h
services/include/param/sys_param.h
+27
-0
services/modules/reboot/reboot.c
services/modules/reboot/reboot.c
+16
-0
services/param/base/param_base.c
services/param/base/param_base.c
+37
-0
services/param/linux/param_request.c
services/param/linux/param_request.c
+0
-10
services/param/liteos/param_client.c
services/param/liteos/param_client.c
+0
-10
services/param/manager/param_manager.c
services/param/manager/param_manager.c
+1
-28
未找到文件。
services/include/param/init_param.h
浏览文件 @
bf433961
...
...
@@ -36,8 +36,6 @@ extern "C" {
#define PARAM_NAME_LEN_MAX 96
#endif
typedef
uint32_t
ParamHandle
;
typedef
enum
{
PARAM_CODE_ERROR
=
-
1
,
PARAM_CODE_SUCCESS
=
0
,
...
...
@@ -166,21 +164,6 @@ int SystemSetParameter(const char *name, const char *value);
*/
#define SystemGetParameter SystemReadParam
/**
* 对外接口
* 查询参数,主要用于其他进程使用,找到对应属性的handle。
*
*/
int
SystemFindParameter
(
const
char
*
name
,
ParamHandle
*
handle
);
/**
* 对外接口
* 根据handle获取对应数据的修改标识。
* commitId 获取计数变化
*
*/
int
SystemGetParameterCommitId
(
ParamHandle
handle
,
uint32_t
*
commitId
);
/**
* 外部接口
* 遍历参数。
...
...
@@ -198,13 +181,6 @@ int SystemTraversalParameter(const char *prefix,
*/
int
SystemGetParameterName
(
ParamHandle
handle
,
char
*
name
,
unsigned
int
len
);
/**
* 外部接口
* 获取参数值。
*
*/
int
SystemGetParameterValue
(
ParamHandle
handle
,
char
*
value
,
unsigned
int
*
len
);
/**
* 外部接口
* 等待某个参数值被修改,阻塞直到参数值被修改或超时
...
...
@@ -216,7 +192,6 @@ typedef void (*ParameterChangePtr)(const char *key, const char *value, void *con
int
SystemWatchParameter
(
const
char
*
keyprefix
,
ParameterChangePtr
change
,
void
*
context
);
int
SystemCheckParamExist
(
const
char
*
name
);
long
long
GetSystemCommitId
(
void
);
void
SystemDumpParameters
(
int
verbose
,
int
(
*
dump
)(
const
char
*
fmt
,
...));
...
...
services/include/param/sys_param.h
浏览文件 @
bf433961
...
...
@@ -23,6 +23,8 @@ extern "C" {
#endif
#endif
typedef
uint32_t
ParamHandle
;
typedef
struct
{
uint8_t
updaterMode
;
void
(
*
logFunc
)(
int
logLevel
,
uint32_t
domain
,
const
char
*
tag
,
const
char
*
fmt
,
va_list
vargs
);
...
...
@@ -45,6 +47,31 @@ int SystemReadParam(const char *name, char *value, uint32_t *len);
* parameter client初始化接口 供服务调用
*/
void
InitParameterClient
(
void
);
/**
* 对外接口
* 查询参数,主要用于其他进程使用,找到对应属性的handle。
*
*/
int
SystemFindParameter
(
const
char
*
name
,
ParamHandle
*
handle
);
/**
* 对外接口
* 根据handle获取对应数据的修改标识。
* commitId 获取计数变化
*
*/
int
SystemGetParameterCommitId
(
ParamHandle
handle
,
uint32_t
*
commitId
);
/**
* 外部接口
* 获取参数值。
*
*/
int
SystemGetParameterValue
(
ParamHandle
handle
,
char
*
value
,
unsigned
int
*
len
);
long
long
GetSystemCommitId
(
void
);
#ifdef __cplusplus
#if __cplusplus
}
...
...
services/modules/reboot/reboot.c
浏览文件 @
bf433961
...
...
@@ -12,7 +12,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <unistd.h>
#include <linux/reboot.h>
#include <sys/reboot.h>
#include <sys/syscall.h>
#include "reboot_adp.h"
#include "init_cmdexecutor.h"
...
...
@@ -103,11 +107,23 @@ static int DoRebootSuspend(int id, const char *name, int argc, const char **argv
return
DoRoot_
(
"suspend"
,
RB_AUTOBOOT
);
}
static
int
DoRebootOther
(
int
id
,
const
char
*
name
,
int
argc
,
const
char
**
argv
)
{
UNUSED
(
id
);
UNUSED
(
name
);
PLUGIN_CHECK
(
argc
>=
1
,
return
-
1
,
"Invalid parameter argc %d"
,
argc
);
const
char
*
cmd
=
strstr
(
argv
[
0
],
"reboot,"
);
PLUGIN_CHECK
(
cmd
!=
NULL
,
return
-
1
,
"Invalid parameter argc %s"
,
argv
[
0
]);
PLUGIN_LOGI
(
"DoRebootOther argv %s"
,
argv
[
0
]);
return
syscall
(
__NR_reboot
,
LINUX_REBOOT_MAGIC1
,
LINUX_REBOOT_MAGIC2
,
LINUX_REBOOT_CMD_RESTART2
,
cmd
+
strlen
(
"reboot,"
));
}
static
void
RebootAdpInit
(
void
)
{
// sample {"reboot,shutdown", "reboot.shutdown", "reboot.shutdown"},
// add default reboot cmd
(
void
)
AddCmdExecutor
(
"reboot"
,
DoReboot
);
(
void
)
AddCmdExecutor
(
"reboot.other"
,
DoRebootOther
);
AddRebootCmdExecutor
(
"shutdown"
,
DoRebootShutdown
);
AddRebootCmdExecutor
(
"flashd"
,
DoRebootFlashed
);
AddRebootCmdExecutor
(
"updater"
,
DoRebootUpdater
);
...
...
services/param/base/param_base.c
浏览文件 @
bf433961
...
...
@@ -293,3 +293,40 @@ INIT_LOCAL_API int AddWorkSpace(const char *name, int onlyRead, uint32_t spaceSi
PARAM_LOGV
(
"AddWorkSpace %s %s"
,
name
,
ret
==
0
?
"success"
:
"fail"
);
return
ret
;
}
int
SystemFindParameter
(
const
char
*
name
,
ParamHandle
*
handle
)
{
PARAM_CHECK
(
name
!=
NULL
&&
handle
!=
NULL
,
return
-
1
,
"The name or handle is null"
);
int
ret
=
ReadParamWithCheck
(
name
,
DAC_READ
,
handle
);
if
(
ret
!=
PARAM_CODE_NOT_FOUND
&&
ret
!=
0
&&
ret
!=
PARAM_CODE_NODE_EXIST
)
{
PARAM_CHECK
(
ret
==
0
,
return
ret
,
"Forbid to access parameter %s"
,
name
);
}
return
ret
;
}
int
SystemGetParameterCommitId
(
ParamHandle
handle
,
uint32_t
*
commitId
)
{
PARAM_CHECK
(
handle
!=
0
&&
commitId
!=
NULL
,
return
-
1
,
"The handle is null"
);
ParamNode
*
entry
=
(
ParamNode
*
)
GetTrieNodeByHandle
(
handle
);
if
(
entry
==
NULL
)
{
return
PARAM_CODE_NOT_FOUND
;
}
*
commitId
=
ReadCommitId
(
entry
);
return
0
;
}
long
long
GetSystemCommitId
(
void
)
{
WorkSpace
*
space
=
GetWorkSpace
(
WORKSPACE_NAME_DAC
);
if
(
space
==
NULL
||
space
->
area
==
NULL
)
{
return
0
;
}
return
ATOMIC_LOAD_EXPLICIT
(
&
space
->
area
->
commitId
,
memory_order_acquire
);
}
int
SystemGetParameterValue
(
ParamHandle
handle
,
char
*
value
,
unsigned
int
*
len
)
{
PARAM_CHECK
(
len
!=
NULL
&&
handle
!=
0
,
return
-
1
,
"The value is null"
);
return
ReadParamValue
(
handle
,
value
,
len
);
}
\ No newline at end of file
services/param/linux/param_request.c
浏览文件 @
bf433961
...
...
@@ -246,16 +246,6 @@ int SystemCheckParamExist(const char *name)
return
SysCheckParamExist
(
name
);
}
int
SystemFindParameter
(
const
char
*
name
,
ParamHandle
*
handle
)
{
PARAM_CHECK
(
name
!=
NULL
&&
handle
!=
NULL
,
return
-
1
,
"The name or handle is null"
);
int
ret
=
ReadParamWithCheck
(
name
,
DAC_READ
,
handle
);
if
(
ret
!=
PARAM_CODE_NOT_FOUND
&&
ret
!=
0
&&
ret
!=
PARAM_CODE_NODE_EXIST
)
{
PARAM_CHECK
(
ret
==
0
,
return
ret
,
"Forbid to access parameter %s"
,
name
);
}
return
ret
;
}
int
WatchParamCheck
(
const
char
*
keyprefix
)
{
PARAM_CHECK
(
keyprefix
!=
NULL
,
return
PARAM_CODE_INVALID_PARAM
,
"Invalid keyprefix"
);
...
...
services/param/liteos/param_client.c
浏览文件 @
bf433961
...
...
@@ -124,13 +124,3 @@ int SystemCheckParamExist(const char *name)
{
return
SysCheckParamExist
(
name
);
}
int
SystemFindParameter
(
const
char
*
name
,
ParamHandle
*
handle
)
{
PARAM_CHECK
(
name
!=
NULL
&&
handle
!=
NULL
,
return
-
1
,
"The name or handle is null"
);
int
ret
=
ReadParamWithCheck
(
name
,
DAC_READ
,
handle
);
if
(
ret
!=
PARAM_CODE_NOT_FOUND
&&
ret
!=
0
&&
ret
!=
PARAM_CODE_NODE_EXIST
)
{
PARAM_CHECK
(
ret
==
0
,
return
ret
,
"Forbid to access parameter %s"
,
name
);
}
return
ret
;
}
services/param/manager/param_manager.c
浏览文件 @
bf433961
...
...
@@ -299,7 +299,7 @@ static int GetServiceCtrlInfoForPowerCtrl(const char *name, const char *value, S
}
// not found reboot, so reboot by normal
valueOffset
=
strlen
(
OHOS_SERVICE_CTRL_PREFIX
)
+
strlen
(
"reboot"
)
+
1
;
return
CreateCtrlInfo
(
ctrlInfo
,
"reboot"
,
valueOffset
,
1
,
"%s%s.%s"
,
OHOS_SERVICE_CTRL_PREFIX
,
"reboot"
,
value
);
return
CreateCtrlInfo
(
ctrlInfo
,
"reboot
.other
"
,
valueOffset
,
1
,
"%s%s.%s"
,
OHOS_SERVICE_CTRL_PREFIX
,
"reboot"
,
value
);
}
INIT_LOCAL_API
int
GetServiceCtrlInfo
(
const
char
*
name
,
const
char
*
value
,
ServiceCtrlInfo
**
ctrlInfo
)
...
...
@@ -376,35 +376,8 @@ INIT_LOCAL_API int CheckParameterSet(const char *name,
return
ret
;
}
int
SystemGetParameterCommitId
(
ParamHandle
handle
,
uint32_t
*
commitId
)
{
PARAM_CHECK
(
handle
!=
0
&&
commitId
!=
NULL
,
return
-
1
,
"The handle is null"
);
ParamNode
*
entry
=
(
ParamNode
*
)
GetTrieNodeByHandle
(
handle
);
if
(
entry
==
NULL
)
{
return
PARAM_CODE_NOT_FOUND
;
}
*
commitId
=
ReadCommitId
(
entry
);
return
0
;
}
long
long
GetSystemCommitId
(
void
)
{
WorkSpace
*
space
=
GetWorkSpace
(
WORKSPACE_NAME_DAC
);
if
(
space
==
NULL
||
space
->
area
==
NULL
)
{
return
0
;
}
return
ATOMIC_LOAD_EXPLICIT
(
&
space
->
area
->
commitId
,
memory_order_acquire
);
}
int
SystemGetParameterName
(
ParamHandle
handle
,
char
*
name
,
unsigned
int
len
)
{
PARAM_CHECK
(
name
!=
NULL
&&
handle
!=
0
,
return
-
1
,
"The name is null"
);
return
ReadParamName
(
handle
,
name
,
len
);
}
int
SystemGetParameterValue
(
ParamHandle
handle
,
char
*
value
,
unsigned
int
*
len
)
{
PARAM_CHECK
(
len
!=
NULL
&&
handle
!=
0
,
return
-
1
,
"The value is null"
);
return
ReadParamValue
(
handle
,
value
,
len
);
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录