!3167 回退持久化参数的修改

Merge pull request !3167 from cat/0923revert_persist
This commit is contained in:
openharmony_ci 2024-09-23 14:12:45 +00:00 committed by Gitee
commit 6a3f9ed398
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 26 additions and 46 deletions

View File

@ -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",

View File

@ -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);

View File

@ -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

View File

@ -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