提交 71e4c419 编写于 作者: wafwerar's avatar wafwerar

[TD-13756]<fix>: file system remove func.

上级 1cdc5afe
......@@ -22,6 +22,7 @@ extern "C" {
#include "osSocket.h"
// If the error is in a third-party library, place this header file under the third-party library header file.
#ifndef ALLOW_FORBID_FUNC
#define open OPEN_FUNC_TAOS_FORBID
#define fopen FOPEN_FUNC_TAOS_FORBID
......@@ -31,6 +32,8 @@ extern "C" {
#define fstat FSTAT_FUNC_TAOS_FORBID
#define close CLOSE_FUNC_TAOS_FORBID
#define fclose FCLOSE_FUNC_TAOS_FORBID
#define fsync FSYNC_FUNC_TAOS_FORBID
// #define fflush FFLUSH_FUNC_TAOS_FORBID
#endif
#ifndef PATH_MAX
......@@ -47,7 +50,7 @@ typedef struct TdFile *TdFilePtr;
#define TD_FILE_TEXT 0x0020
#define TD_FILE_AUTO_DEL 0x0040
#define TD_FILE_EXCL 0x0080
#define TD_FILE_STREAM 0x0100 // Only support taosFprintfFile, taosGetLineFile, taosGetLineFile, taosEOFFile
#define TD_FILE_STREAM 0x0100 // Only support taosFprintfFile, taosGetLineFile, taosEOFFile
TdFilePtr taosOpenFile(const char *path,int32_t tdFileOptions);
#define TD_FILE_ACCESS_EXIST_OK 0x1
......@@ -80,6 +83,7 @@ int64_t taosCloseFile(TdFilePtr *ppFile);
int32_t taosRenameFile(const char *oldName, const char *newName);
int64_t taosCopyFile(const char *from, const char *to);
int32_t taosRemoveFile(const char *path);
void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, char *dstPath);
......
......@@ -46,7 +46,7 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
}
if (!autoDelete) {
remove(pTSBuf->path);
taosRemoveFile(pTSBuf->path);
}
if (NULL == allocResForTSBuf(pTSBuf)) {
......@@ -178,7 +178,7 @@ void* tsBufDestroy(STSBuf* pTSBuf) {
if (pTSBuf->autoDelete) {
// ("tsBuf %p destroyed, delete tmp file:%s", pTSBuf, pTSBuf->path);
remove(pTSBuf->path);
taosRemoveFile(pTSBuf->path);
} else {
// tscDebug("tsBuf %p destroyed, tmp file:%s, remains", pTSBuf, pTSBuf->path);
}
......
......@@ -1054,7 +1054,7 @@ int tsdbWriteBlockIdx(SDFile *pHeadf, SArray *pIdxA, void **ppBuf) {
// pfs->metaCacheComp = NULL;
// } else {
// // remove meta.tmp file
// remove(mf.f.aname);
// taosRemoveFile(mf.f.aname);
// taosHashCleanup(pfs->metaCacheComp);
// pfs->metaCacheComp = NULL;
// }
......
......@@ -439,7 +439,7 @@ static int tsdbSaveFSStatus(STsdb *pRepo, SFSStatus *pStatus) {
if (taosWriteFile(pFile, hbuf, TSDB_FILE_HEAD_SIZE) < TSDB_FILE_HEAD_SIZE) {
terrno = TAOS_SYSTEM_ERROR(errno);
taosCloseFile(&pFile);
remove(tfname);
taosRemoveFile(tfname);
return -1;
}
......@@ -447,7 +447,7 @@ static int tsdbSaveFSStatus(STsdb *pRepo, SFSStatus *pStatus) {
if (fsheader.len > 0) {
if (tsdbMakeRoom(&(pBuf), fsheader.len) < 0) {
taosCloseFile(&pFile);
remove(tfname);
taosRemoveFile(tfname);
return -1;
}
......@@ -458,7 +458,7 @@ static int tsdbSaveFSStatus(STsdb *pRepo, SFSStatus *pStatus) {
if (taosWriteFile(pFile, pBuf, fsheader.len) < fsheader.len) {
terrno = TAOS_SYSTEM_ERROR(errno);
taosCloseFile(&pFile);
(void)remove(tfname);
(void)taosRemoveFile(tfname);
taosTZfree(pBuf);
return -1;
}
......@@ -468,7 +468,7 @@ static int tsdbSaveFSStatus(STsdb *pRepo, SFSStatus *pStatus) {
if (taosFsyncFile(pFile) < 0) {
terrno = TAOS_SYSTEM_ERROR(errno);
taosCloseFile(&pFile);
remove(tfname);
taosRemoveFile(tfname);
taosTZfree(pBuf);
return -1;
}
......
......@@ -19,7 +19,7 @@ static std::string fileName = "/tmp/tindex.tindex";
class FstWriter {
public:
FstWriter() {
remove(fileName.c_str());
taosRemoveFile(fileName.c_str());
_wc = writerCtxCreate(TFile, fileName.c_str(), false, 64 * 1024 * 1024);
_b = fstBuilderCreate(_wc, 0);
}
......
......@@ -202,7 +202,7 @@ void tfsDirname(const STfsFile *pFile, char *dest) {
tstrncpy(dest, dirname(tname), TSDB_FILENAME_LEN);
}
int32_t tfsRemoveFile(const STfsFile *pFile) { return remove(pFile->aname); }
int32_t tfsRemoveFile(const STfsFile *pFile) { return taosRemoveFile(pFile->aname); }
int32_t tfsCopyFile(const STfsFile *pFile1, const STfsFile *pFile2) {
return taosCopyFile(pFile1->aname, pFile2->aname);
......
......@@ -192,7 +192,7 @@ int main(int argc, char *argv[]) {
if (pDataFile != NULL) {
taosCloseFile(&pDataFile);
remove(dataName);
taosRemoveFile(dataName);
}
return 0;
......
......@@ -181,7 +181,7 @@ int main(int argc, char *argv[]) {
if (pDataFile != NULL) {
taosCloseFile(&pDataFile);
remove(dataName);
taosRemoveFile(dataName);
}
return 0;
......
......@@ -379,7 +379,7 @@ int walSaveMeta(SWal* pWal) {
// delete old file
if (metaVer > -1) {
walBuildMetaName(pWal, metaVer, fnameStr);
remove(fnameStr);
taosRemoveFile(fnameStr);
}
free(serialized);
return 0;
......
......@@ -55,9 +55,9 @@ int32_t walRollback(SWal *pWal, int64_t ver) {
int fileSetSize = taosArrayGetSize(pWal->fileInfoSet);
for (int i = pWal->writeCur; i < fileSetSize; i++) {
walBuildLogName(pWal, ((SWalFileInfo *)taosArrayGet(pWal->fileInfoSet, i))->firstVer, fnameStr);
remove(fnameStr);
taosRemoveFile(fnameStr);
walBuildIdxName(pWal, ((SWalFileInfo *)taosArrayGet(pWal->fileInfoSet, i))->firstVer, fnameStr);
remove(fnameStr);
taosRemoveFile(fnameStr);
}
// pop from fileInfoSet
taosArraySetSize(pWal->fileInfoSet, pWal->writeCur + 1);
......@@ -174,9 +174,9 @@ int32_t walEndSnapshot(SWal *pWal) {
for (int i = 0; i < deleteCnt; i++) {
SWalFileInfo *pInfo = taosArrayGet(pWal->fileInfoSet, i);
walBuildLogName(pWal, pInfo->firstVer, fnameStr);
remove(fnameStr);
taosRemoveFile(fnameStr);
walBuildIdxName(pWal, pInfo->firstVer, fnameStr);
remove(fnameStr);
taosRemoveFile(fnameStr);
}
// make new array, remove files
......
......@@ -339,9 +339,9 @@ TEST_F(WalRetentionEnv, repairMeta1) {
//getchar();
char buf[100];
sprintf(buf, "%s/meta-ver%d", pathName, 0);
remove(buf);
taosRemoveFile(buf);
sprintf(buf, "%s/meta-ver%d", pathName, 1);
remove(buf);
taosRemoveFile(buf);
SetUp();
//getchar();
......
......@@ -49,7 +49,7 @@ void taosRemoveDir(const char *dirname) {
if (de->d_type & DT_DIR) {
taosRemoveDir(filename);
} else {
(void)remove(filename);
(void)taosRemoveFile(filename);
//printf("file:%s is removed\n", filename);
}
}
......@@ -102,7 +102,7 @@ void taosRemoveOldFiles(const char *dirname, int32_t keepDays) {
if (fileSec <= 100) continue;
int32_t days = (int32_t)(TABS(sec - fileSec) / 86400 + 1);
if (days > keepDays) {
(void)remove(filename);
(void)taosRemoveFile(filename);
//printf("file:%s is removed, days:%d keepDays:%d", filename, days, keepDays);
} else {
//printf("file:%s won't be removed, days:%d keepDays:%d", filename, days, keepDays);
......
......@@ -142,11 +142,13 @@ int64_t taosCopyFile(const char *from, const char *to) {
_err:
if (pFileFrom != NULL) taosCloseFile(&pFileFrom);
if (pFileTo != NULL) taosCloseFile(&pFileTo);
remove(to);
taosRemoveFile(to);
return -1;
#endif
}
int32_t taosRemoveFile(const char *path) { return remove(path); }
int32_t taosRenameFile(const char *oldName, const char *newName) {
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
int32_t code = MoveFileEx(oldName, newName, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED);
......
......@@ -180,7 +180,7 @@ static void taosKeepOldLog(char *oldName) {
char compressFileName[LOG_FILE_NAME_LEN + 20];
snprintf(compressFileName, LOG_FILE_NAME_LEN + 20, "%s.%" PRId64 ".gz", tsLogObj.logName, fileSec);
if (taosCompressFile(fileName, compressFileName) == 0) {
(void)remove(fileName);
(void)taosRemoveFile(fileName);
}
}
......@@ -251,7 +251,7 @@ void taosResetLog() {
tsLogObj.lines = tsLogObj.maxLines + 10;
taosOpenNewLogFile();
(void)remove(lastName);
(void)taosRemoveFile(lastName);
uInfo("==================================");
uInfo(" reset log file ");
......
......@@ -563,7 +563,7 @@ void destroyDiskbasedBuf(SDiskbasedBuf* pBuf) {
ps->loadPages, ps->loadBytes / (1024.0 * ps->loadPages));
}
remove(pBuf->path);
taosRemoveFile(pBuf->path);
tfree(pBuf->path);
SArray** p = taosHashIterate(pBuf->groupSet, NULL);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册