未验证 提交 811fc153 编写于 作者: O openharmony_ci 提交者: Gitee

!1628 支持产品workspace size 定制

Merge pull request !1628 from cheng_jinsong/init-worksize
......@@ -136,8 +136,9 @@ static uint32_t GetWorkSpaceSize(const char *content)
return PARAM_WORKSPACE_MAX;
}
char name[PARAM_NAME_LEN_MAX] = {0};
int index = 6; // 6 strlen for const.
(void)ParamMemcpy(name, sizeof(name), "const.", index);
size_t len = strlen(content);
int index = 0;
for (size_t i = strlen("u:object_r:"); i < len; i++) {
if (*(content + i) == ':') {
break;
......
......@@ -342,7 +342,11 @@ INIT_LOCAL_API ParamNode *GetParamNode(uint32_t index, const char *name)
INIT_LOCAL_API int AddParamEntry(uint32_t index, uint8_t type, const char *name, const char *value)
{
WorkSpace *workSpace = GetWorkSpace(WORKSPACE_INDEX_BASE);
ParamTrieNode *node = AddTrieNode(workSpace, name, strlen(name));
ParamTrieNode *node = FindTrieNode(workSpace, name, strlen(name), NULL);
if (node != NULL && node->dataIndex != 0) {
return 0;
}
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) {
......
......@@ -256,10 +256,14 @@ static int LoadOneParamAreaSize_(const uint32_t *context, const char *name, cons
ret = CheckParamValue(NULL, name, value, PARAM_TYPE_INT);
PARAM_CHECK(ret == 0, return 0, "Invalid value %s for %s", value, name);
PARAM_LOGV("LoadOneParamAreaSize_ [%s] [%s]", name, value);
return AddParamEntry(WORKSPACE_INDEX_BASE, PARAM_TYPE_INT, name, value);
char buffer[PARAM_NAME_LEN_MAX] = {0};
int len = sprintf_s(buffer, sizeof(buffer), "const.%s", name);
PARAM_CHECK(len > 0, return 0, "Failed to format value %s for %s", value, name);
return AddParamEntry(WORKSPACE_INDEX_BASE, PARAM_TYPE_INT, buffer, value);
}
INIT_LOCAL_API void LoadParamAreaSize(void)
{
LoadDefaultParam_("/sys_prod/etc/param/ohos.para.size", 0, NULL, 0, LoadOneParamAreaSize_);
LoadDefaultParam_(PARAM_AREA_SIZE_CFG, 0, NULL, 0, LoadOneParamAreaSize_);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册