From 84a840d9cb6671256cda3efd4ce6b20ba208046d Mon Sep 17 00:00:00 2001 From: mgceshuang Date: Fri, 9 Jun 2023 10:03:57 +0800 Subject: [PATCH] [bootDetector] uninstall the plugin after boot complete Signed-off-by: mgceshuang --- interfaces/innerkits/fs_manager/fstab_mount.c | 5 +++++ interfaces/innerkits/init_module_engine/include/bootstage.h | 2 +- .../innerkits/init_module_engine/include/init_modulemgr.h | 2 ++ interfaces/innerkits/init_module_engine/init_modulemgr.c | 5 +++++ .../innerkits/init_module_engine/stub/libinit.stub.json | 2 ++ services/init/standard/init.c | 2 +- services/modules/bootevent/bootevent.c | 1 + 7 files changed, 17 insertions(+), 2 deletions(-) diff --git a/interfaces/innerkits/fs_manager/fstab_mount.c b/interfaces/innerkits/fs_manager/fstab_mount.c index 7274f6e9d..a072ead7a 100755 --- a/interfaces/innerkits/fs_manager/fstab_mount.c +++ b/interfaces/innerkits/fs_manager/fstab_mount.c @@ -54,6 +54,10 @@ __attribute__((weak)) void RetriggerUeventByPath(int sockFd, char *path) } #endif +__attribute__((weak)) void InitPostMount(const char *mountPoint, int rc) +{ +} + bool IsSupportedFilesystem(const char *fsType) { bool supported = false; @@ -406,6 +410,7 @@ int MountOneItem(FstabItem *item) } int rc = Mount(item->deviceName, item->mountPoint, item->fsType, mountFlags, fsSpecificData); + InitPostMount(item->mountPoint, rc); if (rc != 0) { if (FM_MANAGER_NOFAIL_ENABLED(item->fsManagerFlags)) { BEGET_LOGE("Mount no fail device %s to %s failed, err = %d", item->deviceName, item->mountPoint, errno); diff --git a/interfaces/innerkits/init_module_engine/include/bootstage.h b/interfaces/innerkits/init_module_engine/include/bootstage.h index 29cfd4243..0bca1c8d6 100755 --- a/interfaces/innerkits/init_module_engine/include/bootstage.h +++ b/interfaces/innerkits/init_module_engine/include/bootstage.h @@ -27,7 +27,7 @@ extern "C" { enum INIT_BOOTSTAGE { INIT_GLOBAL_INIT = 0, - INIT_POST_MOUNT = 3, + INIT_FIRST_STAGE = 1, INIT_POST_DATA_UNENCRYPT = 5, INIT_PRE_PARAM_SERVICE = 10, INIT_PRE_PARAM_LOAD = 20, diff --git a/interfaces/innerkits/init_module_engine/include/init_modulemgr.h b/interfaces/innerkits/init_module_engine/include/init_modulemgr.h index 099c7ae5f..ee528857c 100755 --- a/interfaces/innerkits/init_module_engine/include/init_modulemgr.h +++ b/interfaces/innerkits/init_module_engine/include/init_modulemgr.h @@ -28,6 +28,8 @@ int InitModuleMgrInstall(const char *moduleName); void InitModuleMgrUnInstall(const char *moduleName); +void AutorunModuleMgrUnInstall(const char *moduleName); + void InitModuleMgrDump(void); #ifdef __cplusplus diff --git a/interfaces/innerkits/init_module_engine/init_modulemgr.c b/interfaces/innerkits/init_module_engine/init_modulemgr.c index f1e8c08f0..00e25239c 100644 --- a/interfaces/innerkits/init_module_engine/init_modulemgr.c +++ b/interfaces/innerkits/init_module_engine/init_modulemgr.c @@ -40,6 +40,11 @@ void InitModuleMgrUnInstall(const char *moduleName) ModuleMgrUninstall(defaultModuleMgr, moduleName); } +void AutorunModuleMgrUnInstall(const char *moduleName) +{ + ModuleMgrUninstall(autorunModuleMgr, moduleName); +} + static void InitModuleDump(const MODULE_INFO *moduleInfo) { printf("%s\n", moduleInfo->name); diff --git a/interfaces/innerkits/init_module_engine/stub/libinit.stub.json b/interfaces/innerkits/init_module_engine/stub/libinit.stub.json index efc74fbcc..e406f1c6b 100644 --- a/interfaces/innerkits/init_module_engine/stub/libinit.stub.json +++ b/interfaces/innerkits/init_module_engine/stub/libinit.stub.json @@ -6,6 +6,7 @@ { "name": "AddCmdExecutor" }, { "name": "RemoveCmdExecutor" }, { "name": "HookMgrAdd" }, + { "name": "HookMgrDel" }, { "name": "GetBootStageHookMgr"}, { "name": "InitAddGlobalInitHook" }, { "name": "InitAddPreParamServiceHook" }, @@ -14,6 +15,7 @@ { "name": "InitAddPostCfgLoadHook" }, { "name": "InitModuleMgrInstall" }, { "name": "InitModuleMgrUnInstall" }, + { "name": "AutorunModuleMgrUnInstall" }, { "name": "StartupLog" }, { "name": "DoJobNow" }, { "name": "GetServiceExtData" }, diff --git a/services/init/standard/init.c b/services/init/standard/init.c index ad637f72f..156c000d5 100755 --- a/services/init/standard/init.c +++ b/services/init/standard/init.c @@ -230,7 +230,7 @@ void SystemPrepare(void) // Make sure init log always output to /dev/kmsg. EnableDevKmsg(); INIT_LOGI("Start init first stage."); - HookMgrExecute(GetBootStageHookMgr(), INIT_PRE_PARAM_SERVICE, NULL, NULL); + HookMgrExecute(GetBootStageHookMgr(), INIT_FIRST_STAGE, NULL, NULL); // Only ohos normal system support // two stages of init. // If we are in updater mode, only one stage of init. diff --git a/services/modules/bootevent/bootevent.c b/services/modules/bootevent/bootevent.c index 058b853d5..c45373cb1 100755 --- a/services/modules/bootevent/bootevent.c +++ b/services/modules/bootevent/bootevent.c @@ -260,6 +260,7 @@ static void BootEventParaFireByName(const char *paramName) #ifndef STARTUP_INIT_TEST HookMgrExecute(GetBootStageHookMgr(), INIT_BOOT_COMPLETE, NULL, NULL); #endif + AutorunModuleMgrUnInstall("init_bootDetector"); return; }