mirror of
https://gitee.com/openharmony/startup_init
synced 2024-11-24 00:30:12 +00:00
commit
6a3f9ed398
@ -23,6 +23,7 @@
|
||||
"mkdir /data/service/el0/startup/init 0755 root root",
|
||||
"mkdir /data/vendor/log 0755 system log",
|
||||
"mount configfs none /config nodev noexec nosuid",
|
||||
"load_persist_params ",
|
||||
"bootchart start",
|
||||
"chown access_token access_token /dev/access_token_id",
|
||||
"chmod 0666 /dev/access_token_id",
|
||||
@ -130,7 +131,6 @@
|
||||
"mkdir /data/chipset/el1 0711 root root",
|
||||
"mkdir /data/chipset/el1/public 0711 root root",
|
||||
"mkdir /data/chipset/el2 0711 root root",
|
||||
"load_persist_params ",
|
||||
"init_main_user ",
|
||||
"mkdir /data/app/el1/0 0711 root root",
|
||||
"mkdir /data/app/el1/0/base 0711 root root",
|
||||
|
@ -33,35 +33,27 @@ static int LoadOnePersistParam_(const uint32_t *context, const char *name, const
|
||||
bool clearFactoryPersistParams = *(bool*)context;
|
||||
uint32_t dataIndex = 0;
|
||||
int mode = 0;
|
||||
int result = 0;
|
||||
do {
|
||||
if (!clearFactoryPersistParams) {
|
||||
mode |= LOAD_PARAM_PERSIST;
|
||||
result = WriteParam(name, value, &dataIndex, mode);
|
||||
break;
|
||||
}
|
||||
|
||||
char persetValue[PARAM_VALUE_LEN_MAX] = {0};
|
||||
uint32_t len = PARAM_VALUE_LEN_MAX;
|
||||
int ret = SystemReadParam(name, persetValue, &len);
|
||||
if (ret != 0) {
|
||||
mode |= LOAD_PARAM_PERSIST;
|
||||
result = WriteParam(name, value, &dataIndex, mode);
|
||||
break;
|
||||
}
|
||||
|
||||
if ((strcmp(persetValue, value) != 0)) {
|
||||
PARAM_LOGI("%s value is different, preset value is:%s, persist value is:%s", name, persetValue, value);
|
||||
mode |= LOAD_PARAM_PERSIST;
|
||||
result = WriteParam(name, value, &dataIndex, mode);
|
||||
}
|
||||
} while (0);
|
||||
#if !(defined __LITEOS_A__ || defined __LITEOS_M__)
|
||||
if (result == 0) {
|
||||
PostParamTrigger(EVENT_TRIGGER_PARAM_WATCH, name, value);
|
||||
|
||||
if (!clearFactoryPersistParams) {
|
||||
mode |= LOAD_PARAM_PERSIST;
|
||||
return WriteParam(name, value, &dataIndex, mode);
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
|
||||
char persetValue[PARAM_VALUE_LEN_MAX] = {0};
|
||||
uint32_t len = PARAM_VALUE_LEN_MAX;
|
||||
int ret = SystemReadParam(name, persetValue, &len);
|
||||
if (ret != 0) {
|
||||
mode |= LOAD_PARAM_PERSIST;
|
||||
return WriteParam(name, value, &dataIndex, mode);
|
||||
}
|
||||
|
||||
if ((strcmp(persetValue, value) != 0)) {
|
||||
PARAM_LOGI("%s value is different, preset value is:%s, persist value is:%s", name, persetValue, value);
|
||||
mode |= LOAD_PARAM_PERSIST;
|
||||
return WriteParam(name, value, &dataIndex, mode);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void LoadPersistParam_(const bool clearFactoryPersistParams, const char *fileName,
|
||||
@ -78,23 +70,12 @@ static void LoadPersistParam_(const bool clearFactoryPersistParams, const char *
|
||||
paramNum++;
|
||||
}
|
||||
(void)fclose(fp);
|
||||
if (access(PARAM_OLD_PERSIST_PATH, F_OK) == 0) {
|
||||
CheckAndCreateDir(PARAM_PERSIST_SAVE_PATH);
|
||||
int ret = unlink(fileName);
|
||||
PARAM_CHECK(ret == 0, return, "failed to delete file %s", fileName);
|
||||
}
|
||||
PARAM_LOGI("LoadPersistParam from file %s paramNum %d", fileName, paramNum);
|
||||
}
|
||||
|
||||
static int LoadPersistParam(void)
|
||||
{
|
||||
char *path = PARAM_PERSIST_SAVE_PATH;
|
||||
if (access(PARAM_OLD_PERSIST_PATH, F_OK) == 0 && access(PARAM_PERSIST_SAVE_PATH, F_OK) != 0) {
|
||||
path = PARAM_OLD_PERSIST_PATH;
|
||||
} else {
|
||||
CheckAndCreateDir(PARAM_PERSIST_SAVE_PATH);
|
||||
}
|
||||
|
||||
CheckAndCreateDir(PARAM_PERSIST_SAVE_PATH);
|
||||
bool clearFactoryPersistParams = false;
|
||||
char value[PARAM_VALUE_LEN_MAX] = {0};
|
||||
uint32_t len = PARAM_VALUE_LEN_MAX;
|
||||
@ -108,12 +89,12 @@ static int LoadPersistParam(void)
|
||||
PARAM_CHECK(buffer != NULL, return -1, "Failed to alloc");
|
||||
|
||||
int updaterMode = InUpdaterMode();
|
||||
char *tmpPath = (updaterMode == 0) ? path : "/param/persist_parameters";
|
||||
char *tmpPath = (updaterMode == 0) ? PARAM_PERSIST_SAVE_PATH : "/param/persist_parameters";
|
||||
LoadPersistParam_(clearFactoryPersistParams, tmpPath, buffer, buffSize);
|
||||
tmpPath = (updaterMode == 0) ? PARAM_PERSIST_SAVE_TMP_PATH : "/param/tmp_persist_parameters";
|
||||
LoadPersistParam_(clearFactoryPersistParams, tmpPath, buffer, buffSize);
|
||||
free(buffer);
|
||||
if (clearFactoryPersistParams && access(path, F_OK) == 0) {
|
||||
if (clearFactoryPersistParams && access(PARAM_PERSIST_SAVE_PATH, F_OK) == 0) {
|
||||
FILE *fp = fopen(PERSIST_PARAM_FIXED_FLAGS, "w");
|
||||
PARAM_CHECK(fp != NULL, return -1, "create file %s fail error %d", PERSIST_PARAM_FIXED_FLAGS, errno);
|
||||
(void)fclose(fp);
|
||||
|
@ -57,7 +57,7 @@ extern "C" {
|
||||
#define PARAM_NEED_CHECK_IN_SERVICE 0x2
|
||||
#define PARAM_CTRL_SERVICE 0x1
|
||||
#ifndef OHOS_LITE
|
||||
#define PERSIST_PARAM_FIXED_FLAGS "/data/service/el1/public/startup/persist_param_fixed"
|
||||
#define PERSIST_PARAM_FIXED_FLAGS "/data/service/el1/startup/persist_param_fixed"
|
||||
#else
|
||||
#define PERSIST_PARAM_FIXED_FLAGS "/storage/data/system/param/persist_param_fixed"
|
||||
#endif
|
||||
|
@ -73,7 +73,7 @@ typedef enum {
|
||||
#elif defined __LINUX__
|
||||
#define DATA_PATH STARTUP_INIT_UT_PATH"/storage/data/system/param/"
|
||||
#else
|
||||
#define DATA_PATH STARTUP_INIT_UT_PATH"/data/service/el1/public/startup/parameters/"
|
||||
#define DATA_PATH STARTUP_INIT_UT_PATH"/data/service/el1/startup/parameters/"
|
||||
#endif
|
||||
#define PARAM_AREA_SIZE_CFG STARTUP_INIT_UT_PATH"/etc/param/ohos.para.size"
|
||||
#define CLIENT_PIPE_NAME "/dev/unix/socket/paramservice"
|
||||
@ -81,7 +81,6 @@ typedef enum {
|
||||
#define PARAM_STORAGE_PATH STARTUP_INIT_UT_PATH "/dev/__parameters__"
|
||||
#define PARAM_PERSIST_SAVE_PATH DATA_PATH "persist_parameters"
|
||||
#define PARAM_PERSIST_SAVE_TMP_PATH DATA_PATH "tmp_persist_parameters"
|
||||
#define PARAM_OLD_PERSIST_PATH "data/service/el1/startup/parameters/persist_parameters"
|
||||
|
||||
#define WORKSPACE_FLAGS_INIT 0x01
|
||||
#define WORKSPACE_FLAGS_LOADED 0x02
|
||||
|
Loading…
Reference in New Issue
Block a user