From 4eecd7fd4a250262ce1d696165c1749b8117fc5f Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 10 Oct 2022 18:17:58 +0800 Subject: [PATCH] more code --- source/dnode/vnode/src/vnd/vnodeOpen.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/source/dnode/vnode/src/vnd/vnodeOpen.c b/source/dnode/vnode/src/vnd/vnodeOpen.c index 616aa39bdf..ddd0f36194 100644 --- a/source/dnode/vnode/src/vnd/vnodeOpen.c +++ b/source/dnode/vnode/src/vnd/vnodeOpen.c @@ -28,13 +28,24 @@ int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) { } // create vnode env - if (tfsMkdirAt(pTfs, path, (SDiskID){0}) < 0) { - vError("vgId:%d, failed to create vnode since:%s", pCfg->vgId, tstrerror(terrno)); - return -1; + if (pTfs) { + if (tfsMkdirAt(pTfs, path, (SDiskID){0}) < 0) { + vError("vgId:%d, failed to create vnode since:%s", pCfg->vgId, tstrerror(terrno)); + return -1; + } + snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pTfs), TD_DIRSEP, path); + } else { + if (taosMkDir(path)) { + return TAOS_SYSTEM_ERROR(errno); + } + strcpy(dir, path); + } + + if (pCfg) { + info.config = *pCfg; + } else { + info.config = vnodeCfgDefault; } - - snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pTfs), TD_DIRSEP, path); - info.config = *pCfg; info.state.committed = -1; info.state.applied = -1; info.state.commitID = 0; @@ -44,7 +55,7 @@ int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) { return -1; } - vInfo("vgId:%d, vnode is created", pCfg->vgId); + vInfo("vgId:%d, vnode is created", info.config.vgId); return 0; } -- GitLab