From 8e96af126c464052ce7dc2de6a93b78b66ec479e Mon Sep 17 00:00:00 2001 From: fengjiahui4 Date: Fri, 4 Aug 2023 10:20:28 +0800 Subject: [PATCH] Feature: add file_migrate_ability interface Signed-off-by: fengjiahui4 --- .../init_module_engine/include/bootstage.h | 2 ++ services/init/standard/init_cmds.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/interfaces/innerkits/init_module_engine/include/bootstage.h b/interfaces/innerkits/init_module_engine/include/bootstage.h index 0bca1c8d6..d23debdc8 100755 --- a/interfaces/innerkits/init_module_engine/include/bootstage.h +++ b/interfaces/innerkits/init_module_engine/include/bootstage.h @@ -28,6 +28,8 @@ extern "C" { enum INIT_BOOTSTAGE { INIT_GLOBAL_INIT = 0, INIT_FIRST_STAGE = 1, + INIT_MOUNT_STAGE = 3, + INIT_RESTORECON = 4, INIT_POST_DATA_UNENCRYPT = 5, INIT_PRE_PARAM_SERVICE = 10, INIT_PRE_PARAM_LOAD = 20, diff --git a/services/init/standard/init_cmds.c b/services/init/standard/init_cmds.c index cd619737d..e2dea15bd 100755 --- a/services/init/standard/init_cmds.c +++ b/services/init/standard/init_cmds.c @@ -295,6 +295,7 @@ static void DoMountFstabFile(const struct CmdArgs *ctx) INIT_LOGI("Mount partitions from fstab file \" %s \"", ctx->argv[0]); int ret = MountAllWithFstabFile(ctx->argv[0], 0); INIT_LOGI("Mount partitions from fstab file \" %s \" finish ret %d", ctx->argv[0], ret); + HookMgrExecute(GetBootStageHookMgr(), INIT_MOUNT_STAGE, NULL, NULL); } static void DoUmountFstabFile(const struct CmdArgs *ctx) @@ -310,6 +311,20 @@ static void DoUmountFstabFile(const struct CmdArgs *ctx) static void DoRestorecon(const struct CmdArgs *ctx) { + int ret; + INIT_CMD_INFO cmdInfo; + cmdInfo.cmdName = "restorecon"; + cmdInfo.cmdContent = ctx->argv[0]; + cmdInfo.reserved = NULL; + + HOOK_EXEC_OPTIONS options; + options.flags = TRAVERSE_STOP_WHEN_ERROR; + options.preHook = NULL; + options.postHook = NULL; + ret = HookMgrExecute(GetBootStageHookMgr(), INIT_RESTORECON, (void*)(&cmdInfo), (void*)(&options)); + if (ret == 0) { + return; + } PluginExecCmdByName("restoreContentRecurse", ctx->argv[0]); return; }