mirror of
https://gitee.com/openharmony/startup_init
synced 2025-02-24 06:27:49 +00:00
Description:merge parameters
Feature or Bugfix:Bugfix Binary Source: No Signed-off-by: cat <chenjinxiang3@huawei.com>
This commit is contained in:
parent
10d46e555d
commit
1793f1c2f9
services/param
@ -111,6 +111,13 @@ typedef struct {
|
||||
char *prefix;
|
||||
} ParamTraversalContext;
|
||||
|
||||
typedef struct {
|
||||
uint8_t type;
|
||||
uint8_t mode;
|
||||
const char *name;
|
||||
const char *value;
|
||||
} ParamInfos;
|
||||
|
||||
#define PARAM_HANDLE(workSpace, index) (ParamHandle)((workSpace)->spaceIndex << 24 | (index))
|
||||
#define PARAM_GET_HANDLE_INFO(handle, label, index) \
|
||||
do { \
|
||||
|
@ -420,16 +420,17 @@ int SystemGetParameterName(ParamHandle handle, char *name, unsigned int len)
|
||||
return ReadParamName(handle, name, len);
|
||||
}
|
||||
|
||||
static int AddParam(WorkSpace *workSpace, uint8_t type, const char *name, const char *value, uint32_t *dataIndex, int mode)
|
||||
static int AddParam(WorkSpace *workSpace, ParamInfos paramInfos, uint32_t *dataIndex)
|
||||
{
|
||||
ParamTrieNode *node = AddTrieNode(workSpace, name, strlen(name));
|
||||
ParamTrieNode *node = AddTrieNode(workSpace, paramInfos.name, strlen(paramInfos.name));
|
||||
PARAM_CHECK(node != NULL, return PARAM_CODE_REACHED_MAX,
|
||||
"Failed to add node name %s space %s", name, workSpace->fileName);
|
||||
"Failed to add node name %s space %s", paramInfos.name, workSpace->fileName);
|
||||
ParamNode *entry = (ParamNode *)GetTrieNode(workSpace, node->dataIndex);
|
||||
if (entry == NULL) {
|
||||
uint32_t offset = AddParamNode(workSpace, type, name, strlen(name), value, strlen(value), mode);
|
||||
uint32_t offset = AddParamNode(workSpace, paramInfos.type, paramInfos.name,
|
||||
strlen(paramInfos.name), paramInfos.value, strlen(paramInfos.value), paramInfos.mode);
|
||||
PARAM_CHECK(offset > 0, return PARAM_CODE_REACHED_MAX,
|
||||
"Failed to allocate name %s space %s", name, workSpace->fileName);
|
||||
"Failed to allocate name %s space %s", paramInfos.name, workSpace->fileName);
|
||||
SaveIndex(&node->dataIndex, offset);
|
||||
ATOMIC_SYNC_ADD_AND_FETCH(&workSpace->area->commitId, 1, MEMORY_ORDER_RELEASE);
|
||||
#ifdef PARAM_SUPPORT_SELINUX
|
||||
@ -442,7 +443,7 @@ static int AddParam(WorkSpace *workSpace, uint8_t type, const char *name, const
|
||||
if (dataIndex != NULL) {
|
||||
*dataIndex = node->dataIndex;
|
||||
}
|
||||
PARAM_LOGV("AddParam name %s value: %s", name, value);
|
||||
PARAM_LOGV("AddParam name %s value: %s", paramInfos.name, paramInfos.value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -518,7 +519,8 @@ INIT_LOCAL_API int WriteParam(const char *name, const char *value, uint32_t *dat
|
||||
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, type, name, value, dataIndex, mode);
|
||||
ParamInfos paramInfos = {type, mode, name, value};
|
||||
ret = AddParam((WorkSpace *)workSpace, paramInfos, dataIndex);
|
||||
PARAMSPACE_AREA_RW_UNLOCK(workSpace);
|
||||
}
|
||||
if ((ret == PARAM_CODE_REACHED_MAX) && (flag == 1)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user