diff --git a/include/os/osDir.h b/include/os/osDir.h index d3597cab36..e7da54bf54 100644 --- a/include/os/osDir.h +++ b/include/os/osDir.h @@ -38,6 +38,7 @@ typedef struct TdDirEntry *TdDirEntryPtr; void taosRemoveDir(const char *dirname); bool taosDirExist(char *dirname); int32_t taosMkDir(const char *dirname); +int32_t taosMulMkDir(const char *dirname); void taosRemoveOldFiles(const char *dirname, int32_t keepDays); int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen); int32_t taosRealPath(char *dirname, int32_t maxlen); diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index df4433e6e4..58bc7235a1 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -616,7 +616,7 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi taosSetAllDebugFlag(cfgGetItem(pCfg, "debugFlag")->i32); - if (taosMkDir(tsLogDir) != 0) { + if (taosMulMkDir(tsLogDir) != 0) { uError("failed to create dir:%s since %s", tsLogDir, terrstr()); cfgCleanup(pCfg); return -1; diff --git a/source/os/src/osDir.c b/source/os/src/osDir.c index 383e1617cf..a955fb3b0a 100644 --- a/source/os/src/osDir.c +++ b/source/os/src/osDir.c @@ -68,6 +68,15 @@ void taosRemoveDir(const char *dirname) { bool taosDirExist(char *dirname) { return taosCheckExistFile(dirname); } int32_t taosMkDir(const char *dirname) { + int32_t code = mkdir(dirname, 0755); + if (code < 0 && errno == EEXIST) { + return 0; + } + + return code; +} + +int32_t taosMulMkDir(const char *dirname) { if (dirname == NULL) return -1; char *temp = strdup(dirname); char *pos = temp;