mirror of
https://github.com/openharmony/startup_init_lite.git
synced 2026-07-19 17:07:55 -04:00
modify init
This commit is contained in:
@@ -22,7 +22,7 @@ extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define MAX_CMD_NAME_LEN 10
|
||||
#define MAX_CMD_NAME_LEN 32
|
||||
#define MAX_CMD_CONTENT_LEN 256
|
||||
#define MAX_CMD_CNT_IN_ONE_JOB 200
|
||||
#define MAX_COPY_BUF_SIZE 256
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef OHOS_LITE
|
||||
#define INIT_CONFIGURATION_FILE "/init.cfg"
|
||||
#else
|
||||
|
||||
@@ -78,6 +78,7 @@ static const char* g_supportedCmds[] = {
|
||||
"trigger ",
|
||||
"reset ",
|
||||
"copy ",
|
||||
"setparam ",
|
||||
"load_persist_props "
|
||||
};
|
||||
|
||||
@@ -532,6 +533,21 @@ static void DoInsmod(const char *cmdContent)
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void DoSetParam(const char* cmdContent)
|
||||
{
|
||||
struct CmdArgs *ctx = GetCmd(cmdContent, " ");
|
||||
if (ctx == NULL || ctx->argv == NULL || ctx->argc != 2) {
|
||||
INIT_LOGE("[Init] DoSetParam failed.\n");
|
||||
goto out;
|
||||
}
|
||||
INIT_LOGE("[Init] param name: %s, value %s \n", ctx->argv[0], ctx->argv[1]);
|
||||
INIT_ERROR_CHECK(SystemWriteParameter(ctx->argv[0], ctx->argv[1]) == 0, goto out, "setparam fail \n");
|
||||
out:
|
||||
FreeCmd(&ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
#endif // OHOS_LITE
|
||||
|
||||
static bool CheckValidCfg(const char *path)
|
||||
@@ -870,6 +886,8 @@ void DoCmdByName(const char *name, const char *cmdContent)
|
||||
DoTriggerExec(cmdContent);
|
||||
} else if (strncmp(name, "load_persist_props ", strlen("load_persist_props ")) == 0) {
|
||||
LoadPersistProperties();
|
||||
} else if (strncmp(name, "setparam ", strlen("setparam ")) == 0) {
|
||||
DoSetParam(cmdContent);
|
||||
#endif
|
||||
} else {
|
||||
printf("[Init] DoCmd, unknown cmd name %s.\n", name);
|
||||
|
||||
@@ -361,9 +361,12 @@ static int GetServiceNumber(const cJSON* curArrItem, Service* curServ, const cha
|
||||
}
|
||||
|
||||
int value = (int)cJSON_GetNumberValue(filedJ);
|
||||
if (value < 0) {
|
||||
INIT_LOGE("[Init] GetServiceNumber, value = %d, error.\n", value);
|
||||
return SERVICE_FAILURE;
|
||||
// important value allow < 0
|
||||
if (strncmp(targetField, IMPORTANT_STR_IN_CFG, strlen(IMPORTANT_STR_IN_CFG)) != 0) {
|
||||
if (value < 0) {
|
||||
INIT_LOGE("[Init] GetServiceNumber, value = %d, error.\n", value);
|
||||
return SERVICE_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (strncmp(targetField, ONCE_STR_IN_CFG, strlen(ONCE_STR_IN_CFG)) == 0) {
|
||||
|
||||
Reference in New Issue
Block a user