diff --git a/source/dnode/vnode/src/vnd/vnodeOpen.c b/source/dnode/vnode/src/vnd/vnodeOpen.c index 616aa39bdf4c41514cc133d7505a97e81a4e9f1c..ddd0f361940e77bf52c45fd1cdea9b4682d1e896 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; }