Merge pull request #12693 from taosdata/fix/ZhiqiangWang/fix-15602-fix-file-path-format-error
fix(os): file path format error
This commit is contained in:
commit
a0710fdc01
|
@ -44,6 +44,7 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta) {
|
||||||
pMeta->path = (char *)&pMeta[1];
|
pMeta->path = (char *)&pMeta[1];
|
||||||
sprintf(pMeta->path, "%s%s%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path, TD_DIRSEP,
|
sprintf(pMeta->path, "%s%s%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path, TD_DIRSEP,
|
||||||
VNODE_META_DIR);
|
VNODE_META_DIR);
|
||||||
|
taosRealPath(pMeta->path, NULL, slen);
|
||||||
pMeta->pVnode = pVnode;
|
pMeta->pVnode = pVnode;
|
||||||
|
|
||||||
// create path if not created yet
|
// create path if not created yet
|
||||||
|
|
|
@ -55,6 +55,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee
|
||||||
memcpy(pTsdb->dir, dir, strlen(dir));
|
memcpy(pTsdb->dir, dir, strlen(dir));
|
||||||
pTsdb->path = (char *)&pTsdb[1];
|
pTsdb->path = (char *)&pTsdb[1];
|
||||||
sprintf(pTsdb->path, "%s%s%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path, TD_DIRSEP, dir);
|
sprintf(pTsdb->path, "%s%s%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path, TD_DIRSEP, dir);
|
||||||
|
taosRealPath(pTsdb->path, NULL, slen);
|
||||||
pTsdb->pVnode = pVnode;
|
pTsdb->pVnode = pVnode;
|
||||||
pTsdb->repoLocked = false;
|
pTsdb->repoLocked = false;
|
||||||
taosThreadMutexInit(&pTsdb->mutex, NULL);
|
taosThreadMutexInit(&pTsdb->mutex, NULL);
|
||||||
|
|
|
@ -109,6 +109,7 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
|
||||||
|
|
||||||
// open wal
|
// open wal
|
||||||
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_WAL_DIR);
|
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_WAL_DIR);
|
||||||
|
taosRealPath(tdir, NULL, sizeof(tdir));
|
||||||
pVnode->pWal = walOpen(tdir, &(pVnode->config.walCfg));
|
pVnode->pWal = walOpen(tdir, &(pVnode->config.walCfg));
|
||||||
if (pVnode->pWal == NULL) {
|
if (pVnode->pWal == NULL) {
|
||||||
vError("vgId:%d failed to open vnode wal since %s", TD_VID(pVnode), tstrerror(terrno));
|
vError("vgId:%d failed to open vnode wal since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
|
@ -117,6 +118,7 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
|
||||||
|
|
||||||
// open tq
|
// open tq
|
||||||
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_TQ_DIR);
|
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_TQ_DIR);
|
||||||
|
taosRealPath(tdir, NULL, sizeof(tdir));
|
||||||
pVnode->pTq = tqOpen(tdir, pVnode, pVnode->pWal);
|
pVnode->pTq = tqOpen(tdir, pVnode, pVnode->pWal);
|
||||||
if (pVnode->pTq == NULL) {
|
if (pVnode->pTq == NULL) {
|
||||||
vError("vgId:%d failed to open vnode tq since %s", TD_VID(pVnode), tstrerror(terrno));
|
vError("vgId:%d failed to open vnode tq since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
|
|
|
@ -160,7 +160,14 @@ bool tfsIsSameFile(const STfsFile *pFile1, const STfsFile *pFile2) {
|
||||||
if (pFile1 == NULL || pFile2 == NULL || pFile1->pTfs != pFile2->pTfs) return false;
|
if (pFile1 == NULL || pFile2 == NULL || pFile1->pTfs != pFile2->pTfs) return false;
|
||||||
if (pFile1->did.level != pFile2->did.level) return false;
|
if (pFile1->did.level != pFile2->did.level) return false;
|
||||||
if (pFile1->did.id != pFile2->did.id) return false;
|
if (pFile1->did.id != pFile2->did.id) return false;
|
||||||
if (strncmp(pFile1->rname, pFile2->rname, TSDB_FILENAME_LEN) != 0) return false;
|
char nameBuf1[TMPNAME_LEN], nameBuf2[TMPNAME_LEN];
|
||||||
|
strncpy(nameBuf1, pFile1->rname, TMPNAME_LEN);
|
||||||
|
strncpy(nameBuf2, pFile2->rname, TMPNAME_LEN);
|
||||||
|
nameBuf1[TMPNAME_LEN - 1] = 0;
|
||||||
|
nameBuf2[TMPNAME_LEN - 1] = 0;
|
||||||
|
taosRealPath(nameBuf1, NULL, TMPNAME_LEN);
|
||||||
|
taosRealPath(nameBuf2, NULL, TMPNAME_LEN);
|
||||||
|
if (strncmp(nameBuf1, nameBuf2, TMPNAME_LEN) != 0) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -183,6 +183,7 @@ SScript *simParseScript(char *fileName) {
|
||||||
strcpy(name, fileName);
|
strcpy(name, fileName);
|
||||||
} else {
|
} else {
|
||||||
sprintf(name, "%s" TD_DIRSEP "%s", simScriptDir, fileName);
|
sprintf(name, "%s" TD_DIRSEP "%s", simScriptDir, fileName);
|
||||||
|
taosRealPath(name, NULL, sizeof(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
// if ((fd = fopen(name, "r")) == NULL) {
|
// if ((fd = fopen(name, "r")) == NULL) {
|
||||||
|
|
Loading…
Reference in New Issue