使用层级接口加载param

Signed-off-by: zhr758 <zhanghaoran@huawei.com>
This commit is contained in:
zhr758 2022-04-13 17:19:04 +08:00
parent a0962e3d49
commit 935a358669
3 changed files with 27 additions and 6 deletions

View File

@ -123,6 +123,7 @@ if (defined(ohos_lite)) {
sources += init_common_sources
include_dirs = [
"//base/customization/config_policy/interfaces/innerkits/include",
"//base/security/access_token/interfaces/innerkits/token_setproc/include",
"//base/security/access_token/interfaces/innerkits/nativetoken/include",
"//base/startup/init_lite/interfaces/innerkits/sandbox/include",
@ -139,6 +140,7 @@ if (defined(ohos_lite)) {
"//third_party/bounds_checking_function/include",
]
deps = [
"//base/customization/config_policy/frameworks/config_policy:configpolicy_util_for_init_static",
"//base/security/access_token/interfaces/innerkits/nativetoken:libnativetoken",
"//base/security/access_token/interfaces/innerkits/token_setproc:libtoken_setproc",
"//base/startup/init_lite/interfaces/innerkits:libfsmanager_static",

View File

@ -23,6 +23,8 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <linux/major.h>
#include "config_policy_utils.h"
#include "device.h"
#include "fd_holder_service.h"
#include "fs_manager/fs_manager.h"
@ -289,23 +291,38 @@ static void IsEnableSandbox(void)
}
}
// Init provide this function for static lib link
__attribute__((weak)) int SystemGetParameter(const char *name, char *value, unsigned int *len)
{
return SystemReadParam(name, value, len);
}
static void InitLoadParamFiles(void)
{
// Load const params, these can't be override!
LoadDefaultParams("/system/etc/param/ohos_const", LOAD_PARAM_NORMAL);
CfgFiles *files = GetCfgFiles("etc/param");
for (int i = MAX_CFG_POLICY_DIRS_CNT - 1; files && i >= 0; i--) {
if (files->paths[i]) {
LoadDefaultParams(files->paths[i], LOAD_PARAM_ONLY_ADD);
}
}
FreeCfgFiles(files);
}
void SystemConfig(void)
{
InitServiceSpace();
InitParamService();
InitParseGroupCfg();
PluginManagerInit();
InitParamService();
RegisterBootStateChange(BootStateChange);
// load SELinux context and policy
// Do not move position!
SystemLoadSelinux();
// parse parameters
LoadDefaultParams("/system/etc/param/ohos_const", LOAD_PARAM_NORMAL);
LoadDefaultParams("/vendor/etc/param", LOAD_PARAM_NORMAL);
LoadDefaultParams("/system/etc/param", LOAD_PARAM_ONLY_ADD);
InitLoadParamFiles();
// read config
ReadConfig();
INIT_LOGI("Parse init config file done.");

View File

@ -134,6 +134,7 @@ ohos_unittest("init_ut") {
configs = [ "//base/startup/init_lite/test/unittest:utest_config" ]
include_dirs = [
"//base/customization/config_policy/interfaces/innerkits/include",
"//base/startup/init_lite/services/init/standard",
"//base/startup/init_lite/interfaces/innerkits/include",
"//base/startup/init_lite/interfaces/innerkits/fd_holder",
@ -174,6 +175,7 @@ ohos_unittest("init_ut") {
]
deps = [
"//base/customization/config_policy/frameworks/config_policy:configpolicy_util_for_init_static",
"//base/security/access_token/interfaces/innerkits/nativetoken:libnativetoken",
"//base/security/access_token/interfaces/innerkits/token_setproc:libtoken_setproc",
"//base/startup/syspara_lite/interfaces/innerkits/native/syspara:syspara",