未验证 提交 39632963 编写于 作者: O openharmony_ci 提交者: Gitee

!641 fix bootchart 功能

Merge pull request !641 from Mupceet/bootchart
......@@ -271,7 +271,7 @@ static int hookTraversalProc(ListNode *node, void *cookie)
if ((args != NULL) && (args->preHook != NULL)) {
args->preHook(&hookInfo);
}
hookInfo.retVal = hookItem->hook(hookInfo.stage, hookItem->prio, args->cookie);
hookInfo.retVal = hookItem->hook(hookInfo.stage, hookItem->prio, hookInfo.cookie);
if ((args != NULL) && (args->postHook != NULL)) {
args->postHook(&hookInfo);
}
......
......@@ -22,6 +22,7 @@
#include <dirent.h>
#include <linux/limits.h>
#include "beget_ext.h"
#include "list.h"
#include "securec.h"
#include "modulemgr.h"
......@@ -127,11 +128,13 @@ static void *moduleInstall(MODULE_ITEM *module, int argc, const char *argv[])
return NULL;
}
}
BEGET_LOGV("moduleInstall path %s", path);
currentInstallArgs = &(module->moduleMgr->installArgs);
handle = dlopen(path, RTLD_LAZY | RTLD_GLOBAL);
currentInstallArgs = NULL;
if (handle == NULL) {
BEGET_LOGE("moduleInstall path %s fail %d", path, errno);
}
return handle;
}
......
......@@ -29,7 +29,8 @@ enum INIT_BOOTSTAGE {
INIT_PRE_PARAM_SERVICE = 10,
INIT_PRE_PARAM_LOAD = 20,
INIT_PRE_CFG_LOAD = 30,
INIT_POST_CFG_LOAD = 40
INIT_POST_PERSIST_PARAM_LOAD = 40,
INIT_POST_CFG_LOAD = 50
};
inline int InitAddGlobalInitHook(int prio, OhosHook hook)
......@@ -57,6 +58,10 @@ inline int InitAddPostCfgLoadHook(int prio, OhosHook hook)
return HookMgrAdd(NULL, INIT_POST_CFG_LOAD, prio, hook);
}
inline int InitAddPostPersistParamLoadHook(int prio, OhosHook hook)
{
return HookMgrAdd(NULL, INIT_POST_PERSIST_PARAM_LOAD, prio, hook);
}
#ifdef __cplusplus
#if __cplusplus
}
......
......@@ -25,7 +25,7 @@ int InitModuleMgrInstall(const char *moduleName)
}
if (defaultModuleMgr == NULL) {
defaultModuleMgr = ModuleMgrCreate(moduleName);
defaultModuleMgr = ModuleMgrCreate("init");
}
if (defaultModuleMgr == NULL) {
return -1;
......@@ -43,8 +43,11 @@ static int ModuleMgrCmdInstall(int id, const char *name, int argc, const char **
{
INIT_ERROR_CHECK(argv != NULL && argc >= 1, return -1, "Invalid install parameter");
int ret;
ret = ModuleMgrInstall(NULL, argv[0], argc-1, argv+1);
INIT_ERROR_CHECK(ret == 0, return ret, "Install module %s fail", argv[0]);
if (defaultModuleMgr == NULL) {
defaultModuleMgr = ModuleMgrCreate("init");
}
ret = ModuleMgrInstall(defaultModuleMgr, argv[0], argc-1, argv+1);
INIT_ERROR_CHECK(ret == 0, return ret, "Install module %s fail errno %d", argv[0], ret);
return 0;
}
......
......@@ -253,6 +253,8 @@ static void BootStateChange(const char *content)
}
if (strcmp("post-init", content) == 0) {
StartAllServices(START_MODE_NARMAL);
// Destroy all hooks
HookMgrDestroy(NULL);
return;
}
}
......@@ -358,9 +360,6 @@ void SystemConfig(void)
INIT_LOGI("Parse init config file done.");
HookMgrExecute(NULL, INIT_POST_CFG_LOAD, (void *)&args);
// Destroy all hooks
HookMgrDestroy(NULL);
// dump config
#if defined(OHOS_SERVICE_DUMP)
AddCmdExecutor("display", SystemDump);
......
......@@ -29,8 +29,9 @@
#include <sys/sysmacros.h>
#include <sys/wait.h>
#include <unistd.h>
#include <linux/module.h>
#include "bootstage.h"
#include "fs_manager/fs_manager.h"
#include "init_jobs_internal.h"
#include "init_log.h"
......@@ -178,8 +179,9 @@ static void DoSetParam(const struct CmdArgs *ctx)
static void DoLoadPersistParams(const struct CmdArgs *ctx)
{
INIT_LOGV("load persist params : %s", ctx->argv[0]);
INIT_LOGV("LoadPersistParams");
LoadPersistParams();
HookMgrExecute(NULL, INIT_POST_PERSIST_PARAM_LOAD, NULL);
}
static void DoTriggerCmd(const struct CmdArgs *ctx)
......
......@@ -264,14 +264,45 @@ static int DoBootchartStop(void)
return 0;
}
static int DoBootchartCmd(int id, const char *name, int argc, const char **argv)
{
PLUGIN_LOGI("DoBootchartCmd argc %d %s", argc, name);
PLUGIN_CHECK(argc >= 1, return -1, "Invalid parameter");
if (strcmp(argv[0], "start") == 0) {
return DoBootchartStart();
} else if (strcmp(argv[0], "stop") == 0) {
return DoBootchartStop();
}
return 0;
}
static int32_t g_executorId = -1;
static int BootchartInit(void)
{
if (g_executorId == -1) {
g_executorId = AddCmdExecutor("bootchart", DoBootchartCmd);
PLUGIN_LOGI("BootchartInit executorId %d", g_executorId);
}
return 0;
}
static void BootchartExit(void)
{
PLUGIN_LOGI("BootchartExit executorId %d", g_executorId);
if (g_executorId != -1) {
RemoveCmdExecutor("bootchart", g_executorId);
}
}
MODULE_CONSTRUCTOR(void)
{
PLUGIN_LOGI("DoBootchartStart now ...");
DoBootchartStart();
BootchartInit();
}
MODULE_DESTRUCTOR(void)
{
PLUGIN_LOGI("DoBootchartStop now ...");
DoBootchartStop();
BootchartExit();
}
......@@ -34,5 +34,5 @@ static int bootchartEarlyHook(int stage, int prio, void *cookie)
MODULE_CONSTRUCTOR(void)
{
// Depends on parameter service
InitAddPreCfgLoadHook(0, bootchartEarlyHook);
InitAddPostPersistParamLoadHook(0, bootchartEarlyHook);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册