Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
866c68f3
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看板
提交
866c68f3
编写于
7月 20, 2022
作者:
M
Mupceet
提交者:
Gitee
7月 20, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of gitee.com:openharmony/startup_init_lite into init
Signed-off-by:
N
Mupceet
<
laiguizhong@huawei.com
>
上级
d7dcfe2b
b29beea1
变更
61
隐藏空白更改
内联
并排
Showing
61 changed file
with
564 addition
and
280 deletion
+564
-280
bundle.json
bundle.json
+13
-4
initsync/BUILD.gn
initsync/BUILD.gn
+0
-2
interfaces/innerkits/BUILD.gn
interfaces/innerkits/BUILD.gn
+7
-4
interfaces/innerkits/control_fd/control_fd_client.c
interfaces/innerkits/control_fd/control_fd_client.c
+0
-8
interfaces/innerkits/control_fd/control_fd_service.c
interfaces/innerkits/control_fd/control_fd_service.c
+1
-1
interfaces/innerkits/fs_manager/fstab_mount.c
interfaces/innerkits/fs_manager/fstab_mount.c
+0
-1
interfaces/innerkits/modulemgr/modulemgr.c
interfaces/innerkits/modulemgr/modulemgr.c
+0
-2
interfaces/innerkits/syspara/param_comm.c
interfaces/innerkits/syspara/param_comm.c
+0
-40
interfaces/innerkits/syspara/param_comm.h
interfaces/innerkits/syspara/param_comm.h
+0
-5
interfaces/innerkits/syspara/param_wrapper.cpp
interfaces/innerkits/syspara/param_wrapper.cpp
+1
-0
interfaces/innerkits/syspara/parameter.c
interfaces/innerkits/syspara/parameter.c
+1
-1
interfaces/innerkits/token/BUILD.gn
interfaces/innerkits/token/BUILD.gn
+0
-1
services/etc/group
services/etc/group
+2
-1
services/etc/init.cfg
services/etc/init.cfg
+1
-2
services/etc/init.usb.cfg
services/etc/init.usb.cfg
+2
-0
services/etc/init.without_two_stages.cfg
services/etc/init.without_two_stages.cfg
+0
-1
services/etc/param/ohos.para
services/etc/param/ohos.para
+1
-1
services/etc/param/ohos.para.dac
services/etc/param/ohos.para.dac
+2
-0
services/etc/passwd
services/etc/passwd
+2
-1
services/include/init_utils.h
services/include/init_utils.h
+7
-0
services/init/lite/BUILD.gn
services/init/lite/BUILD.gn
+0
-1
services/init/standard/fd_holder_service.c
services/init/standard/fd_holder_service.c
+3
-1
services/log/BUILD.gn
services/log/BUILD.gn
+3
-0
services/log/init_log.c
services/log/init_log.c
+4
-0
services/loopevent/task/le_asynctask.c
services/loopevent/task/le_asynctask.c
+17
-4
services/param/adapter/param_dac.c
services/param/adapter/param_dac.c
+31
-8
services/param/adapter/param_persistadp.c
services/param/adapter/param_persistadp.c
+2
-2
services/param/adapter/param_selinux.c
services/param/adapter/param_selinux.c
+4
-1
services/param/base/param_base.c
services/param/base/param_base.c
+3
-3
services/param/base/param_comm.c
services/param/base/param_comm.c
+66
-13
services/param/base/param_trie.c
services/param/base/param_trie.c
+16
-17
services/param/include/param_manager.h
services/param/include/param_manager.h
+2
-1
services/param/include/param_osadp.h
services/param/include/param_osadp.h
+1
-1
services/param/include/param_persist.h
services/param/include/param_persist.h
+3
-1
services/param/include/param_security.h
services/param/include/param_security.h
+2
-1
services/param/include/param_trie.h
services/param/include/param_trie.h
+14
-4
services/param/include/param_utils.h
services/param/include/param_utils.h
+3
-2
services/param/linux/BUILD.gn
services/param/linux/BUILD.gn
+5
-1
services/param/linux/param_message.c
services/param/linux/param_message.c
+0
-4
services/param/linux/param_osadp.c
services/param/linux/param_osadp.c
+1
-1
services/param/liteos/BUILD.gn
services/param/liteos/BUILD.gn
+11
-6
services/param/liteos/param_client.c
services/param/liteos/param_client.c
+6
-25
services/param/liteos/param_hal.c
services/param/liteos/param_hal.c
+100
-21
services/param/liteos/param_osadp.c
services/param/liteos/param_osadp.c
+2
-4
services/param/liteos/param_service.c
services/param/liteos/param_service.c
+93
-2
services/param/manager/param_manager.c
services/param/manager/param_manager.c
+1
-1
services/param/manager/param_persist.c
services/param/manager/param_persist.c
+25
-15
services/param/manager/param_server.c
services/param/manager/param_server.c
+19
-8
services/utils/BUILD.gn
services/utils/BUILD.gn
+4
-1
services/utils/init_utils.c
services/utils/init_utils.c
+48
-0
test/exec_test/fd_holder_test.cfg
test/exec_test/fd_holder_test.cfg
+1
-1
test/moduletest/param_test_cmds.c
test/moduletest/param_test_cmds.c
+0
-5
test/unittest/lite/BUILD.gn
test/unittest/lite/BUILD.gn
+2
-4
test/unittest/param/client_unittest.cpp
test/unittest/param/client_unittest.cpp
+2
-1
test/unittest/param/watcher_agent_unittest.cpp
test/unittest/param/watcher_agent_unittest.cpp
+2
-2
test/unittest/syspara/syspara_unittest.cpp
test/unittest/syspara/syspara_unittest.cpp
+1
-0
test/unittest/tools/prepare_testdata.sh
test/unittest/tools/prepare_testdata.sh
+27
-32
ueventd/standard/ueventd_parameter.c
ueventd/standard/ueventd_parameter.c
+0
-2
ueventd/ueventd.c
ueventd/ueventd.c
+0
-1
ueventd/ueventd_device_handler.c
ueventd/ueventd_device_handler.c
+0
-1
ueventd/ueventd_socket.c
ueventd/ueventd_socket.c
+0
-7
未找到文件。
bundle.json
浏览文件 @
866c68f3
...
...
@@ -21,12 +21,21 @@
"ram"
:
""
,
"deps"
:
{
"components"
:
[
"selinux"
,
"ipc"
,
"startup"
,
"safwk"
,
"samgr_standard"
,
"utils_base"
,
"profiler"
"napi"
,
"ipc"
,
"config_policy"
,
"hilog_native"
,
"thirdparty_bounds_checking_function"
,
"samgr_standard"
,
"hiviewdfx_hilog_native"
,
"selinux"
,
"hiviewdfx"
,
"access_token"
,
"common"
,
"dsoftbus"
],
"third_party"
:
[
"cJSON"
,
...
...
initsync/BUILD.gn
浏览文件 @
866c68f3
...
...
@@ -19,7 +19,6 @@ lite_component("initsync") {
shared_library("libinitsync_shared") {
sources = [ "src/init_sync.c" ]
cflags = [ "-Wall" ]
include_dirs = [
"//base/startup/init/initsync/include",
"//base/startup/init/interfaces/kits/syscap",
...
...
@@ -34,7 +33,6 @@ shared_library("libinitsync_shared") {
static_library("libinitsync_static") {
sources = [ "src/init_sync.c" ]
cflags = [ "-Wall" ]
include_dirs = [
"//base/startup/init/initsync/include",
"//base/startup/init/interfaces/kits/syscap",
...
...
interfaces/innerkits/BUILD.gn
浏览文件 @
866c68f3
...
...
@@ -120,10 +120,13 @@ if (defined(ohos_lite)) {
deps += [ "//third_party/mbedtls:mbedtls" ]
defines += [ "USE_MBEDTLS" ]
}
deps += [
"//base/startup/init/services/param/liteos:param_client_lite",
"//base/startup/init/services/utils:libinit_utils",
]
if (enable_ohos_startup_init_feature_begetctl_liteos) {
deps += [
"//base/startup/init/services/log:init_log",
"//base/startup/init/services/param/liteos:param_client_lite",
"//base/startup/init/services/utils:libinit_utils",
]
}
}
}
...
...
interfaces/innerkits/control_fd/control_fd_client.c
浏览文件 @
866c68f3
...
...
@@ -14,21 +14,13 @@
*/
#include <errno.h>
#include <fcntl.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/select.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <termios.h>
#include <time.h>
#include <unistd.h>
#include <limits.h>
#include "beget_ext.h"
#include "control_fd.h"
#include "init_utils.h"
#include "securec.h"
static
void
ProcessPtyWrite
(
const
WatcherHandle
taskHandle
,
int
fd
,
uint32_t
*
events
,
const
void
*
context
)
...
...
interfaces/innerkits/control_fd/control_fd_service.c
浏览文件 @
866c68f3
...
...
@@ -61,7 +61,7 @@ static void CmdOnRecvMessage(const TaskHandle task, const uint8_t *buffer, uint3
BEGET_ERROR_CHECK
(
strl
!=
NULL
,
return
,
"pty slave path %s is invaild"
,
realPath
);
int
fd
=
open
(
realPath
,
O_RDWR
);
free
(
realPath
);
BEGET_ERROR_CHECK
(
fd
>=
0
,
return
,
"Failed open %s, err=%d"
,
realPath
,
errno
);
BEGET_ERROR_CHECK
(
fd
>=
0
,
return
,
"Failed open %s, err=%d"
,
msg
->
ptyName
,
errno
);
(
void
)
dup2
(
fd
,
STDIN_FILENO
);
(
void
)
dup2
(
fd
,
STDOUT_FILENO
);
(
void
)
dup2
(
fd
,
STDERR_FILENO
);
// Redirect fd to 0, 1, 2
...
...
interfaces/innerkits/fs_manager/fstab_mount.c
浏览文件 @
866c68f3
...
...
@@ -17,7 +17,6 @@
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <sys/ioctl.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/wait.h>
...
...
interfaces/innerkits/modulemgr/modulemgr.c
浏览文件 @
866c68f3
...
...
@@ -17,8 +17,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <sys/types.h>
#include <dirent.h>
#include <linux/limits.h>
...
...
interfaces/innerkits/syspara/param_comm.c
浏览文件 @
866c68f3
...
...
@@ -84,46 +84,6 @@ INIT_LOCAL_API const char *GetProperty(const char *key, const char **paramHolder
return
*
paramHolder
;
}
INIT_LOCAL_API
int
StringToLL
(
const
char
*
str
,
long
long
int
*
out
)
{
const
char
*
s
=
str
;
while
(
isspace
(
*
s
))
{
s
++
;
}
size_t
len
=
strlen
(
str
);
int
positiveHex
=
(
len
>
1
&&
s
[
0
]
==
'0'
&&
(
s
[
1
]
==
'x'
||
s
[
1
]
==
'X'
));
int
negativeHex
=
(
len
>
2
&&
s
[
0
]
==
'-'
&&
s
[
1
]
==
'0'
&&
(
s
[
2
]
==
'x'
||
s
[
2
]
==
'X'
));
// 2: shorttest
int
base
=
(
positiveHex
||
negativeHex
)
?
HEX
:
DECIMAL
;
char
*
end
=
NULL
;
errno
=
0
;
*
out
=
strtoll
(
s
,
&
end
,
base
);
if
(
errno
!=
0
)
{
return
-
1
;
}
BEGET_CHECK
(
!
(
s
==
end
||
*
end
!=
'\0'
),
return
-
1
);
return
0
;
}
INIT_LOCAL_API
int
StringToULL
(
const
char
*
str
,
unsigned
long
long
int
*
out
)
{
const
char
*
s
=
str
;
while
(
isspace
(
*
s
))
{
s
++
;
}
BEGET_CHECK
(
s
[
0
]
!=
'-'
,
return
-
1
);
int
base
=
(
s
[
0
]
==
'0'
&&
(
s
[
1
]
==
'x'
||
s
[
1
]
==
'X'
))
?
HEX
:
DECIMAL
;
char
*
end
=
NULL
;
errno
=
0
;
*
out
=
strtoull
(
s
,
&
end
,
base
);
if
(
errno
!=
0
)
{
return
-
1
;
}
BEGET_CHECK
(
end
!=
s
,
return
-
1
);
BEGET_CHECK
(
*
end
==
'\0'
,
return
-
1
);
return
0
;
}
INIT_LOCAL_API
const
char
*
GetProductModel_
(
void
)
{
static
const
char
*
productModel
=
NULL
;
...
...
interfaces/innerkits/syspara/param_comm.h
浏览文件 @
866c68f3
...
...
@@ -29,13 +29,8 @@ extern "C" {
#define HASH_LENGTH 32
#define DEV_BUF_LENGTH 3
#define DEV_BUF_MAX_LENGTH 1024
#define DECIMAL 10
#define HEX 16
INIT_LOCAL_API
const
char
*
GetProperty
(
const
char
*
key
,
const
char
**
paramHolder
);
INIT_LOCAL_API
int
StringToULL
(
const
char
*
str
,
unsigned
long
long
int
*
out
);
INIT_LOCAL_API
int
StringToLL
(
const
char
*
str
,
long
long
int
*
out
);
INIT_LOCAL_API
int
GetParameter_
(
const
char
*
key
,
const
char
*
def
,
char
*
value
,
uint32_t
len
);
INIT_LOCAL_API
const
char
*
GetProductModel_
(
void
);
...
...
interfaces/innerkits/syspara/param_wrapper.cpp
浏览文件 @
866c68f3
...
...
@@ -22,6 +22,7 @@
#include "beget_ext.h"
#include "param_comm.h"
#include "init_param.h"
#include "init_utils.h"
#include "sysparam_errno.h"
#include "securec.h"
#include "parameter.h"
...
...
interfaces/innerkits/syspara/parameter.c
浏览文件 @
866c68f3
...
...
@@ -20,9 +20,9 @@
#include "param_comm.h"
#include "init_param.h"
#include "init_utils.h"
#include "sysparam_errno.h"
#include "securec.h"
#include "sysversion.h"
#include "beget_ext.h"
int
WaitParameter
(
const
char
*
key
,
const
char
*
value
,
int
timeout
)
...
...
interfaces/innerkits/token/BUILD.gn
浏览文件 @
866c68f3
...
...
@@ -18,7 +18,6 @@ import("//build/lite/ndk/ndk.gni")
if (ohos_kernel_type == "liteos_a" || ohos_kernel_type == "linux") {
shared_library("token_shared") {
cflags = [ "-Wall" ]
include_dirs = [
"//base/startup/init/interfaces/innerkits/include",
"//base/startup/init/interfaces/innerkits/include/token",
...
...
services/etc/group
浏览文件 @
866c68f3
...
...
@@ -75,7 +75,7 @@ dscreen:x:3054:
daudio:x:3055:
dhardware:x:3056:
installs:x:3060:
codec_service
:x:3061:
vendor_mpp_driver
:x:3061:
deviceauth:x:3333:
huks_server:x:3510:
dms:x:5522:
...
...
@@ -109,3 +109,4 @@ accessibility:x:1103:
motion_host:x:3065:
uhdf_driver:x:3066:
memmgr:x:1111:
ispserver:x:3821:
services/etc/init.cfg
浏览文件 @
866c68f3
...
...
@@ -68,7 +68,7 @@
"chmod 0660 /sys/power/state",
"mount pstore pstore /sys/fs/pstore nodev noexec nosuid",
"chown system log /sys/fs/pstore",
"chmod 055
0
/sys/fs/pstore",
"chmod 055
5
/sys/fs/pstore",
"ifup lo",
"hostname localhost",
"domainname localdomain"
...
...
@@ -152,7 +152,6 @@
"mkdir /data/nfc/param 0770 nfc nfc",
"mkdir /data/system 0775 system system",
"mkdir /data/system/dropbox 0700 system system",
"mkdir /data/system/users 0750 account account",
"mkdir /data/system_de 0770 system system",
"mkdir /data/system_ce 0770 system system",
"mkdir /data/misc_de 01771 system misc",
...
...
services/etc/init.usb.cfg
浏览文件 @
866c68f3
...
...
@@ -28,6 +28,8 @@
"uid" : "system",
"gid" : "system"
}],
"permission" : ["ohos.permission.DUMP"],
"permission_acls" : ["ohos.permission.DUMP"],
"sandbox" : 0,
"start-mode" : "condition",
"secon" : "u:r:hdcd:s0",
...
...
services/etc/init.without_two_stages.cfg
浏览文件 @
866c68f3
...
...
@@ -164,7 +164,6 @@
"mkdir /data/system 0775 system system",
"mkdir /data/system/dropbox 0700 system system",
"mkdir /data/system/heapdump 0700 system system",
"mkdir /data/system/users 0750 account account",
"mkdir /data/system_de 0770 system system",
"mkdir /data/system_ce 0770 system system",
"mkdir /data/misc_de 01771 system misc",
...
...
services/etc/param/ohos.para
浏览文件 @
866c68f3
...
...
@@ -30,7 +30,7 @@ const.build.product=default
const.product.hardwareversion=default
const.product.bootloader.version=bootloader
const.product.cpu.abilist=default
const.product.software.version=OpenHarmony 3.2.5.
2
const.product.software.version=OpenHarmony 3.2.5.
5
const.product.incremental.version=default
const.product.firstapiversion=1
const.product.build.type=default
...
...
services/etc/param/ohos.para.dac
浏览文件 @
866c68f3
...
...
@@ -31,3 +31,5 @@ persist.window.boot. = root:system:0775
debug.bytrace. = root:system:0775
persist.distributed_hardware.device_manager. = system:system:0775
bootevent. = samgr:samgr:0777
hw_sc. = root:root:0777
services/etc/passwd
浏览文件 @
866c68f3
...
...
@@ -72,7 +72,7 @@ dscreen:x:3054:3054:::/bin/false
daudio:x:3055:3055:::/bin/false
dhardware:x:3056:3056:::/bin/false
installs:x:3060:3060:::/bin/false
codec_service
:x:3061:3061:::/bin/false
vendor_mpp_driver
:x:3061:3061:::/bin/false
deviceauth:x:3333:3333:::/bin/false
huks_server:x:3510:3510:::/bin/false
dms:x:5522:5522:::/bin/false
...
...
@@ -106,3 +106,4 @@ deviceinfo:x:1102:1102:::/bin/false
accessibility:x:1103:1103:::/bin/false
motion_host:x:3065:3065:::/bin/false
memmgr:x:1111:1111:::/bin/false
ispserver:x:3821:3821:::/bin/false
services/include/init_utils.h
浏览文件 @
866c68f3
...
...
@@ -21,6 +21,8 @@
#include <stdbool.h>
#include <unistd.h>
#include "beget_ext.h"
#ifdef __cplusplus
#if __cplusplus
extern
"C"
{
...
...
@@ -32,6 +34,7 @@ typedef struct {
int
value
;
}
InitArgInfo
;
#define HEX_BASE 16
#define BINARY_BASE 2
#define OCTAL_BASE 8
#define DECIMAL_BASE 10
...
...
@@ -76,6 +79,10 @@ int GetMapValue(const char *name, const InitArgInfo *infos, int argNum, int defV
const
InitArgInfo
*
GetServieStatusMap
(
int
*
size
);
uint32_t
GetRandom
(
void
);
void
OpenConsole
(
void
);
INIT_LOCAL_API
int
StringToULL
(
const
char
*
str
,
unsigned
long
long
int
*
out
);
INIT_LOCAL_API
int
StringToLL
(
const
char
*
str
,
long
long
int
*
out
);
#ifdef __cplusplus
#if __cplusplus
}
...
...
services/init/lite/BUILD.gn
浏览文件 @
866c68f3
...
...
@@ -55,7 +55,6 @@ executable("init") {
"//base/hiviewdfx/hilog_lite/interfaces/native/kits",
]
cflags = [ "-Wall" ]
ldflags = []
deps = [
"//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
...
...
services/init/standard/fd_holder_service.c
浏览文件 @
866c68f3
...
...
@@ -215,14 +215,16 @@ static void HandlerFdHolder(int sock)
if
(
strcmp
(
action
,
ACTION_HOLD
)
==
0
)
{
INIT_LOGI
(
"Service
\'
%s
\'
request init to %s fds"
,
serviceName
,
action
);
if
(
HandlerHoldFds
(
service
,
fds
,
fdCount
,
pollStr
)
<
0
)
{
CloseFds
(
fds
,
fdCount
);
}
}
else
if
(
strcmp
(
action
,
ACTION_GET
)
==
0
)
{
// In this case, ignore fds, just close them if fd passed to init
CloseFds
(
fds
,
fdCount
);
HandlerGetFds
(
sock
,
service
);
}
else
{
INIT_LOGE
(
"Unexpected action: %s"
,
action
);
CloseFds
(
fds
,
fdCount
);
}
CloseFds
(
fds
,
fdCount
);
FreeFds
(
fds
);
FreeStringVector
(
msg
,
msgCount
);
}
...
...
services/log/BUILD.gn
浏览文件 @
866c68f3
...
...
@@ -33,6 +33,9 @@ if (defined(ohos_lite)) {
if (ohos_kernel_type == "linux") {
defines += [ "INIT_DMESG" ]
}
if (ohos_kernel_type == "liteos_m") {
defines += [ "__LITEOS_M__" ]
}
include_dirs = [
"//base/hiviewdfx/hilog_lite/interfaces/native/kits",
"//third_party/bounds_checking_function/include",
...
...
services/log/init_log.c
浏览文件 @
866c68f3
...
...
@@ -97,9 +97,13 @@ void LogToDmesg(InitLogLevel logLevel, const char *tag, const char *info)
static
void
PrintLog
(
InitLogLevel
logLevel
,
unsigned
int
domain
,
const
char
*
tag
,
const
char
*
logInfo
)
{
#ifdef OHOS_LITE
#ifdef __LITEOS_M__
printf
(
"[%s]%s
\n
"
,
tag
,
logInfo
);
#else
static
const
LogLevel
LOG_LEVEL
[]
=
{
LOG_DEBUG
,
LOG_INFO
,
LOG_WARN
,
LOG_ERROR
,
LOG_FATAL
};
(
void
)
HiLogPrint
(
INIT_LOG_INIT
,
LOG_LEVEL
[
logLevel
],
domain
,
tag
,
"%{public}s"
,
logInfo
);
#endif
#endif
#ifdef INIT_DMESG
LogToDmesg
(
logLevel
,
tag
,
logInfo
);
#endif
...
...
services/loopevent/task/le_asynctask.c
浏览文件 @
866c68f3
...
...
@@ -22,15 +22,28 @@
static
void
DoAsyncEvent_
(
const
LoopHandle
loopHandle
,
AsyncEventTask
*
asyncTask
)
{
LE_CHECK
(
loopHandle
!=
NULL
&&
asyncTask
!=
NULL
,
return
,
"Invalid parameters"
);
LE_Buffer
*
buffer
=
GetFirstBuffer
(
&
asyncTask
->
stream
);
while
(
buffer
!=
NULL
)
{
ListNode
tmpHdr
;
OH_ListInit
(
&
tmpHdr
);
StreamTask
*
task
=
&
asyncTask
->
stream
;
LoopMutexLock
(
&
task
->
mutex
);
tmpHdr
.
next
=
task
->
buffHead
.
next
;
tmpHdr
.
prev
=
task
->
buffHead
.
prev
;
task
->
buffHead
.
next
->
prev
=
&
tmpHdr
;
task
->
buffHead
.
prev
->
next
=
&
tmpHdr
;
OH_ListInit
(
&
task
->
buffHead
);
LoopMutexUnlock
(
&
task
->
mutex
);
ListNode
*
node
=
tmpHdr
.
next
;
while
(
node
!=
&
tmpHdr
)
{
LE_Buffer
*
buffer
=
ListEntry
(
node
,
LE_Buffer
,
node
);
uint64_t
eventId
=
*
(
uint64_t
*
)(
buffer
->
data
);
if
(
asyncTask
->
processAsyncEvent
)
{
asyncTask
->
processAsyncEvent
((
TaskHandle
)
asyncTask
,
eventId
,
(
uint8_t
*
)(
buffer
->
data
+
sizeof
(
uint64_t
)),
buffer
->
dataSize
);
}
FreeBuffer
(
loopHandle
,
&
asyncTask
->
stream
,
buffer
);
buffer
=
GetFirstBuffer
(
&
asyncTask
->
stream
);
OH_ListRemove
(
&
buffer
->
node
);
free
(
buffer
);
node
=
tmpHdr
.
next
;
}
}
#ifdef STARTUP_INIT_TEST
...
...
services/param/adapter/param_dac.c
浏览文件 @
866c68f3
...
...
@@ -16,12 +16,9 @@
#include <grp.h>
#include <pwd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <dirent.h>
#include <
fcntl
.h>
#include <
string
.h>
#include "init_utils.h"
#include "param_manager.h"
#include "param_security.h"
#include "param_trie.h"
...
...
@@ -64,6 +61,15 @@ static void GetGroupIdByName(gid_t *gid, const char *name, uint32_t nameLen)
// user:group:r|w
static
int
GetParamDacData
(
ParamDacData
*
dacData
,
const
char
*
value
)
{
static
const
struct
{
const
char
*
name
;
int
value
;
}
paramTypes
[]
=
{
{
"int"
,
PARAM_TYPE_INT
},
{
"string"
,
PARAM_TYPE_STRING
},
{
"bool"
,
PARAM_TYPE_BOOL
},
};
if
(
dacData
==
NULL
)
{
return
-
1
;
}
...
...
@@ -77,7 +83,19 @@ static int GetParamDacData(ParamDacData *dacData, const char *value)
}
GetUserIdByName
(
&
dacData
->
uid
,
value
,
groupName
-
value
);
GetGroupIdByName
(
&
dacData
->
gid
,
groupName
+
1
,
mode
-
groupName
-
1
);
dacData
->
mode
=
strtol
(
mode
+
1
,
NULL
,
OCT_BASE
);
dacData
->
paramType
=
PARAM_TYPE_STRING
;
char
*
type
=
strstr
(
mode
+
1
,
":"
);
if
(
type
!=
NULL
)
{
*
type
=
'\0'
;
type
++
;
for
(
size_t
i
=
0
;
(
type
!=
NULL
)
&&
(
i
<
ARRAY_LENGTH
(
paramTypes
));
i
++
)
{
if
(
strcmp
(
paramTypes
[
i
].
name
,
type
)
==
0
)
{
dacData
->
paramType
=
paramTypes
[
i
].
value
;
}
}
}
dacData
->
mode
=
(
uint16_t
)
strtol
(
mode
+
1
,
NULL
,
OCT_BASE
);
return
0
;
}
...
...
@@ -116,7 +134,7 @@ static int LoadParamLabels(const char *fileName)
char
*
buff
=
(
char
*
)
calloc
(
1
,
buffSize
);
while
(
fp
!=
NULL
&&
buff
!=
NULL
&&
fgets
(
buff
,
buffSize
,
fp
)
!=
NULL
)
{
buff
[
buffSize
-
1
]
=
'\0'
;
int
ret
=
Split
e
String
(
buff
,
NULL
,
0
,
LoadOneParam_
,
NULL
);
int
ret
=
Split
Param
String
(
buff
,
NULL
,
0
,
LoadOneParam_
,
NULL
);
if
(
ret
!=
0
)
{
PARAM_LOGE
(
"Failed to split string %s fileName %s"
,
buff
,
fileName
);
continue
;
...
...
@@ -237,8 +255,13 @@ static int DacCheckParamPermission(const ParamSecurityLabel *srcLabel, const cha
if
((
node
->
mode
&
localMode
)
!=
0
)
{
ret
=
DAC_RESULT_PERMISSION
;
}
PARAM_LOGV
(
"Param '%s' label gid:%d uid:%d mode 0%o"
,
name
,
srcLabel
->
cred
.
gid
,
srcLabel
->
cred
.
uid
,
localMode
);
PARAM_LOGV
(
"Cfg label %d gid:%d uid:%d mode 0%o result %d"
,
labelIndex
,
node
->
gid
,
node
->
uid
,
node
->
mode
,
ret
);
if
(
ret
!=
DAC_RESULT_PERMISSION
)
{
PARAM_LOGW
(
"Param '%s' label gid:%d uid:%d mode 0%o"
,
name
,
srcLabel
->
cred
.
gid
,
srcLabel
->
cred
.
uid
,
localMode
);
PARAM_LOGW
(
"Cfg label %d gid:%d uid:%d mode 0%o "
,
labelIndex
,
node
->
gid
,
node
->
uid
,
node
->
mode
);
#ifndef STARTUP_INIT_TEST
ret
=
DAC_RESULT_PERMISSION
;
#endif
}
return
ret
;
}
...
...
services/param/adapter/param_persistadp.c
浏览文件 @
866c68f3
...
...
@@ -56,7 +56,7 @@ static int LoadPersistParam()
uint32_t
paramNum
=
0
;
while
(
fgets
(
buffer
,
buffSize
,
fp
)
!=
NULL
)
{
buffer
[
buffSize
-
1
]
=
'\0'
;
int
ret
=
Split
e
String
(
buffer
,
NULL
,
0
,
LoadOnePersistParam_
,
NULL
);
int
ret
=
Split
Param
String
(
buffer
,
NULL
,
0
,
LoadOnePersistParam_
,
NULL
);
PARAM_CHECK
(
ret
==
0
,
continue
,
"Failed to set param %d %s"
,
ret
,
buffer
);
paramNum
++
;
}
...
...
@@ -125,7 +125,7 @@ static void BatchSavePersistParamEnd(PERSIST_SAVE_HANDLE handle)
int
RegisterPersistParamOps
(
PersistParamOps
*
ops
)
{
ParamMutexCeate
(
&
g_saveMutex
);
ParamMutexC
r
eate
(
&
g_saveMutex
);
PARAM_CHECK
(
ops
!=
NULL
,
return
-
1
,
"Invalid ops"
);
ops
->
save
=
SavePersistParam
;
ops
->
load
=
LoadPersistParam
;
...
...
services/param/adapter/param_selinux.c
浏览文件 @
866c68f3
...
...
@@ -193,7 +193,10 @@ static int SelinuxCheckParamPermission(const ParamSecurityLabel *srcLabel, const
#endif
}
if
(
ret
!=
0
)
{
PARAM_LOGI
(
"Selinux check name %s pid %d uid %d %d result %d"
,
name
,
uc
.
pid
,
uc
.
uid
,
uc
.
gid
,
ret
);
PARAM_LOGW
(
"Selinux check name %s pid %d uid %d %d result %d"
,
name
,
uc
.
pid
,
uc
.
uid
,
uc
.
gid
,
ret
);
ret
=
DAC_RESULT_FORBIDED
;
}
else
{
ret
=
DAC_RESULT_PERMISSION
;
}
return
ret
;
}
...
...
services/param/base/param_base.c
浏览文件 @
866c68f3
...
...
@@ -155,6 +155,7 @@ INIT_PUBLIC_API int InitParamWorkSpace(int onlyRead)
auditData
.
dacData
.
gid
=
DAC_DEFAULT_GROUP
;
// 2000 for shell
auditData
.
dacData
.
uid
=
DAC_DEFAULT_USER
;
// for root
auditData
.
dacData
.
mode
=
DAC_DEFAULT_MODE
;
// 0774 default mode
auditData
.
dacData
.
paramType
=
PARAM_TYPE_STRING
;
ret
=
AddSecurityLabel
(
&
auditData
);
PARAM_CHECK
(
ret
==
0
,
return
ret
,
"Failed to add default dac label"
);
}
else
{
...
...
@@ -299,12 +300,11 @@ INIT_INNER_API int CheckParamPermission(const ParamSecurityLabel *srcLabel, cons
continue
;
}
if
(
ops
->
securityCheckParamPermission
==
NULL
)
{
ret
=
DAC_RESULT_FORBIDED
;
continue
;
}
ret
=
ops
->
securityCheckParamPermission
(
srcLabel
,
name
,
mode
);
PARAM_LOGV
(
"CheckParamPermission %s %s ret %d"
,
ops
->
name
,
name
,
ret
);
if
(
ret
==
DAC_RESULT_PERMISSION
)
{
if
(
ret
==
DAC_RESULT_FORBIDED
)
{
PARAM_LOGW
(
"CheckParamPermission %s %s FORBID"
,
ops
->
name
,
name
);
break
;
}
}
...
...
services/param/base/param_comm.c
浏览文件 @
866c68f3
...
...
@@ -129,7 +129,53 @@ INIT_LOCAL_API int ReadParamWithCheck(const char *name, uint32_t op, ParamHandle
return
PARAM_CODE_NOT_FOUND
;
}
INIT_LOCAL_API
int
CheckParamValue
(
const
ParamTrieNode
*
node
,
const
char
*
name
,
const
char
*
value
)
INIT_LOCAL_API
uint8_t
GetParamValueType
(
const
char
*
name
)
{
uint32_t
labelIndex
=
0
;
WorkSpace
*
space
=
GetWorkSpace
(
WORKSPACE_NAME_DAC
);
if
(
space
==
NULL
)
{
return
PARAM_TYPE_STRING
;
}
(
void
)
FindTrieNode
(
space
,
name
,
strlen
(
name
),
&
labelIndex
);
ParamSecurityNode
*
securityNode
=
(
ParamSecurityNode
*
)
GetTrieNode
(
space
,
labelIndex
);
if
(
securityNode
==
NULL
)
{
return
PARAM_TYPE_STRING
;
}
return
securityNode
->
type
;
}
static
int
CheckParamValueType
(
const
char
*
name
,
const
char
*
value
,
uint8_t
paramType
)
{
if
(
paramType
==
PARAM_TYPE_INT
)
{
long
long
int
temp1
=
0
;
if
(
strlen
(
value
)
>
1
&&
value
[
0
]
==
'-'
&&
StringToLL
(
value
,
&
temp1
)
!=
0
)
{
PARAM_LOGE
(
"Illegal param value %s for int"
,
value
);
return
PARAM_CODE_INVALID_VALUE
;
}
unsigned
long
long
int
temp2
=
0
;
if
(
StringToULL
(
value
,
&
temp2
)
!=
0
)
{
PARAM_LOGE
(
"Illegal param value %s for int"
,
value
);
return
PARAM_CODE_INVALID_VALUE
;
}
}
else
if
(
paramType
==
PARAM_TYPE_BOOL
)
{
static
const
char
*
validValue
[]
=
{
"1"
,
"0"
,
"true"
,
"false"
,
"y"
,
"yes"
,
"on"
,
"off"
,
"n"
,
"no"
};
size_t
i
=
0
;
for
(;
i
<
ARRAY_LENGTH
(
validValue
);
i
++
)
{
if
(
strcasecmp
(
validValue
[
i
],
value
)
==
0
)
{
break
;
}
}
if
(
i
>=
ARRAY_LENGTH
(
validValue
))
{
PARAM_LOGE
(
"Illegal param value %s for bool"
,
value
);
return
PARAM_CODE_INVALID_VALUE
;
}
}
return
0
;
}
INIT_LOCAL_API
int
CheckParamValue
(
const
ParamTrieNode
*
node
,
const
char
*
name
,
const
char
*
value
,
uint8_t
paramType
)
{
if
(
IS_READY_ONLY
(
name
))
{
PARAM_CHECK
(
strlen
(
value
)
<
PARAM_CONST_VALUE_LEN_MAX
,
...
...
@@ -139,10 +185,10 @@ INIT_LOCAL_API int CheckParamValue(const ParamTrieNode *node, const char *name,
return
PARAM_CODE_READ_ONLY
;
}
}
else
{
PARAM_CHECK
(
strlen
(
value
)
<
PARAM_VALUE_LEN_MAX
,
return
PARAM_CODE_INVALID_VALUE
,
"Illegal param value %s"
,
value
);
PARAM_CHECK
(
strlen
(
value
)
<
GetParamMaxLen
(
paramType
)
,
return
PARAM_CODE_INVALID_VALUE
,
"Illegal param value %s
length
"
,
value
);
}
return
0
;
return
CheckParamValueType
(
name
,
value
,
paramType
)
;
}
INIT_LOCAL_API
int
CheckParamName
(
const
char
*
name
,
int
info
)
...
...
@@ -181,13 +227,13 @@ INIT_LOCAL_API int CheckParamName(const char *name, int info)
return
0
;
}
static
int
AddParam
(
WorkSpace
*
workSpace
,
const
char
*
name
,
const
char
*
value
,
uint32_t
*
dataIndex
)
static
int
AddParam
(
WorkSpace
*
workSpace
,
uint8_t
type
,
const
char
*
name
,
const
char
*
value
,
uint32_t
*
dataIndex
)
{
ParamTrieNode
*
node
=
AddTrieNode
(
workSpace
,
name
,
strlen
(
name
));
PARAM_CHECK
(
node
!=
NULL
,
return
PARAM_CODE_REACHED_MAX
,
"Failed to add node"
);
ParamNode
*
entry
=
(
ParamNode
*
)
GetTrieNode
(
workSpace
,
node
->
dataIndex
);
if
(
entry
==
NULL
)
{
uint32_t
offset
=
AddParamNode
(
workSpace
,
name
,
strlen
(
name
),
value
,
strlen
(
value
));
uint32_t
offset
=
AddParamNode
(
workSpace
,
type
,
name
,
strlen
(
name
),
value
,
strlen
(
value
));
PARAM_CHECK
(
offset
>
0
,
return
PARAM_CODE_REACHED_MAX
,
"Failed to allocate name %s"
,
name
);
SaveIndex
(
&
node
->
dataIndex
,
offset
);
long
long
globalCommitId
=
ATOMIC_LOAD_EXPLICIT
(
&
workSpace
->
area
->
commitId
,
memory_order_relaxed
);
...
...
@@ -255,16 +301,21 @@ INIT_LOCAL_API int WriteParam(const char *name, const char *value, uint32_t *dat
if
((
mode
&
LOAD_PARAM_ONLY_ADD
)
==
LOAD_PARAM_ONLY_ADD
)
{
return
PARAM_CODE_READ_ONLY
;
}
ret
=
CheckParamValue
(
node
,
name
,
value
);
ParamNode
*
entry
=
(
ParamNode
*
)
GetTrieNode
(
workSpace
,
node
->
dataIndex
);
PARAM_CHECK
(
entry
!=
NULL
,
return
PARAM_CODE_REACHED_MAX
,
"Failed to update param value %s %u"
,
name
,
node
->
dataIndex
);
// use save type to check value
ret
=
CheckParamValue
(
node
,
name
,
value
,
entry
->
type
);
PARAM_CHECK
(
ret
==
0
,
return
ret
,
"Invalid param value param: %s=%s"
,
name
,
value
);
PARAMSPACE_AREA_RW_LOCK
(
workSpace
);
ret
=
UpdateParam
(
workSpace
,
&
node
->
dataIndex
,
name
,
value
);
PARAMSPACE_AREA_RW_UNLOCK
(
workSpace
);
}
else
{
ret
=
CheckParamValue
(
node
,
name
,
value
);
uint8_t
type
=
GetParamValueType
(
name
);
ret
=
CheckParamValue
(
node
,
name
,
value
,
type
);
PARAM_CHECK
(
ret
==
0
,
return
ret
,
"Invalid param value param: %s=%s"
,
name
,
value
);
PARAMSPACE_AREA_RW_LOCK
(
workSpace
);
ret
=
AddParam
((
WorkSpace
*
)
workSpace
,
name
,
value
,
dataIndex
);
ret
=
AddParam
((
WorkSpace
*
)
workSpace
,
type
,
name
,
value
,
dataIndex
);
PARAMSPACE_AREA_RW_UNLOCK
(
workSpace
);
}
return
ret
;
...
...
@@ -288,7 +339,7 @@ INIT_LOCAL_API int AddSecurityLabel(const ParamAuditData *auditData)
PARAM_CHECK
(
node
!=
NULL
,
return
PARAM_CODE_REACHED_MAX
,
"Failed to add node %s"
,
auditData
->
name
);
uint32_t
offset
=
node
->
labelIndex
;
if
(
node
->
labelIndex
==
0
)
{
// can not support update for label
offset
=
AddParamSec
ru
ityNode
(
workSpace
,
auditData
);
offset
=
AddParamSec
ur
ityNode
(
workSpace
,
auditData
);
PARAM_CHECK
(
offset
!=
0
,
return
PARAM_CODE_REACHED_MAX
,
"Failed to add label"
);
SaveIndex
(
&
node
->
labelIndex
,
offset
);
}
else
{
...
...
@@ -297,11 +348,13 @@ INIT_LOCAL_API int AddSecurityLabel(const ParamAuditData *auditData)
label
->
mode
=
auditData
->
dacData
.
mode
;
label
->
uid
=
auditData
->
dacData
.
uid
;
label
->
gid
=
auditData
->
dacData
.
gid
;
label
->
type
=
auditData
->
dacData
.
paramType
&
PARAM_TYPE_MASK
;
#endif
PARAM_LOGE
(
"Error, repeat to add label for name %s"
,
auditData
->
name
);
}
PARAM_LOGV
(
"AddSecurityLabel label %d gid %d uid %d mode %o name: %s"
,
offset
,
auditData
->
dacData
.
gid
,
auditData
->
dacData
.
uid
,
auditData
->
dacData
.
mode
,
auditData
->
name
);
PARAM_LOGV
(
"AddSecurityLabel label %d gid %d uid %d mode %o type:%d name: %s"
,
offset
,
auditData
->
dacData
.
gid
,
auditData
->
dacData
.
uid
,
auditData
->
dacData
.
mode
,
auditData
->
dacData
.
paramType
,
auditData
->
name
);
return
0
;
}
...
...
@@ -320,7 +373,7 @@ INIT_LOCAL_API ParamSecurityLabel *GetParamSecurityLabel()
return
&
paramSpace
->
securityLabel
;
}
int
Split
e
String
(
char
*
line
,
const
char
*
exclude
[],
uint32_t
count
,
int
Split
Param
String
(
char
*
line
,
const
char
*
exclude
[],
uint32_t
count
,
int
(
*
result
)(
const
uint32_t
*
context
,
const
char
*
name
,
const
char
*
value
),
const
uint32_t
*
context
)
{
// Skip spaces
...
...
services/param/base/param_trie.c
浏览文件 @
866c68f3
...
...
@@ -323,16 +323,11 @@ INIT_LOCAL_API int TraversalTrieNode(const WorkSpace *workSpace,
return
0
;
}
INIT_LOCAL_API
uint32_t
AddParamSec
ru
ityNode
(
WorkSpace
*
workSpace
,
const
ParamAuditData
*
auditData
)
INIT_LOCAL_API
uint32_t
AddParamSec
ur
ityNode
(
WorkSpace
*
workSpace
,
const
ParamAuditData
*
auditData
)
{
PARAM_CHECK
(
workSpace
!=
NULL
&&
workSpace
->
area
!=
NULL
,
return
0
,
"Invalid param"
);
PARAM_CHECK
(
auditData
!=
NULL
&&
auditData
->
name
!=
NULL
,
return
0
,
"Invalid auditData"
);
#ifdef PARAM_SUPPORT_SELINUX
const
uint32_t
labelLen
=
strlen
(
auditData
->
label
);
uint32_t
realLen
=
sizeof
(
ParamSecurityNode
)
+
PARAM_ALIGN
(
labelLen
+
1
);
#else
uint32_t
realLen
=
sizeof
(
ParamSecurityNode
);
#endif
PARAM_CHECK
((
workSpace
->
area
->
currOffset
+
realLen
)
<
workSpace
->
area
->
dataSize
,
return
0
,
"Failed to allocate currOffset %u, dataSize %u datalen %u"
,
workSpace
->
area
->
currOffset
,
workSpace
->
area
->
dataSize
,
realLen
);
...
...
@@ -340,22 +335,14 @@ INIT_LOCAL_API uint32_t AddParamSecruityNode(WorkSpace *workSpace, const ParamAu
node
->
uid
=
auditData
->
dacData
.
uid
;
node
->
gid
=
auditData
->
dacData
.
gid
;
node
->
mode
=
auditData
->
dacData
.
mode
;
node
->
length
=
0
;
#ifdef PARAM_SUPPORT_SELINUX
if
(
labelLen
!=
0
)
{
int
ret
=
ParamMemcpy
(
node
->
data
,
labelLen
,
auditData
->
label
,
labelLen
);
PARAM_CHECK
(
ret
==
0
,
return
0
,
"Failed to copy key"
);
node
->
data
[
labelLen
]
=
'\0'
;
node
->
length
=
labelLen
;
}
#endif
node
->
type
=
auditData
->
dacData
.
paramType
&
PARAM_TYPE_MASK
;
uint32_t
offset
=
workSpace
->
area
->
currOffset
;
workSpace
->
area
->
currOffset
+=
realLen
;
workSpace
->
area
->
securityNodeCount
++
;
return
offset
;
}
INIT_LOCAL_API
uint32_t
AddParamNode
(
WorkSpace
*
workSpace
,
INIT_LOCAL_API
uint32_t
AddParamNode
(
WorkSpace
*
workSpace
,
uint8_t
type
,
const
char
*
key
,
uint32_t
keyLen
,
const
char
*
value
,
uint32_t
valueLen
)
{
PARAM_CHECK
(
workSpace
!=
NULL
&&
workSpace
->
area
!=
NULL
,
return
0
,
"Invalid param"
);
...
...
@@ -366,7 +353,7 @@ INIT_LOCAL_API uint32_t AddParamNode(WorkSpace *workSpace,
if
((
valueLen
>
PARAM_VALUE_LEN_MAX
)
||
IS_READY_ONLY
(
key
))
{
realLen
+=
keyLen
+
valueLen
;
}
else
{
realLen
+=
keyLen
+
PARAM_VALUE_LEN_MAX
;
realLen
+=
keyLen
+
GetParamMaxLen
(
type
)
;
}
realLen
=
PARAM_ALIGN
(
realLen
);
PARAM_CHECK
((
workSpace
->
area
->
currOffset
+
realLen
)
<
workSpace
->
area
->
dataSize
,
return
0
,
...
...
@@ -376,6 +363,7 @@ INIT_LOCAL_API uint32_t AddParamNode(WorkSpace *workSpace,
ParamNode
*
node
=
(
ParamNode
*
)(
workSpace
->
area
->
data
+
workSpace
->
area
->
currOffset
);
ATOMIC_INIT
(
&
node
->
commitId
,
0
);
node
->
type
=
type
;
node
->
keyLength
=
keyLen
;
node
->
valueLength
=
valueLen
;
int
ret
=
ParamSprintf
(
node
->
data
,
realLen
,
"%s=%s"
,
key
,
value
);
...
...
@@ -417,4 +405,15 @@ INIT_LOCAL_API ParamTrieNode *FindTrieNode(WorkSpace *workSpace,
return
NULL
;
}
return
node
;
}
uint32_t
GetParamMaxLen
(
uint8_t
type
)
{
static
const
uint32_t
typeLengths
[]
=
{
PARAM_VALUE_LEN_MAX
,
32
,
8
// 8 max bool length 32 max int length
};
if
(
type
>=
ARRAY_LENGTH
(
typeLengths
))
{
return
PARAM_VALUE_LEN_MAX
;
}
return
typeLengths
[
type
];
}
\ No newline at end of file
services/param/include/param_manager.h
浏览文件 @
866c68f3
...
...
@@ -84,8 +84,9 @@ INIT_LOCAL_API WorkSpace *GetNextWorkSpace(WorkSpace *curr);
INIT_LOCAL_API
WorkSpace
*
GetWorkSpace
(
const
char
*
name
);
INIT_LOCAL_API
ParamTrieNode
*
GetTrieNodeByHandle
(
ParamHandle
handle
);
INIT_LOCAL_API
int
ReadParamWithCheck
(
const
char
*
name
,
uint32_t
op
,
ParamHandle
*
handle
);
INIT_LOCAL_API
int
CheckParamValue
(
const
ParamTrieNode
*
node
,
const
char
*
name
,
const
char
*
value
);
INIT_LOCAL_API
int
CheckParamValue
(
const
ParamTrieNode
*
node
,
const
char
*
name
,
const
char
*
value
,
uint8_t
paramType
);
INIT_LOCAL_API
int
CheckParamName
(
const
char
*
name
,
int
paramInfo
);
INIT_LOCAL_API
uint8_t
GetParamValueType
(
const
char
*
name
);
INIT_LOCAL_API
ParamNode
*
SystemCheckMatchParamWait
(
const
char
*
name
,
const
char
*
value
);
INIT_LOCAL_API
int
WriteParam
(
const
char
*
name
,
const
char
*
value
,
uint32_t
*
dataIndex
,
int
onlyAdd
);
...
...
services/param/include/param_osadp.h
浏览文件 @
866c68f3
...
...
@@ -142,7 +142,7 @@ int ParamRWMutexRDLock(ParamRWMutex *lock);
int
ParamRWMutexUnlock
(
ParamRWMutex
*
lock
);
int
ParamRWMutexDelete
(
ParamRWMutex
*
lock
);
int
ParamMutexCeate
(
ParamMutex
*
mutex
);
int
ParamMutexC
r
eate
(
ParamMutex
*
mutex
);
int
ParamMutexPend
(
ParamMutex
*
mutex
);
int
ParamMutexPost
(
ParamMutex
*
mutex
);
int
ParamMutexDelete
(
ParamMutex
*
mutex
);
...
...
services/param/include/param_persist.h
浏览文件 @
866c68f3
/*
* Copyright (c) 202
1
Huawei Device Co., Ltd.
* Copyright (c) 202
2
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
...
...
@@ -50,6 +50,8 @@ int RegisterPersistParamOps(PersistParamOps *ops);
void
TimerCallbackForSave
(
ParamTaskPtr
timer
,
void
*
context
);
#endif
void
CheckAndSavePersistParam
(
void
);
#ifdef __cplusplus
#if __cplusplus
}
...
...
services/param/include/param_security.h
浏览文件 @
866c68f3
...
...
@@ -74,7 +74,8 @@ typedef struct {
pid_t
pid
;
uid_t
uid
;
gid_t
gid
;
uint32_t
mode
;
uint16_t
mode
;
uint8_t
paramType
;
}
ParamDacData
;
typedef
struct
{
...
...
services/param/include/param_trie.h
浏览文件 @
866c68f3
...
...
@@ -50,9 +50,15 @@ typedef struct {
#define PARAM_FLAGS_WAITED 0x20000000
#define PARAM_FLAGS_COMMITID 0x0000ffff
#define PARAM_TYPE_MASK 0x0f
#define PARAM_TYPE_STRING 0x00
#define PARAM_TYPE_INT 0x01
#define PARAM_TYPE_BOOL 0x02
typedef
struct
{
ATOMIC_UINT32
commitId
;
uint16_t
keyLength
;
uint8_t
type
;
uint8_t
keyLength
;
uint16_t
valueLength
;
char
data
[
0
];
}
ParamNode
;
...
...
@@ -61,7 +67,8 @@ typedef struct {
uid_t
uid
;
gid_t
gid
;
uint16_t
mode
;
uint16_t
length
;
uint8_t
type
;
uint8_t
length
;
char
data
[
0
];
}
ParamSecurityNode
;
...
...
@@ -107,9 +114,12 @@ typedef int (*TraversalTrieNodePtr)(const WorkSpace *workSpace, const ParamTrieN
INIT_LOCAL_API
int
TraversalTrieNode
(
const
WorkSpace
*
workSpace
,
const
ParamTrieNode
*
subTrie
,
TraversalTrieNodePtr
walkFunc
,
const
void
*
cookie
);
INIT_LOCAL_API
uint32_t
AddParamSec
ru
ityNode
(
WorkSpace
*
workSpace
,
const
ParamAuditData
*
auditData
);
INIT_LOCAL_API
uint32_t
AddParamNode
(
WorkSpace
*
workSpace
,
INIT_LOCAL_API
uint32_t
AddParamSec
ur
ityNode
(
WorkSpace
*
workSpace
,
const
ParamAuditData
*
auditData
);
INIT_LOCAL_API
uint32_t
AddParamNode
(
WorkSpace
*
workSpace
,
uint8_t
type
,
const
char
*
key
,
uint32_t
keyLen
,
const
char
*
value
,
uint32_t
valueLen
);
uint32_t
GetParamMaxLen
(
uint8_t
type
);
#ifdef __cplusplus
#if __cplusplus
}
...
...
services/param/include/param_utils.h
浏览文件 @
866c68f3
...
...
@@ -69,7 +69,7 @@ typedef struct cmdLineInfo {
#ifdef __LITEOS_M__
#ifndef DATA_PATH
#define DATA_PATH ""
#define DATA_PATH "
/
"
#endif
#elif defined __LITEOS_A__
#define DATA_PATH STARTUP_INIT_UT_PATH"/storage/data/system/param/"
...
...
@@ -101,6 +101,7 @@ typedef struct cmdLineInfo {
#define PARAM_LOGI(fmt, ...) STARTUP_LOGI(PARAN_DOMAIN, PARAN_LABEL, fmt, ##__VA_ARGS__)
#define PARAM_LOGE(fmt, ...) STARTUP_LOGE(PARAN_DOMAIN, PARAN_LABEL, fmt, ##__VA_ARGS__)
#define PARAM_LOGV(fmt, ...) STARTUP_LOGV(PARAN_DOMAIN, PARAN_LABEL, fmt, ##__VA_ARGS__)
#define PARAM_LOGW(fmt, ...) STARTUP_LOGW(PARAN_DOMAIN, PARAN_LABEL, fmt, ##__VA_ARGS__)
#define PARAM_CHECK(retCode, exper, ...) \
if
(
!
(
retCode
))
{
\
...
...
@@ -132,7 +133,7 @@ typedef struct cmdLineInfo {
#define SUBSTR_INFO_DAC 1
#endif
int
Split
e
String
(
char
*
line
,
const
char
*
exclude
[],
uint32_t
count
,
int
Split
Param
String
(
char
*
line
,
const
char
*
exclude
[],
uint32_t
count
,
int
(
*
result
)(
const
uint32_t
*
context
,
const
char
*
name
,
const
char
*
value
),
const
uint32_t
*
context
);
#ifdef __cplusplus
#if __cplusplus
...
...
services/param/linux/BUILD.gn
浏览文件 @
866c68f3
...
...
@@ -77,6 +77,7 @@ if (defined(ohos_lite)) {
"_GNU_SOURCE",
"__LINUX__",
"OHOS_LITE",
"PARAM_SUPPORT_REAL_CHECK",
"INCREMENTAL_VERSION=\"${ohos_version}\"",
"BUILD_TYPE=\"${ohos_build_type}\"",
"BUILD_USER=\"${ohos_build_user}\"",
...
...
@@ -102,7 +103,10 @@ if (defined(ohos_lite)) {
sources += param_trigger_sources
include_dirs = param_include_dirs
public_configs = [ ":exported_header_files" ]
defines = [ "_GNU_SOURCE" ]
defines = [
"_GNU_SOURCE",
"PARAM_SUPPORT_REAL_CHECK",
]
if (defined(boot_kernel_extended_cmdline)) {
defines += [ "BOOT_EXTENDED_CMDLINE=\"${boot_kernel_extended_cmdline}\"" ]
...
...
services/param/linux/param_message.c
浏览文件 @
866c68f3
...
...
@@ -15,11 +15,7 @@
#include "param_message.h"
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/un.h>
#include <unistd.h>
#include "param_utils.h"
#include "securec.h"
...
...
services/param/linux/param_osadp.c
浏览文件 @
866c68f3
...
...
@@ -49,7 +49,7 @@ int ParamRWMutexDelete(ParamRWMutex *lock)
return
0
;
}
int
ParamMutexCeate
(
ParamMutex
*
mutex
)
int
ParamMutexC
r
eate
(
ParamMutex
*
mutex
)
{
return
0
;
}
...
...
services/param/liteos/BUILD.gn
浏览文件 @
866c68f3
...
...
@@ -13,6 +13,7 @@
import("//base/startup/init/begetd.gni")
param_include_dirs = [
"//base/startup/init/interfaces/innerkits/include/syspara",
"//base/startup/init/services/param/include",
"//base/startup/init/services/param/adapter",
"//base/startup/init/services/include/param",
...
...
@@ -116,22 +117,26 @@ static_library("param_client_lite") {
"WORKSPACE_AREA_NEED_MUTEX",
"PARAM_PERSIST_SAVE_MUTEX",
"PARAMWORKSPACE_NEED_MUTEX",
"PARAM_SUPPORT_CYCLE_CHECK",
]
} else if (ohos_kernel_type == "liteos_m") {
sources += [ "//base/startup/init/services/param/manager/param_server.c" ]
sources += [
"//base/startup/init/services/param/liteos/param_hal.c",
"//base/startup/init/services/param/liteos/param_service.c",
"//base/startup/init/services/param/manager/param_server.c",
]
if (enable_ohos_startup_init_lite_use_posix_file_api) {
sources +=
[ "//base/startup/init/services/param/adapter/param_persistadp.c" ]
} else {
sources += [ "//base/startup/init/services/param/liteos/param_hal.c" ]
defines += [ "PARAM_SUPPORT_POSIX" ]
}
defines += [
"__LITEOS_M__",
"WORKSPACE_AREA_NEED_MUTEX",
"PARAM_PERSIST_SAVE_MUTEX",
"PARAMWORKSPACE_NEED_MUTEX",
"DATA_PATH=\"${config_ohos_startup_init_lite_data_path}\"",
]
if (config_ohos_startup_init_lite_data_path != "") {
defines += [ "DATA_PATH=\"${config_ohos_startup_init_lite_data_path}\"" ]
}
if (enable_ohos_startup_init_feature_begetctl_liteos) {
deps = [ ":lite_ohos_param_to" ]
include_dirs += [ "$root_out_dir/gen/init" ]
...
...
services/param/liteos/param_client.c
浏览文件 @
866c68f3
...
...
@@ -14,12 +14,10 @@
*/
#include "init_param.h"
#include "param_manager.h"
#ifdef PARAM_LOAD_CFG_FROM_CODE
#include "param_cfg.h"
#endif
#define MIN_SLEEP (100 * 1000)
static
int
g_flags
=
0
;
__attribute__
((
constructor
))
static
void
ClientInit
(
void
);
__attribute__
((
destructor
))
static
void
ClientDeinit
(
void
);
...
...
@@ -28,40 +26,26 @@ static int InitParamClient(void)
if
(
PARAM_TEST_FLAG
(
g_flags
,
WORKSPACE_FLAGS_INIT
))
{
return
0
;
}
#ifdef __LITEOS_M__
int
ret
=
InitParamWorkSpace
(
0
);
#else
EnableInitLog
(
INIT_INFO
);
int
ret
=
InitParamWorkSpace
(
1
);
#endif
PARAM_LOGV
(
"InitParamClient"
);
int
ret
=
InitParamWorkSpace
(
1
);
PARAM_CHECK
(
ret
==
0
,
return
-
1
,
"Failed to init param workspace"
);
PARAM_SET_FLAG
(
g_flags
,
WORKSPACE_FLAGS_INIT
);
// init persist to save
InitPersistParamWorkSpace
();
#ifdef PARAM_LOAD_CFG_FROM_CODE
for
(
size_t
i
=
0
;
i
<
ARRAY_LENGTH
(
g_paramDefCfgNodes
);
i
++
)
{
PARAM_LOGI
(
"InitParamClient name %s = %s"
,
g_paramDefCfgNodes
[
i
].
name
,
g_paramDefCfgNodes
[
i
].
value
);
uint32_t
dataIndex
=
0
;
ret
=
WriteParam
(
g_paramDefCfgNodes
[
i
].
name
,
g_paramDefCfgNodes
[
i
].
value
,
&
dataIndex
,
0
);
PARAM_CHECK
(
ret
==
0
,
continue
,
"Failed to set param %d name %s %s"
,
ret
,
g_paramDefCfgNodes
[
i
].
name
,
g_paramDefCfgNodes
[
i
].
value
);
}
#endif
#ifdef __LITEOS_M__
LoadParamFromBuild
();
// get persist param
LoadPersistParams
();
#endif
return
0
;
}
void
ClientInit
(
void
)
{
PARAM_LOGV
(
"ClientInit"
);
#ifdef __LITEOS_M__
InitParamService
();
#else
#ifndef STARTUP_INIT_TEST
(
void
)
InitParamClient
();
#endif
#endif
}
void
ClientDeinit
(
void
)
...
...
@@ -75,7 +59,6 @@ void ClientDeinit(void)
int
SystemSetParameter
(
const
char
*
name
,
const
char
*
value
)
{
PARAM_CHECK
(
name
!=
NULL
&&
value
!=
NULL
,
return
-
1
,
"Invalid name or value %s"
,
name
);
InitParamClient
();
int
ctrlService
=
0
;
int
ret
=
CheckParameterSet
(
name
,
value
,
GetParamSecurityLabel
(),
&
ctrlService
);
PARAM_CHECK
(
ret
==
0
,
return
ret
,
"Forbid to set parameter %s"
,
name
);
...
...
@@ -139,13 +122,11 @@ int WatchParamCheck(const char *keyprefix)
int
SystemCheckParamExist
(
const
char
*
name
)
{
(
void
)
InitParamClient
();
return
SysCheckParamExist
(
name
);
}
int
SystemFindParameter
(
const
char
*
name
,
ParamHandle
*
handle
)
{
(
void
)
InitParamClient
();
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
)
{
...
...
services/param/liteos/param_hal.c
浏览文件 @
866c68f3
...
...
@@ -28,6 +28,83 @@
// for linux, no mutex
static
ParamMutex
g_saveMutex
=
{};
#ifdef PARAM_SUPPORT_POSIX
#define MODE_READ O_RDONLY
#define MODE_APPEND (O_RDWR | O_CREAT | O_APPEND)
#define MODE_CREATE (O_RDWR | O_CREAT | O_TRUNC)
#else
#define MODE_READ O_RDONLY_FS
#define MODE_APPEND (O_RDWR_FS | O_CREAT_FS | O_APPEND_FS)
#define MODE_CREATE (O_RDWR_FS | O_CREAT_FS | O_TRUNC_FS)
#endif
static
int
ParamFileOpen
(
const
char
*
path
,
int
oflag
,
int
mode
)
{
#ifdef PARAM_SUPPORT_POSIX
return
open
(
path
,
oflag
,
mode
);
#else
return
UtilsFileOpen
(
path
,
oflag
,
mode
);
#endif
}
static
int
ParamFileClose
(
int
fd
)
{
#ifdef PARAM_SUPPORT_POSIX
return
close
(
fd
);
#else
return
UtilsFileClose
(
fd
);
#endif
}
static
int
ParamFileRead
(
int
fd
,
char
*
buf
,
unsigned
int
len
)
{
#ifdef PARAM_SUPPORT_POSIX
return
read
(
fd
,
buf
,
len
);
#else
return
UtilsFileRead
(
fd
,
buf
,
len
);
#endif
}
static
int
ParamFileWrite
(
int
fd
,
const
char
*
buf
,
unsigned
int
len
)
{
#ifdef PARAM_SUPPORT_POSIX
return
write
(
fd
,
buf
,
len
);
#else
return
UtilsFileWrite
(
fd
,
buf
,
len
);
#endif
}
static
int
ParamFileDelete
(
const
char
*
path
)
{
#ifdef PARAM_SUPPORT_POSIX
return
unlink
(
path
);
#else
return
UtilsFileDelete
(
path
);
#endif
}
static
int
ParamFileStat
(
const
char
*
path
,
unsigned
int
*
fileSize
)
{
#ifdef PARAM_SUPPORT_POSIX
int
fd
=
open
(
path
,
O_RDONLY
);
if
(
fd
<
0
)
{
return
-
1
;
}
*
fileSize
=
lseek
(
fd
,
0
,
SEEK_END
);
lseek
(
fd
,
0
,
SEEK_SET
);
return
0
;
#else
return
UtilsFileStat
(
path
,
fileSize
);
#endif
}
static
void
ParamFileSync
(
int
ft
)
{
#ifdef PARAM_SUPPORT_POSIX
fsync
(
ft
);
#else
#endif
}
static
int
LoadOnePersistParam_
(
const
uint32_t
*
context
,
const
char
*
name
,
const
char
*
value
)
{
...
...
@@ -45,27 +122,27 @@ static int LoadPersistParam(void)
int
fd
=
-
1
;
uint32_t
paramNum
=
0
;
do
{
fd
=
UtilsFileOpen
(
path
,
O_RDONLY_FS
,
0
);
fd
=
ParamFileOpen
(
path
,
MODE_READ
,
0
);
if
(
fd
<
0
)
{
path
=
PARAM_PERSIST_SAVE_PATH
;
fd
=
UtilsFileOpen
(
path
,
O_RDONLY_FS
,
0
);
fd
=
ParamFileOpen
(
path
,
MODE_READ
,
0
);
PARAM_LOGI
(
"LoadPersistParam open file %s"
,
path
);
}
PARAM_CHECK
(
fd
>=
0
,
break
,
"No valid persist parameter file %s"
,
path
);
// read file
uint32_t
fileSize
=
0
;
int
ret
=
Utils
FileStat
(
path
,
&
fileSize
);
int
ret
=
Param
FileStat
(
path
,
&
fileSize
);
PARAM_CHECK
(
ret
==
0
,
break
,
"Failed to get file state %s"
,
path
);
buffer
=
malloc
(
fileSize
);
PARAM_CHECK
(
buffer
!=
NULL
,
break
,
"Failed to get file"
);
ret
=
Utils
FileRead
(
fd
,
buffer
,
fileSize
);
ret
=
Param
FileRead
(
fd
,
buffer
,
fileSize
);
PARAM_CHECK
(
ret
==
0
,
break
,
"Failed to get read file %s"
,
path
);
uint32_t
currLen
=
0
;
while
(
currLen
<
fileSize
)
{
if
(
buffer
[
currLen
]
==
'\n'
)
{
// split line
buffer
[
currLen
]
=
'\0'
;
int
ret
=
Split
e
String
(
buffer
,
NULL
,
0
,
LoadOnePersistParam_
,
NULL
);
int
ret
=
Split
Param
String
(
buffer
,
NULL
,
0
,
LoadOnePersistParam_
,
NULL
);
PARAM_CHECK
(
ret
==
0
,
continue
,
"Failed to set param %d %s"
,
ret
,
buffer
);
paramNum
++
;
}
...
...
@@ -73,30 +150,30 @@ static int LoadPersistParam(void)
}
}
while
(
0
);
if
(
fd
>
0
)
{
Utils
FileClose
(
fd
);
Param
FileClose
(
fd
);
}
if
(
buffer
!=
NULL
)
{
free
(
buffer
);
}
PARAM_LOGI
(
"LoadPersistParam
from file %s paramNum %d"
,
path
,
paramNum
);
PARAM_LOGI
(
"LoadPersistParam
paramNum %d"
,
paramNum
);
return
0
;
}
static
int
PersistWrite
(
int
fd
,
const
char
*
name
,
const
char
*
value
)
{
int
ret
=
Utils
FileWrite
(
fd
,
name
,
strlen
(
name
));
int
ret
=
Param
FileWrite
(
fd
,
name
,
strlen
(
name
));
if
(
ret
<=
0
)
{
PARAM_LOGE
(
"Failed to save persist param %s"
,
name
);
}
ret
=
Utils
FileWrite
(
fd
,
"="
,
strlen
(
"="
));
ret
=
Param
FileWrite
(
fd
,
"="
,
strlen
(
"="
));
if
(
ret
<=
0
)
{
PARAM_LOGE
(
"Failed to save persist param %s"
,
name
);
}
ret
=
Utils
FileWrite
(
fd
,
value
,
strlen
(
value
));
ret
=
Param
FileWrite
(
fd
,
value
,
strlen
(
value
));
if
(
ret
<=
0
)
{
PARAM_LOGE
(
"Failed to save persist param %s"
,
name
);
}
ret
=
Utils
FileWrite
(
fd
,
"
\n
"
,
strlen
(
"
\n
"
));
ret
=
Param
FileWrite
(
fd
,
"
\n
"
,
strlen
(
"
\n
"
));
if
(
ret
<=
0
)
{
PARAM_LOGE
(
"Failed to save persist param %s"
,
name
);
}
...
...
@@ -107,10 +184,14 @@ static int SavePersistParam(const char *name, const char *value)
{
ParamMutexPend
(
&
g_saveMutex
);
int
ret
=
-
1
;
int
fd
=
UtilsFileOpen
(
PARAM_PERSIST_SAVE_PATH
,
O_RDWR_FS
|
O_CREAT_FS
|
O_APPEND_FS
,
0
);
int
fd
=
ParamFileOpen
(
PARAM_PERSIST_SAVE_PATH
,
MODE_APPEND
,
0
);
if
(
fd
>
0
)
{
ret
=
PersistWrite
(
fd
,
name
,
value
);
UtilsFileClose
(
fd
);
ParamFileSync
(
fd
);
ParamFileClose
(
fd
);
}
if
(
ret
!=
0
)
{
PARAM_LOGE
(
"SavePersistParam %s errno %d"
,
name
,
errno
);
}
ParamMutexPost
(
&
g_saveMutex
);
return
ret
;
...
...
@@ -119,10 +200,10 @@ static int SavePersistParam(const char *name, const char *value)
static
int
BatchSavePersistParamBegin
(
PERSIST_SAVE_HANDLE
*
handle
)
{
ParamMutexPend
(
&
g_saveMutex
);
int
fd
=
UtilsFileOpen
(
PARAM_PERSIST_SAVE_TMP_PATH
,
O_RDWR_FS
|
O_CREAT_FS
|
O_TRUNC_FS
,
0
);
int
fd
=
ParamFileOpen
(
PARAM_PERSIST_SAVE_PATH
,
MODE_CREATE
,
0
);
if
(
fd
<
0
)
{
ParamMutexPost
(
&
g_saveMutex
);
PARAM_LOGE
(
"Open file %s fail error %d"
,
PARAM_PERSIST_SAVE_
TMP_
PATH
,
errno
);
PARAM_LOGE
(
"Open file %s fail error %d"
,
PARAM_PERSIST_SAVE_PATH
,
errno
);
return
-
1
;
}
*
handle
=
(
PERSIST_SAVE_HANDLE
)
fd
;
...
...
@@ -142,17 +223,15 @@ static void BatchSavePersistParamEnd(PERSIST_SAVE_HANDLE handle)
{
int
ret
;
int
fd
=
(
int
)
handle
;
UtilsFileClose
(
fd
);
UtilsFileDelete
(
PARAM_PERSIST_SAVE_PATH
);
ret
=
UtilsFileMove
(
PARAM_PERSIST_SAVE_TMP_PATH
,
PARAM_PERSIST_SAVE_PATH
);
ParamFileSync
(
fd
);
ParamFileClose
(
fd
);
ParamMutexPost
(
&
g_saveMutex
);
PARAM_CHECK
(
ret
==
0
,
return
,
"BatchSavePersistParamEnd
%s fail error %d"
,
PARAM_PERSIST_SAVE_TMP_PATH
,
errno
);
PARAM_CHECK
(
ret
==
0
,
return
,
"BatchSavePersistParamEnd
fail error %d"
,
errno
);
}
int
RegisterPersistParamOps
(
PersistParamOps
*
ops
)
{
PARAM_LOGI
(
"RegisterPersistParamOps"
);
ParamMutexCeate
(
&
g_saveMutex
);
ParamMutexCreate
(
&
g_saveMutex
);
PARAM_CHECK
(
ops
!=
NULL
,
return
-
1
,
"Invalid ops"
);
ops
->
save
=
SavePersistParam
;
ops
->
load
=
LoadPersistParam
;
...
...
services/param/liteos/param_osadp.c
浏览文件 @
866c68f3
...
...
@@ -179,7 +179,7 @@ int ParamRWMutexDelete(ParamRWMutex *lock)
return
0
;
}
int
ParamMutexCeate
(
ParamMutex
*
mutex
)
int
ParamMutexC
r
eate
(
ParamMutex
*
mutex
)
{
PARAM_CHECK
(
mutex
!=
NULL
,
return
-
1
,
"Invalid mutex"
);
pthread_mutexattr_t
mutexattr
;
...
...
@@ -233,8 +233,6 @@ void FreeSharedMem(const MemHandle *handle, void *mem, uint32_t dataSize)
void
paramMutexEnvInit
(
void
)
{
uint32_t
ret
=
OsMuxInit
();
PARAM_CHECK
(
ret
==
LOS_OK
,
return
,
"Failed to init mutex ret %d"
,
ret
);
return
;
}
...
...
@@ -278,7 +276,7 @@ int ParamRWMutexDelete(ParamRWMutex *lock)
return
0
;
}
int
ParamMutexCeate
(
ParamMutex
*
mutex
)
int
ParamMutexC
r
eate
(
ParamMutex
*
mutex
)
{
PARAM_CHECK
(
mutex
!=
NULL
,
return
-
1
,
"Invalid lock"
);
uint32_t
ret
=
LOS_MuxCreate
(
&
mutex
->
mutex
);
...
...
services/param/liteos/param_service.c
浏览文件 @
866c68f3
...
...
@@ -12,15 +12,54 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <errno.h>
#include <unistd.h>
#include "init_param.h"
#include "init_utils.h"
#include "param_manager.h"
#ifdef PARAM_LOAD_CFG_FROM_CODE
#include "param_cfg.h"
#endif
#ifdef __LITEOS_M__
#include "ohos_init.h"
#include "cmsis_os2.h"
#include "parameter.h"
#endif
static
const
char
*
StringTrim
(
char
*
buffer
,
int
size
,
const
char
*
name
)
{
char
*
tmp
=
(
char
*
)
name
;
while
(
*
tmp
!=
'\0'
&&
*
tmp
!=
'"'
)
{
tmp
++
;
}
if
(
*
tmp
==
'\0'
)
{
return
name
;
}
// skip "
tmp
++
;
int
i
=
0
;
while
(
*
tmp
!=
'\0'
&&
i
<
size
)
{
buffer
[
i
++
]
=
*
tmp
;
tmp
++
;
}
if
(
i
>=
size
)
{
return
name
;
}
while
(
i
>
0
)
{
if
(
buffer
[
i
]
==
'"'
)
{
buffer
[
i
]
=
'\0'
;
return
buffer
;
}
i
--
;
}
return
name
;
}
void
InitParamService
(
void
)
{
PARAM_LOGI
(
"InitParamService
"
);
CheckAndCreateDir
(
PARAM_STORAGE_PATH
"/"
);
PARAM_LOGI
(
"InitParamService
%s"
,
DATA_PATH
);
CheckAndCreateDir
(
PARAM_STORAGE_PATH
"/"
);
CheckAndCreateDir
(
DATA_PATH
);
// param space
int
ret
=
InitParamWorkSpace
(
0
);
...
...
@@ -30,6 +69,19 @@ void InitParamService(void)
// from build
LoadParamFromBuild
();
#ifdef PARAM_LOAD_CFG_FROM_CODE
char
*
buffer
=
calloc
(
1
,
PARAM_VALUE_LEN_MAX
);
PARAM_CHECK
(
buffer
!=
NULL
,
return
,
"Failed to malloc for buffer"
);
for
(
size_t
i
=
0
;
i
<
ARRAY_LENGTH
(
g_paramDefCfgNodes
);
i
++
)
{
PARAM_LOGV
(
"InitParamService name %s = %s"
,
g_paramDefCfgNodes
[
i
].
name
,
g_paramDefCfgNodes
[
i
].
value
);
uint32_t
dataIndex
=
0
;
ret
=
WriteParam
(
g_paramDefCfgNodes
[
i
].
name
,
StringTrim
(
buffer
,
PARAM_VALUE_LEN_MAX
,
g_paramDefCfgNodes
[
i
].
value
),
&
dataIndex
,
0
);
PARAM_CHECK
(
ret
==
0
,
continue
,
"Failed to set param %d name %s %s"
,
ret
,
g_paramDefCfgNodes
[
i
].
name
,
g_paramDefCfgNodes
[
i
].
value
);
}
free
(
buffer
);
#endif
}
int
StartParamService
(
void
)
...
...
@@ -61,3 +113,42 @@ int SystemWriteParam(const char *name, const char *value)
}
return
ret
;
}
#ifdef __LITEOS_M__
#define OS_DELAY 1000 // * 30 // 30s
#define STACK_SIZE 1024
static
void
ParamServiceTask
(
int
*
arg
)
{
char
buffer
[
10
]
=
{
0
};
(
void
)
arg
;
PARAM_LOGI
(
"ParamServiceTask start"
);
while
(
1
)
{
CheckAndSavePersistParam
();
osDelay
(
OS_DELAY
);
}
}
void
LiteParamService
(
void
)
{
EnableInitLog
(
INIT_INFO
);
PARAM_LOGI
(
"LiteParamService"
);
InitParamService
();
// get persist param
LoadPersistParams
();
osThreadAttr_t
attr
;
attr
.
name
=
"ParamServiceTask"
;
attr
.
attr_bits
=
0U
;
attr
.
cb_mem
=
NULL
;
attr
.
cb_size
=
0U
;
attr
.
stack_mem
=
NULL
;
attr
.
stack_size
=
0
;
attr
.
priority
=
osPriorityBelowNormal
;
if
(
osThreadNew
((
osThreadFunc_t
)
ParamServiceTask
,
NULL
,
&
attr
)
==
NULL
)
{
PARAM_LOGE
(
"Failed to create ParamServiceTask! %d"
,
errno
);
}
}
CORE_INIT
(
LiteParamService
);
#endif
\ No newline at end of file
services/param/manager/param_manager.c
浏览文件 @
866c68f3
...
...
@@ -306,7 +306,7 @@ INIT_INNER_API int CheckParameterSet(const char *name,
PARAM_CHECK
(
srcLabel
!=
NULL
&&
ctrlService
!=
NULL
,
return
-
1
,
"Invalid param "
);
int
ret
=
CheckParamName
(
name
,
0
);
PARAM_CHECK
(
ret
==
0
,
return
ret
,
"Illegal param name %s"
,
name
);
ret
=
CheckParamValue
(
NULL
,
name
,
value
);
ret
=
CheckParamValue
(
NULL
,
name
,
value
,
GetParamValueType
(
name
)
);
PARAM_CHECK
(
ret
==
0
,
return
ret
,
"Illegal param value %s"
,
value
);
*
ctrlService
=
0
;
...
...
services/param/manager/param_persist.c
浏览文件 @
866c68f3
...
...
@@ -35,7 +35,7 @@ static int IsNeedToSave(const char *name)
return
(
strncmp
(
name
,
PARAM_PERSIST_PREFIX
,
strlen
(
PARAM_PERSIST_PREFIX
))
==
0
)
?
1
:
0
;
#endif
}
#ifdef PARAM_SUPPORT_CYCLE_CHECK
static
long
long
GetPersistCommitId
(
void
)
{
ParamWorkSpace
*
paramSpace
=
GetParamWorkSpace
();
...
...
@@ -50,7 +50,6 @@ static long long GetPersistCommitId(void)
PARAMSPACE_AREA_RW_UNLOCK
(
space
);
return
globalCommitId
;
}
#endif
static
void
UpdatePersistCommitId
(
void
)
{
...
...
@@ -145,27 +144,32 @@ INIT_LOCAL_API void ClosePersistParamWorkSpace(void)
g_persistWorkSpace
.
flags
=
0
;
}
void
CheckAndSavePersistParam
(
void
)
{
// check commit
long
long
commit
=
GetPersistCommitId
();
PARAM_LOGV
(
"CheckAndSavePersistParam commit %lld %lld"
,
commit
,
g_persistWorkSpace
.
commitId
);
if
(
g_persistWorkSpace
.
commitId
==
commit
)
{
return
;
}
g_persistWorkSpace
.
commitId
=
commit
;
(
void
)
BatchSavePersistParam
();
}
PARAM_STATIC
void
TimerCallbackForSave
(
const
ParamTaskPtr
timer
,
void
*
context
)
{
UNUSED
(
context
);
UNUSED
(
timer
);
// for liteos,we must cycle check
#ifndef PARAM_SUPPORT_CYCLE_CHECK
PARAM_LOGV
(
"TimerCallbackForSave "
);
// for liteos-a,we must cycle check
#if (!defined(PARAM_SUPPORT_CYCLE_CHECK) || defined(PARAM_SUPPORT_REAL_CHECK))
ParamTimerClose
(
g_persistWorkSpace
.
saveTimer
);
g_persistWorkSpace
.
saveTimer
=
NULL
;
if
(
!
PARAM_TEST_FLAG
(
g_persistWorkSpace
.
flags
,
WORKSPACE_FLAGS_UPDATE
))
{
return
;
}
#else
// check commit
long
long
commit
=
GetPersistCommitId
();
PARAM_LOGV
(
"TimerCallbackForSave commit %lld %lld"
,
commit
,
g_persistWorkSpace
.
commitId
);
if
(
g_persistWorkSpace
.
commitId
==
commit
)
{
return
;
}
g_persistWorkSpace
.
commitId
=
commit
;
#endif
(
void
)
Batch
SavePersistParam
();
CheckAnd
SavePersistParam
();
}
INIT_LOCAL_API
int
WritePersistParam
(
const
char
*
name
,
const
char
*
value
)
...
...
@@ -180,7 +184,11 @@ INIT_LOCAL_API int WritePersistParam(const char *name, const char *value)
}
// update commit for check
UpdatePersistCommitId
();
// for liteos-m, start task to check and save parameter
// for linux, start timer after set persist parameter
// for liteos-a, start timer in init to check and save parameter
#ifdef PARAM_SUPPORT_REAL_CHECK
PARAM_LOGI
(
"WritePersistParam start check "
);
if
(
!
PARAM_TEST_FLAG
(
g_persistWorkSpace
.
flags
,
WORKSPACE_FLAGS_LOADED
))
{
PARAM_LOGE
(
"Can not save persist param before load %s "
,
name
);
return
0
;
...
...
@@ -200,7 +208,7 @@ INIT_LOCAL_API int WritePersistParam(const char *name, const char *value)
}
return
BatchSavePersistParam
();
}
#ifndef PARAM_SUPPORT_CYCLE_CHECK
PARAM_SET_FLAG
(
g_persistWorkSpace
.
flags
,
WORKSPACE_FLAGS_UPDATE
);
if
(
g_persistWorkSpace
.
saveTimer
==
NULL
)
{
ParamTimerCreate
(
&
g_persistWorkSpace
.
saveTimer
,
TimerCallbackForSave
,
NULL
);
...
...
@@ -228,7 +236,9 @@ int LoadPersistParams(void)
// save new persist param
ret
=
BatchSavePersistParam
();
PARAM_CHECK
(
ret
==
0
,
return
ret
,
"Failed to load persist param"
);
// for liteos-a, start time to check in init
#ifdef PARAM_SUPPORT_CYCLE_CHECK
PARAM_LOGV
(
"LoadPersistParams start check time "
);
if
(
g_persistWorkSpace
.
saveTimer
==
NULL
)
{
ParamTimerCreate
(
&
g_persistWorkSpace
.
saveTimer
,
TimerCallbackForSave
,
NULL
);
ParamTimerStart
(
g_persistWorkSpace
.
saveTimer
,
PARAM_MUST_SAVE_PARAM_DIFF
*
MS_UNIT
,
MS_UNIT
);
...
...
services/param/manager/param_server.c
浏览文件 @
866c68f3
...
...
@@ -174,7 +174,7 @@ static int LoadDefaultParam_(const char *fileName, uint32_t mode, const char *ex
}
while
(
fgets
(
buffer
,
buffSize
,
fp
)
!=
NULL
)
{
buffer
[
buffSize
-
1
]
=
'\0'
;
int
ret
=
Split
e
String
(
buffer
,
exclude
,
count
,
LoadOneParam_
,
&
mode
);
int
ret
=
Split
Param
String
(
buffer
,
exclude
,
count
,
LoadOneParam_
,
&
mode
);
PARAM_CHECK
(
ret
==
0
,
continue
,
"Failed to set param '%s' error:%d "
,
buffer
,
ret
);
paramNum
++
;
}
...
...
@@ -215,23 +215,34 @@ INIT_LOCAL_API void LoadParamFromBuild(void)
{
PARAM_LOGI
(
"load parameters from build "
);
#ifdef INCREMENTAL_VERSION
WriteParam
(
"const.product.incremental.version"
,
INCREMENTAL_VERSION
,
NULL
,
LOAD_PARAM_NORMAL
);
if
(
strlen
(
INCREMENTAL_VERSION
)
>
0
)
{
WriteParam
(
"const.product.incremental.version"
,
INCREMENTAL_VERSION
,
NULL
,
LOAD_PARAM_NORMAL
);
}
#endif
#ifdef BUILD_TYPE
WriteParam
(
"const.product.build.type"
,
BUILD_TYPE
,
NULL
,
LOAD_PARAM_NORMAL
);
if
(
strlen
(
BUILD_TYPE
)
>
0
)
{
WriteParam
(
"const.product.build.type"
,
BUILD_TYPE
,
NULL
,
LOAD_PARAM_NORMAL
);
}
#endif
#ifdef BUILD_USER
WriteParam
(
"const.product.build.user"
,
BUILD_USER
,
NULL
,
LOAD_PARAM_NORMAL
);
if
(
strlen
(
BUILD_USER
)
>
0
)
{
WriteParam
(
"const.product.build.user"
,
BUILD_USER
,
NULL
,
LOAD_PARAM_NORMAL
);
}
#endif
#ifdef BUILD_TIME
PARAM_LOGI
(
"const.product.build.date %s"
,
BUILD_TIME
);
WriteParam
(
"const.product.build.date"
,
BUILD_TIME
,
NULL
,
LOAD_PARAM_NORMAL
);
if
(
strlen
(
BUILD_TIME
)
>
0
)
{
WriteParam
(
"const.product.build.date"
,
BUILD_TIME
,
NULL
,
LOAD_PARAM_NORMAL
);
}
#endif
#ifdef BUILD_HOST
WriteParam
(
"const.product.build.host"
,
BUILD_HOST
,
NULL
,
LOAD_PARAM_NORMAL
);
if
(
strlen
(
BUILD_HOST
)
>
0
)
{
WriteParam
(
"const.product.build.host"
,
BUILD_HOST
,
NULL
,
LOAD_PARAM_NORMAL
);
}
#endif
#ifdef BUILD_ROOTHASH
WriteParam
(
"const.ohos.buildroothash"
,
BUILD_ROOTHASH
,
NULL
,
LOAD_PARAM_NORMAL
);
if
(
strlen
(
BUILD_ROOTHASH
)
>
0
)
{
WriteParam
(
"const.ohos.buildroothash"
,
BUILD_ROOTHASH
,
NULL
,
LOAD_PARAM_NORMAL
);
}
#endif
}
services/utils/BUILD.gn
浏览文件 @
866c68f3
...
...
@@ -27,7 +27,10 @@ if (defined(ohos_lite)) {
"//base/startup/init/interfaces/innerkits/include",
"//third_party/bounds_checking_function/include",
]
defines = [ "_GNU_SOURCE" ]
defines = [
"_GNU_SOURCE",
"OHOS_LITE",
]
}
} else {
import("//build/ohos.gni")
...
...
services/utils/init_utils.c
浏览文件 @
866c68f3
...
...
@@ -496,12 +496,16 @@ int ReadFileInDir(const char *dirPath, const char *includeExt,
// Check if in updater mode.
int
InUpdaterMode
(
void
)
{
#ifdef OHOS_LITE
return
0
;
#else
const
char
*
const
updaterExecutabeFile
=
"/bin/updater"
;
if
(
access
(
updaterExecutabeFile
,
X_OK
)
==
0
)
{
return
1
;
}
else
{
return
0
;
}
#endif
}
int
StringReplaceChr
(
char
*
strl
,
char
oldChr
,
char
newChr
)
...
...
@@ -582,3 +586,47 @@ void OpenConsole(void)
return
;
#endif
}
INIT_LOCAL_API
int
StringToLL
(
const
char
*
str
,
long
long
int
*
out
)
{
INIT_ERROR_CHECK
(
str
!=
NULL
&&
out
!=
NULL
,
return
-
1
,
"Invalid parament"
);
const
char
*
s
=
str
;
while
(
isspace
(
*
s
))
{
s
++
;
}
size_t
len
=
strlen
(
str
);
int
positiveHex
=
(
len
>
1
&&
s
[
0
]
==
'0'
&&
(
s
[
1
]
==
'x'
||
s
[
1
]
==
'X'
));
int
negativeHex
=
(
len
>
2
&&
s
[
0
]
==
'-'
&&
s
[
1
]
==
'0'
&&
(
s
[
2
]
==
'x'
||
s
[
2
]
==
'X'
));
// 2: shorttest
int
base
=
(
positiveHex
||
negativeHex
)
?
HEX_BASE
:
DECIMAL_BASE
;
char
*
end
=
NULL
;
errno
=
0
;
*
out
=
strtoll
(
s
,
&
end
,
base
);
if
(
errno
!=
0
)
{
INIT_LOGE
(
"StringToLL %s err = %d"
,
str
,
errno
);
return
-
1
;
}
BEGET_CHECK
(
!
(
s
==
end
||
*
end
!=
'\0'
),
return
-
1
);
return
0
;
}
INIT_LOCAL_API
int
StringToULL
(
const
char
*
str
,
unsigned
long
long
int
*
out
)
{
INIT_ERROR_CHECK
(
str
!=
NULL
&&
out
!=
NULL
,
return
-
1
,
"Invalid parament"
);
const
char
*
s
=
str
;
while
(
isspace
(
*
s
))
{
s
++
;
}
BEGET_CHECK
(
s
[
0
]
!=
'-'
,
return
-
1
);
int
base
=
(
s
[
0
]
==
'0'
&&
(
s
[
1
]
==
'x'
||
s
[
1
]
==
'X'
))
?
HEX_BASE
:
DECIMAL_BASE
;
char
*
end
=
NULL
;
errno
=
0
;
*
out
=
strtoull
(
s
,
&
end
,
base
);
if
(
errno
!=
0
)
{
INIT_LOGE
(
"StringToULL %s err = %d"
,
str
,
errno
);
return
-
1
;
}
BEGET_CHECK
(
end
!=
s
,
return
-
1
);
BEGET_CHECK
(
*
end
==
'\0'
,
return
-
1
);
return
0
;
}
test/exec_test/fd_holder_test.cfg
浏览文件 @
866c68f3
...
...
@@ -11,7 +11,7 @@
"name" : "fd_holder_test",
"path" : ["/system/bin/fd_holder_test", "save", "fd_holder_test", "/data/test/1", "/data/test/2"],
"uid" : "root",
"gid" : "system"
,
"gid" : "system"
}
]
}
\ No newline at end of file
test/moduletest/param_test_cmds.c
浏览文件 @
866c68f3
...
...
@@ -14,12 +14,8 @@
*/
#include <fcntl.h>
#include <pthread.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "begetctl.h"
#include "init_param.h"
...
...
@@ -27,7 +23,6 @@
#include "parameter.h"
#include "plugin_test.h"
#include "service_watcher.h"
#include "shell_utils.h"
#define READ_DURATION 100000
static
char
*
GetLocalBuffer
(
uint32_t
*
buffSize
)
...
...
test/unittest/lite/BUILD.gn
浏览文件 @
866c68f3
...
...
@@ -157,15 +157,13 @@ if (defined(ohos_lite)) {
defines += [ "__LITEOS_M__" ]
sources += [
"//base/startup/init/services/param/liteos/param_client.c",
"//base/startup/init/services/param/liteos/param_hal.c",
"//base/startup/init/services/param/liteos/param_litedac.c",
"//base/startup/init/services/param/liteos/param_osadp.c",
"//base/startup/init/services/param/liteos/param_service.c",
]
if (enable_ohos_startup_init_lite_use_posix_file_api) {
sources +=
[ "//base/startup/init/services/param/adapter/param_persistadp.c" ]
} else {
sources += [ "//base/startup/init/services/param/liteos/param_hal.c" ]
defines += [ "PARAM_SUPPORT_POSIX" ]
}
sources += [
"../param/dac_unittest.cpp",
...
...
test/unittest/param/client_unittest.cpp
浏览文件 @
866c68f3
...
...
@@ -135,8 +135,9 @@ static void TestPermission()
EXPECT_EQ
(
ret
,
testResult
);
#endif
u_int32_t
len
=
sizeof
(
tmp
);
SetTestPermissionResult
(
DAC_RESULT_FORBIDED
);
ret
=
SystemGetParameter
(
testName
,
tmp
,
&
len
);
EXPECT_EQ
(
ret
,
testResult
);
EXPECT_EQ
(
ret
,
DAC_RESULT_FORBIDED
);
RegisterSecurityOps
(
0
);
SetTestPermissionResult
(
0
);
// recover testpermission result
}
...
...
test/unittest/param/watcher_agent_unittest.cpp
浏览文件 @
866c68f3
...
...
@@ -61,7 +61,7 @@ public:
ret
=
SystemWatchParameter
(
"test.permission.watcher.tes^^^^t1*"
,
TestParameterChange
,
nullptr
);
EXPECT_NE
(
ret
,
0
);
ret
=
SystemWatchParameter
(
"test.permission.read.test1*"
,
TestParameterChange
,
nullptr
);
EXPECT_EQ
(
ret
,
0
);
EXPECT_EQ
(
ret
,
DAC_RESULT_FORBIDED
);
return
0
;
}
...
...
@@ -78,7 +78,7 @@ public:
ret
=
SystemWatchParameter
(
"test.permission.watcher.tes^^^^t1*"
,
nullptr
,
nullptr
);
EXPECT_NE
(
ret
,
0
);
ret
=
SystemWatchParameter
(
"test.permission.read.test1*"
,
nullptr
,
nullptr
);
EXPECT_EQ
(
ret
,
0
);
EXPECT_EQ
(
ret
,
DAC_RESULT_FORBIDED
);
return
0
;
}
...
...
test/unittest/syspara/syspara_unittest.cpp
浏览文件 @
866c68f3
...
...
@@ -16,6 +16,7 @@
#include "gtest/gtest.h"
#include "init_param.h"
#include "init_utils.h"
#include "parameter.h"
#include "sysparam_errno.h"
#include "param_comm.h"
...
...
test/unittest/tools/prepare_testdata.sh
浏览文件 @
866c68f3
...
...
@@ -18,7 +18,8 @@
# path is the rootdir of ohos projects.
if
[
$#
-lt
1
]
;
then
echo
"Usage
$0
<ohos project rootpath>"
echo
"Usage
$0
<product name>"
echo
"example
$0
rk3568"
exit
1
fi
...
...
@@ -31,16 +32,30 @@ function hdc_shell_cmd() {
hdc shell
$@
}
function
hdc_push_cmd
()
{
# do nothing if there are not any arguments
if
[
$#
-ne
2
]
;
then
return
;
fi
echo
"Pushing resources to device"
hdc file send
$@
sleep
0.2
function
get_root_dir
()
{
local
cur_path
=
$(
pwd
)
while
[
"
${
cur_path
}
"
!=
""
]
do
cur_path
=
${
cur_path
%/*
}
if
[
"
${
cur_path
}
"
==
""
]
;
then
echo
"[error] get code root dir fail"
exit
1
fi
if
[
"
$(
basename
${
cur_path
}
)
"
==
"base"
]
;
then
ohos_root
=
${
cur_path
%/*
}
return
fi
done
}
get_root_dir
product_name
=
$1
if
[
!
-d
"
${
ohos_root
}
/out/
${
product_name
}
"
]
;
then
echo
"product
${
product_name
}
not exist"
exit
1
fi
hdc target mount
sleep
0.2
hdc_shell_cmd
"mount -o remount,rw /"
...
...
@@ -54,33 +69,13 @@ hdc_shell_cmd "umask 022"
hdc_shell_cmd
"mkdir -p
${
ut_target_path
}
"
hdc_shell_cmd
"mkdir -p
${
ut_target_path
}
/proc"
ohos_root
=
"
$1
"
ohos_root
=
${
ohos_root
%%/
}
ohos_init
=
"
${
ohos_root
}
/base/startup/init"
ohos_init
=
"
${
ohos_root
}
/base/startup"
hdc_shell_cmd
"mkdir -p
${
ut_target_path
}
/coverage"
sleep
0.25
# copy file to test
hdc_shell_cmd
"mkdir -p
${
ut_target_path
}
/system"
hdc_shell_cmd
"mkdir -p
${
ut_target_path
}
/system/etc"
hdc_shell_cmd
"mkdir -p
${
ut_target_path
}
/system/etc/param"
hdc_shell_cmd
"mkdir -p
${
ut_target_path
}
/system/etc/param/ohos_const"
hdc_shell_cmd
"mkdir -p
${
ut_target_path
}
/vendor"
hdc_shell_cmd
"mkdir -p
${
ut_target_path
}
/vendor/etc"
hdc_shell_cmd
"mkdir -p
${
ut_target_path
}
/vendor/etc/param"
hdc_shell_cmd
"cp
${
ohos_root
}
/base/startup/init/test/unittest/test_data/system/etc/param/ohos_const/*
${
ut_target_path
}
/system/etc/param/ohos_const/"
hdc_push_cmd
${
ohos_root
}
/base/startup/init/test/unittest/test_data/system/etc/param/ohos.para
${
ut_target_path
}
/system/etc/param/ohos.para
hdc_push_cmd
${
ohos_root
}
/base/startup/init/test/unittest/test_data/system/etc/param/ohos.para.dac
${
ut_target_path
}
/system/etc/param/ohos.para.dac
hdc_push_cmd
${
ohos_root
}
/base/startup/init/test/unittest/test_data/system/etc/param/ohos.para.selinux
${
ut_target_path
}
/system/etc/param/ohos.para.selinux
hdc_push_cmd
${
ohos_root
}
/base/startup/init/test/unittest/test_data/trigger_test.cfg /data/init_ut/trigger_test.cfg
sleep
0.2
hdc_push_cmd
${
ohos_root
}
/base/startup/init/test/unittest/test_data/proc/cmdline /data/init_ut/proc/cmdline
sleep
0.25
hdc file send
${
ohos_root
}
/out/rk3568/tests/unittest/startup/init/init_unittest /data/init_ut/init_unittest
hdc file send
${
ohos_root
}
/out/
${
product_name
}
/tests/unittest/startup/init/init_unittest /data/init_ut/init_unittest
sleep
0.25
hdc_shell_cmd
"cp /data/init_ut/init_unittest /bin/init_unittest"
...
...
@@ -109,7 +104,7 @@ done
echo
"Find out all gcno files and copy to
${
ohos_init
}
"
find
${
ohos_root
}
/out/
rk3568
/obj/base/startup/
-name
"*.gcno"
-type
f
-exec
cp
{}
.
\;
find
${
ohos_root
}
/out/
${
product_name
}
/obj/base/startup/
-name
"*.gcno"
-type
f
-exec
cp
{}
.
\;
if
[
$?
-ne
0
]
;
then
echo
"find gcno failed."
popd
2>&1
>
/dev/null
...
...
ueventd/standard/ueventd_parameter.c
浏览文件 @
866c68f3
...
...
@@ -14,7 +14,6 @@
*/
#include "ueventd_parameter.h"
#include <errno.h>
#include <pthread.h>
#include <sys/time.h>
...
...
@@ -24,7 +23,6 @@
#include "init_param.h"
#include "ueventd.h"
#include "ueventd_read_cfg.h"
#include "ueventd_utils.h"
typedef
struct
{
int
inited
;
...
...
ueventd/ueventd.c
浏览文件 @
866c68f3
...
...
@@ -20,7 +20,6 @@
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
#include <fcntl.h>
...
...
ueventd/ueventd_device_handler.c
浏览文件 @
866c68f3
...
...
@@ -24,7 +24,6 @@
#include <sys/stat.h>
#include <sys/sysmacros.h>
#include "init_utils.h"
#include "list.h"
#include "ueventd.h"
#ifndef __RAMDISK__
#include "ueventd_parameter.h"
...
...
ueventd/ueventd_socket.c
浏览文件 @
866c68f3
...
...
@@ -14,18 +14,11 @@
*/
#include <poll.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <ctype.h>
#include <signal.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <linux/netlink.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
#include "securec.h"
#define INIT_LOG_TAG "ueventd"
#include "init_log.h"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录