Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
35b3edae
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
35b3edae
编写于
3月 04, 2022
作者:
wafwerar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-13756]<fix>: file system stat access func.
上级
d9072005
变更
42
隐藏空白更改
内联
并排
Showing
42 changed file
with
220 addition
and
183 deletion
+220
-183
include/os/osDir.h
include/os/osDir.h
+1
-1
include/os/osFile.h
include/os/osFile.h
+17
-7
source/common/test/commonTests.cpp
source/common/test/commonTests.cpp
+2
-2
source/common/test/tmsgTest.cpp
source/common/test/tmsgTest.cpp
+1
-1
source/dnode/vnode/src/tq/tqMetaStore.c
source/dnode/vnode/src/tq/tqMetaStore.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+2
-2
source/dnode/vnode/src/tsdb/tsdbFS.c
source/dnode/vnode/src/tsdb/tsdbFS.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbFile.c
source/dnode/vnode/src/tsdb/tsdbFile.c
+7
-8
source/libs/CMakeLists.txt
source/libs/CMakeLists.txt
+0
-1
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+3
-3
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+4
-4
source/libs/executor/test/executorTests.cpp
source/libs/executor/test/executorTests.cpp
+3
-3
source/libs/executor/test/sortTests.cpp
source/libs/executor/test/sortTests.cpp
+1
-1
source/libs/index/src/index_fst_counting_writer.c
source/libs/index/src/index_fst_counting_writer.c
+10
-8
source/libs/parser/test/mockCatalog.cpp
source/libs/parser/test/mockCatalog.cpp
+2
-4
source/libs/parser/test/parserTests.cpp
source/libs/parser/test/parserTests.cpp
+2
-2
source/libs/parser/test/plannerTest.cpp
source/libs/parser/test/plannerTest.cpp
+1
-1
source/libs/qworker/test/qworkerTests.cpp
source/libs/qworker/test/qworkerTests.cpp
+2
-2
source/libs/scalar/test/filter/filterTests.cpp
source/libs/scalar/test/filter/filterTests.cpp
+2
-2
source/libs/scalar/test/scalar/scalarTests.cpp
source/libs/scalar/test/scalar/scalarTests.cpp
+2
-2
source/libs/scheduler/test/schedulerTests.cpp
source/libs/scheduler/test/schedulerTests.cpp
+11
-11
source/libs/sync/test/syncIOSendMsgClientTest.cpp
source/libs/sync/test/syncIOSendMsgClientTest.cpp
+1
-1
source/libs/sync/test/syncIOSendMsgServerTest.cpp
source/libs/sync/test/syncIOSendMsgServerTest.cpp
+1
-1
source/libs/sync/test/syncIOSendMsgTest.cpp
source/libs/sync/test/syncIOSendMsgTest.cpp
+1
-1
source/libs/sync/test/syncIOTickPingTest.cpp
source/libs/sync/test/syncIOTickPingTest.cpp
+1
-1
source/libs/sync/test/syncIOTickQTest.cpp
source/libs/sync/test/syncIOTickQTest.cpp
+1
-1
source/libs/sync/test/syncRaftStoreTest.cpp
source/libs/sync/test/syncRaftStoreTest.cpp
+2
-2
source/libs/sync/test/syncTest.cpp
source/libs/sync/test/syncTest.cpp
+1
-1
source/libs/tdb/src/db/tdb.c
source/libs/tdb/src/db/tdb.c
+1
-1
source/libs/tdb/src/db/tdbUtil.c
source/libs/tdb/src/db/tdbUtil.c
+21
-22
source/libs/tdb/src/inc/tdbUtil.h
source/libs/tdb/src/inc/tdbUtil.h
+4
-4
source/libs/tdb/test/tdbTest.cpp
source/libs/tdb/test/tdbTest.cpp
+1
-1
source/libs/tfs/src/tfs.c
source/libs/tfs/src/tfs.c
+2
-9
source/libs/tfs/test/tfsTest.cpp
source/libs/tfs/test/tfsTest.cpp
+49
-49
source/libs/wal/src/walMeta.c
source/libs/wal/src/walMeta.c
+11
-11
source/os/src/osDir.c
source/os/src/osDir.c
+1
-1
source/os/src/osFile.c
source/os/src/osFile.c
+39
-0
source/util/test/cacheTest.cpp
source/util/test/cacheTest.cpp
+1
-1
source/util/test/encodeTest.cpp
source/util/test/encodeTest.cpp
+1
-1
source/util/test/freelistTest.cpp
source/util/test/freelistTest.cpp
+1
-1
source/util/test/hashTest.cpp
source/util/test/hashTest.cpp
+2
-2
tools/shell/src/backup/shellImport.c
tools/shell/src/backup/shellImport.c
+3
-5
未找到文件。
include/os/osDir.h
浏览文件 @
35b3edae
...
...
@@ -21,7 +21,7 @@ extern "C" {
#endif
void
taosRemoveDir
(
const
char
*
dirname
);
int32_t
taosDirExist
(
char
*
dirname
);
bool
taosDirExist
(
char
*
dirname
);
int32_t
taosMkDir
(
const
char
*
dirname
);
void
taosRemoveOldFiles
(
const
char
*
dirname
,
int32_t
keepDays
);
int32_t
taosExpandDir
(
const
char
*
dirname
,
char
*
outname
,
int32_t
maxlen
);
...
...
include/os/osFile.h
浏览文件 @
35b3edae
...
...
@@ -25,8 +25,12 @@ extern "C" {
#ifndef ALLOW_FORBID_FUNC
#define open OPEN_FUNC_TAOS_FORBID
#define fopen FOPEN_FUNC_TAOS_FORBID
// #define close CLOSE_FUNC_TAOS_FORBID
// #define fclose FCLOSE_FUNC_TAOS_FORBID
#define access ACCESS_FUNC_TAOS_FORBID
#define stat STAT_FUNC_TAOS_FORBID
#define lstat LSTAT_FUNC_TAOS_FORBID
#define fstat FSTAT_FUNC_TAOS_FORBID
#define close CLOSE_FUNC_TAOS_FORBID
#define fclose FCLOSE_FUNC_TAOS_FORBID
#endif
#ifndef PATH_MAX
...
...
@@ -44,6 +48,12 @@ typedef struct TdFile *TdFilePtr;
#define TD_FILE_AUTO_DEL 0x0040
#define TD_FILE_EXCL 0x0080
#define TD_FILE_STREAM 0x0100 // Only support taosFprintfFile, taosGetLineFile, taosGetLineFile, taosEOFFile
TdFilePtr
taosOpenFile
(
const
char
*
path
,
int32_t
tdFileOptions
);
#define TD_FILE_ACCESS_EXIST_OK 0x1
#define TD_FILE_ACCESS_READ_OK 0x2
#define TD_FILE_ACCESS_WRITE_OK 0x4
bool
taosCheckAccessFile
(
const
char
*
pathname
,
int
mode
);
int32_t
taosLockFile
(
TdFilePtr
pFile
);
int32_t
taosUnLockFile
(
TdFilePtr
pFile
);
...
...
@@ -51,9 +61,9 @@ int32_t taosUnLockFile(TdFilePtr pFile);
int32_t
taosUmaskFile
(
int32_t
maskVal
);
int32_t
taosStatFile
(
const
char
*
path
,
int64_t
*
size
,
int32_t
*
mtime
);
int32_t
taosDevInoFile
(
const
char
*
path
,
int64_t
*
stDev
,
int64_t
*
stIno
);
int32_t
taosFStatFile
(
TdFilePtr
pFile
,
int64_t
*
size
,
int32_t
*
mtime
);
TdFilePtr
taosOpenFile
(
const
char
*
path
,
int32_t
tdFileOptions
);
bool
taosCheckExistFile
(
const
char
*
pathname
);
int64_t
taosLSeekFile
(
TdFilePtr
pFile
,
int64_t
offset
,
int32_t
whence
);
int32_t
taosFtruncateFile
(
TdFilePtr
pFile
,
int64_t
length
);
...
...
@@ -62,7 +72,7 @@ int32_t taosFsyncFile(TdFilePtr pFile);
int64_t
taosReadFile
(
TdFilePtr
pFile
,
void
*
buf
,
int64_t
count
);
int64_t
taosPReadFile
(
TdFilePtr
pFile
,
void
*
buf
,
int64_t
count
,
int64_t
offset
);
int64_t
taosWriteFile
(
TdFilePtr
pFile
,
const
void
*
buf
,
int64_t
count
);
void
taosFprintfFile
(
TdFilePtr
pFile
,
const
char
*
format
,
...);
void
taosFprintfFile
(
TdFilePtr
pFile
,
const
char
*
format
,
...);
int64_t
taosGetLineFile
(
TdFilePtr
pFile
,
char
**
__restrict__
ptrBuf
);
int32_t
taosEOFFile
(
TdFilePtr
pFile
);
...
...
@@ -71,7 +81,7 @@ int64_t taosCloseFile(TdFilePtr *ppFile);
int32_t
taosRenameFile
(
const
char
*
oldName
,
const
char
*
newName
);
int64_t
taosCopyFile
(
const
char
*
from
,
const
char
*
to
);
void
taosGetTmpfilePath
(
const
char
*
inputTmpDir
,
const
char
*
fileNamePrefix
,
char
*
dstPath
);
void
taosGetTmpfilePath
(
const
char
*
inputTmpDir
,
const
char
*
fileNamePrefix
,
char
*
dstPath
);
int64_t
taosSendFile
(
SocketFd
fdDst
,
TdFilePtr
pFileSrc
,
int64_t
*
offset
,
int64_t
size
);
int64_t
taosFSendFile
(
TdFilePtr
pFileOut
,
TdFilePtr
pFileIn
,
int64_t
*
offset
,
int64_t
size
);
...
...
@@ -79,7 +89,7 @@ int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, in
void
*
taosMmapReadOnlyFile
(
TdFilePtr
pFile
,
int64_t
length
);
bool
taosValidFile
(
TdFilePtr
pFile
);
int
taosGetErrorFile
(
TdFilePtr
pFile
);
int
32_t
taosGetErrorFile
(
TdFilePtr
pFile
);
#ifdef __cplusplus
}
...
...
source/common/test/commonTests.cpp
浏览文件 @
35b3edae
#include "tcommon.h"
#include <gtest/gtest.h>
#include <tep.h>
#include <iostream>
#pragma GCC diagnostic push
...
...
@@ -10,6 +8,8 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "os.h"
#include "tep.h"
#include "tcommon.h"
#include "taos.h"
#include "tvariant.h"
#include "tdef.h"
...
...
source/common/test/tmsgTest.cpp
浏览文件 @
35b3edae
#include <iostream>
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "tmsg.h"
...
...
source/dnode/vnode/src/tq/tqMetaStore.c
浏览文件 @
35b3edae
...
...
@@ -90,7 +90,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
char
name
[
pathLen
+
10
];
strcpy
(
name
,
path
);
if
(
taosDirExist
(
name
)
!=
0
&&
taosMkDir
(
name
)
!=
0
)
{
if
(
!
taosDirExist
(
name
)
&&
taosMkDir
(
name
)
!=
0
)
{
terrno
=
TSDB_CODE_TQ_FAILED_TO_CREATE_DIR
;
tqError
(
"failed to create dir:%s since %s "
,
name
,
terrstr
());
}
...
...
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
35b3edae
...
...
@@ -580,7 +580,7 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
SDFile
*
pRSmadF
=
TSDB_READ_SMAD_FILE
(
&
(
pCommith
->
readh
));
SDFile
*
pWSmadF
=
TSDB_COMMIT_SMAD_FILE
(
pCommith
);
if
(
access
(
TSDB_FILE_FULL_NAME
(
pRSmadF
),
F_OK
)
!=
0
)
{
if
(
!
taosCheckExistFile
(
TSDB_FILE_FULL_NAME
(
pRSmadF
))
)
{
tsdbDebug
(
"vgId:%d create data file %s as not exist"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pRSmadF
));
tsdbInitDFile
(
pRepo
,
pWSmadF
,
did
,
fid
,
FS_TXN_VERSION
(
REPO_FS
(
pRepo
)),
TSDB_FILE_SMAD
);
...
...
@@ -614,7 +614,7 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
SDFile
*
pRSmalF
=
TSDB_READ_SMAL_FILE
(
&
(
pCommith
->
readh
));
SDFile
*
pWSmalF
=
TSDB_COMMIT_SMAL_FILE
(
pCommith
);
if
((
pCommith
->
isLFileSame
)
&&
access
(
TSDB_FILE_FULL_NAME
(
pRSmalF
),
F_OK
)
==
0
)
{
if
((
pCommith
->
isLFileSame
)
&&
taosCheckExistFile
(
TSDB_FILE_FULL_NAME
(
pRSmalF
))
)
{
tsdbInitDFileEx
(
pWSmalF
,
pRSmalF
);
if
(
tsdbOpenDFile
(
pWSmalF
,
O_RDWR
)
<
0
)
{
tsdbError
(
"vgId:%d failed to open file %s to commit since %s"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pWSmalF
),
...
...
source/dnode/vnode/src/tsdb/tsdbFS.c
浏览文件 @
35b3edae
...
...
@@ -314,7 +314,7 @@ int tsdbOpenFS(STsdb *pRepo) {
tsdbGetTxnFname
(
pRepo
,
TSDB_TXN_CURR_FILE
,
current
);
tsdbGetRtnSnap
(
pRepo
,
&
pRepo
->
rtn
);
if
(
access
(
current
,
F_OK
)
==
0
)
{
if
(
taosCheckExistFile
(
current
)
)
{
if
(
tsdbOpenFSFromCurrent
(
pRepo
)
<
0
)
{
tsdbError
(
"vgId:%d failed to open FS since %s"
,
REPO_ID
(
pRepo
),
tstrerror
(
terrno
));
return
-
1
;
...
...
source/dnode/vnode/src/tsdb/tsdbFile.c
浏览文件 @
35b3edae
...
...
@@ -443,25 +443,24 @@ int tsdbLoadDFileHeader(SDFile *pDFile, SDFInfo *pInfo) {
}
static
int
tsdbScanAndTryFixDFile
(
STsdb
*
pRepo
,
SDFile
*
pDFile
)
{
struct
stat
dfstat
;
SDFile
df
;
tsdbInitDFileEx
(
&
df
,
pDFile
);
if
(
access
(
TSDB_FILE_FULL_NAME
(
pDFile
),
F_OK
)
!=
0
)
{
if
(
!
taosCheckExistFile
(
TSDB_FILE_FULL_NAME
(
pDFile
))
)
{
tsdbError
(
"vgId:%d data file %s not exit, report to upper layer to fix it"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pDFile
));
// pRepo->state |= TSDB_STATE_BAD_DATA;
TSDB_FILE_SET_STATE
(
pDFile
,
TSDB_FILE_STATE_BAD
);
return
0
;
}
if
(
stat
(
TSDB_FILE_FULL_NAME
(
&
df
),
&
dfstat
)
<
0
)
{
int64_t
file_size
=
0
;
if
(
taosStatFile
(
TSDB_FILE_FULL_NAME
(
&
df
),
&
file_size
,
NULL
)
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
if
(
pDFile
->
info
.
size
<
dfstat
.
st
_size
)
{
if
(
pDFile
->
info
.
size
<
file
_size
)
{
// if (tsdbOpenDFile(&df, O_WRONLY) < 0) {
if
(
tsdbOpenDFile
(
&
df
,
TD_FILE_WRITE
)
<
0
)
{
return
-
1
;
...
...
@@ -480,10 +479,10 @@ static int tsdbScanAndTryFixDFile(STsdb *pRepo, SDFile *pDFile) {
tsdbCloseDFile
(
&
df
);
tsdbInfo
(
"vgId:%d file %s is truncated from %"
PRId64
" to %"
PRId64
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pDFile
),
dfstat
.
st
_size
,
pDFile
->
info
.
size
);
}
else
if
(
pDFile
->
info
.
size
>
dfstat
.
st
_size
)
{
file
_size
,
pDFile
->
info
.
size
);
}
else
if
(
pDFile
->
info
.
size
>
file
_size
)
{
tsdbError
(
"vgId:%d data file %s has wrong size %"
PRId64
" expected %"
PRId64
", report to upper layer to fix it"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pDFile
),
dfstat
.
st
_size
,
pDFile
->
info
.
size
);
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pDFile
),
file
_size
,
pDFile
->
info
.
size
);
// pRepo->state |= TSDB_STATE_BAD_DATA;
TSDB_FILE_SET_STATE
(
pDFile
,
TSDB_FILE_STATE_BAD
);
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
...
...
source/libs/CMakeLists.txt
浏览文件 @
35b3edae
add_definitions
(
"-D ALLOW_FORBID_FUNC"
)
add_subdirectory
(
transport
)
add_subdirectory
(
sync
)
add_subdirectory
(
tdb
)
...
...
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
35b3edae
...
...
@@ -14,9 +14,7 @@
*/
#include <gtest/gtest.h>
#include <tglobal.h>
#include <iostream>
#include "os.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wwrite-strings"
...
...
@@ -24,8 +22,10 @@
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wformat"
#include <addr_any.h>
#include "addr_any.h"
#include "os.h"
#include "tglobal.h"
#include "catalog.h"
#include "stub.h"
#include "taos.h"
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
35b3edae
...
...
@@ -2215,10 +2215,10 @@ static void destroyTsComp(STaskRuntimeEnv *pRuntimeEnv, STaskAttr *pQueryAttr) {
if
(
pQueryAttr
->
tsCompQuery
&&
pRuntimeEnv
->
outputBuf
&&
pRuntimeEnv
->
outputBuf
->
pDataBlock
&&
taosArrayGetSize
(
pRuntimeEnv
->
outputBuf
->
pDataBlock
)
>
0
)
{
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pRuntimeEnv
->
outputBuf
->
pDataBlock
,
0
);
if
(
pColInfoData
)
{
FILE
*
f
=
*
(
FILE
*
*
)
pColInfoData
->
pData
;
// TODO refactor
if
(
f
)
{
fclose
(
f
);
*
(
FILE
*
*
)
pColInfoData
->
pData
=
NULL
;
TdFilePtr
pFile
=
*
(
TdFilePtr
*
)
pColInfoData
->
pData
;
// TODO refactor
if
(
pFile
!=
NULL
)
{
taosCloseFile
(
&
pFile
);
*
(
TdFilePtr
*
)
pColInfoData
->
pData
=
NULL
;
}
}
}
...
...
source/libs/executor/test/executorTests.cpp
浏览文件 @
35b3edae
...
...
@@ -13,10 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <executorimpl.h>
#include <function.h>
#include <gtest/gtest.h>
#include <tglobal.h>
#include <iostream>
#pragma GCC diagnostic push
...
...
@@ -26,6 +23,9 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "os.h"
#include "tglobal.h"
#include "executorimpl.h"
#include "function.h"
#include "taos.h"
#include "tdef.h"
#include "tvariant.h"
...
...
source/libs/executor/test/sortTests.cpp
浏览文件 @
35b3edae
...
...
@@ -13,7 +13,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <executorimpl.h>
#include <gtest/gtest.h>
#include <tglobal.h>
#include <tsort.h>
...
...
@@ -26,6 +25,7 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "os.h"
#include "executorimpl.h"
#include "executor.h"
#include "stub.h"
#include "taos.h"
...
...
source/libs/index/src/index_fst_counting_writer.c
浏览文件 @
35b3edae
...
...
@@ -63,9 +63,9 @@ static int writeCtxDoReadFrom(WriterCtx* ctx, uint8_t* buf, int len, int32_t off
}
static
int
writeCtxGetSize
(
WriterCtx
*
ctx
)
{
if
(
ctx
->
type
==
TFile
)
{
struct
stat
fstat
;
stat
(
ctx
->
file
.
buf
,
&
fstat
);
return
fstat
.
st
_size
;
int64_t
file_size
=
0
;
taosStatFile
(
ctx
->
file
.
buf
,
&
file_size
,
NULL
);
return
(
int
)
file
_size
;
}
return
0
;
}
...
...
@@ -99,9 +99,9 @@ WriterCtx* writerCtxCreate(WriterType type, const char* path, bool readOnly, int
// ctx->file.pFile = open(path, O_RDONLY, S_IRWXU | S_IRWXG | S_IRWXO);
ctx
->
file
.
pFile
=
taosOpenFile
(
path
,
TD_FILE_READ
);
struct
stat
fstat
;
stat
(
path
,
&
fstat
);
ctx
->
file
.
size
=
fstat
.
st
_size
;
int64_t
file_size
=
0
;
taosFStatFile
(
ctx
->
file
.
pFile
,
&
file_size
,
NULL
);
ctx
->
file
.
size
=
(
int
)
file
_size
;
#ifdef USE_MMAP
ctx
->
file
.
ptr
=
(
char
*
)
tfMmapReadOnly
(
ctx
->
file
.
pFile
,
ctx
->
file
.
size
);
#endif
...
...
@@ -142,8 +142,10 @@ void writerCtxDestroy(WriterCtx* ctx, bool remove) {
#endif
}
if
(
ctx
->
file
.
readOnly
==
false
)
{
struct
stat
fstat
;
stat
(
ctx
->
file
.
buf
,
&
fstat
);
int64_t
file_size
=
0
;
taosStatFile
(
ctx
->
file
.
buf
,
&
file_size
,
NULL
);
// struct stat fstat;
// stat(ctx->file.buf, &fstat);
// indexError("write file size: %d", (int)(fstat.st_size));
}
if
(
remove
)
{
unlink
(
ctx
->
file
.
buf
);
}
...
...
source/libs/parser/test/mockCatalog.cpp
浏览文件 @
35b3edae
...
...
@@ -13,19 +13,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "mockCatalog.h"
#include <iostream>
#include "stub.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat"
#include
"addr_any.h"
#include
<addr_any.h>
#pragma GCC diagnostic pop
#include "mockCatalog.h"
namespace
{
void
generateTestT1
(
MockCatalogService
*
mcs
)
{
...
...
source/libs/parser/test/parserTests.cpp
浏览文件 @
35b3edae
...
...
@@ -13,10 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <function.h>
#include <gtest/gtest.h>
#include <iostream>
#include "tglobal.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wwrite-strings"
...
...
@@ -25,6 +23,8 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "os.h"
#include "function.h"
#include "tglobal.h"
#include "astGenerator.h"
#include "parserInt.h"
#include "taos.h"
...
...
source/libs/parser/test/plannerTest.cpp
浏览文件 @
35b3edae
...
...
@@ -13,7 +13,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <function.h>
#include <gtest/gtest.h>
#include <tglobal.h>
#include <iostream>
...
...
@@ -25,6 +24,7 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "os.h"
#include "function.h"
#include "astGenerator.h"
#include "parserInt.h"
#include "taos.h"
...
...
source/libs/qworker/test/qworkerTests.cpp
浏览文件 @
35b3edae
...
...
@@ -14,7 +14,6 @@
*/
#include <gtest/gtest.h>
#include <tglobal.h>
#include <iostream>
#pragma GCC diagnostic push
...
...
@@ -26,9 +25,11 @@
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
#pragma GCC diagnostic ignored "-Wpointer-arith"
#include <addr_any.h>
#include "os.h"
#include "tglobal.h"
#include "taos.h"
#include "tdef.h"
#include "tvariant.h"
...
...
@@ -37,7 +38,6 @@
#include "planner.h"
#include "qworker.h"
#include "stub.h"
#include "addr_any.h"
#include "executor.h"
#include "dataSinkMgt.h"
...
...
source/libs/scalar/test/filter/filterTests.cpp
浏览文件 @
35b3edae
...
...
@@ -14,7 +14,6 @@
*/
#include <gtest/gtest.h>
#include <tglobal.h>
#include <iostream>
#pragma GCC diagnostic push
...
...
@@ -26,15 +25,16 @@
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
#pragma GCC diagnostic ignored "-Wpointer-arith"
#include <addr_any.h>
#include "os.h"
#include "tglobal.h"
#include "taos.h"
#include "tdef.h"
#include "tvariant.h"
#include "tep.h"
#include "stub.h"
#include "addr_any.h"
#include "scalar.h"
#include "nodes.h"
#include "tlog.h"
...
...
source/libs/scalar/test/scalar/scalarTests.cpp
浏览文件 @
35b3edae
...
...
@@ -14,7 +14,6 @@
*/
#include <gtest/gtest.h>
#include <tglobal.h>
#include <iostream>
#pragma GCC diagnostic push
...
...
@@ -26,15 +25,16 @@
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
#pragma GCC diagnostic ignored "-Wpointer-arith"
#include <addr_any.h>
#include "os.h"
#include "tglobal.h"
#include "taos.h"
#include "tdef.h"
#include "tvariant.h"
#include "tep.h"
#include "stub.h"
#include "addr_any.h"
#include "scalar.h"
#include "nodes.h"
#include "tlog.h"
...
...
source/libs/scheduler/test/schedulerTests.cpp
浏览文件 @
35b3edae
...
...
@@ -14,11 +14,21 @@
*/
#include <gtest/gtest.h>
#include <tglobal.h>
#include <iostream>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wwrite-strings"
#pragma GCC diagnostic ignored "-Wunused-function"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wreturn-type"
#pragma GCC diagnostic ignored "-Wformat"
#include <addr_any.h>
#include "os.h"
#include "tglobal.h"
#include "taos.h"
#include "tdef.h"
#include "tvariant.h"
...
...
@@ -26,18 +36,8 @@
#include "scheduler.h"
#include "tep.h"
#include "trpc.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wwrite-strings"
#pragma GCC diagnostic ignored "-Wunused-function"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wreturn-type"
#pragma GCC diagnostic ignored "-Wformat"
#include "schedulerInt.h"
#include "stub.h"
#include "addr_any.h"
#include "tref.h"
namespace
{
...
...
source/libs/sync/test/syncIOSendMsgClientTest.cpp
浏览文件 @
35b3edae
#include <stdio.h>
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "syncIO.h"
#include "syncInt.h"
#include "syncRaftStore.h"
...
...
source/libs/sync/test/syncIOSendMsgServerTest.cpp
浏览文件 @
35b3edae
#include <stdio.h>
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "syncIO.h"
#include "syncInt.h"
#include "syncRaftStore.h"
...
...
source/libs/sync/test/syncIOSendMsgTest.cpp
浏览文件 @
35b3edae
#include <stdio.h>
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "syncIO.h"
#include "syncInt.h"
#include "syncRaftStore.h"
...
...
source/libs/sync/test/syncIOTickPingTest.cpp
浏览文件 @
35b3edae
#include <stdio.h>
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "syncIO.h"
#include "syncInt.h"
#include "syncRaftStore.h"
...
...
source/libs/sync/test/syncIOTickQTest.cpp
浏览文件 @
35b3edae
#include <stdio.h>
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "syncIO.h"
#include "syncInt.h"
#include "syncRaftStore.h"
...
...
source/libs/sync/test/syncRaftStoreTest.cpp
浏览文件 @
35b3edae
#include "syncRaftStore.h"
#include <stdio.h>
#include "gtest/gtest.h"
#include <gtest/gtest.h>
#include "syncRaftStore.h"
#include "syncIO.h"
#include "syncInt.h"
...
...
source/libs/sync/test/syncTest.cpp
浏览文件 @
35b3edae
#include <stdio.h>
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "syncIO.h"
#include "syncInt.h"
#include "syncRaftStore.h"
...
...
source/libs/tdb/src/db/tdb.c
浏览文件 @
35b3edae
...
...
@@ -90,7 +90,7 @@ int tdbOpen(TDB *pDb, const char *fname, const char *dbname, TENV *pEnv) {
// get page file from the env, if not opened yet, open it
pPgFile
=
NULL
;
snprintf
(
dbfname
,
128
,
"%s/%s"
,
tdbEnvGetRootDir
(
pEnv
),
fname
);
fileExist
=
(
tdbCheckFileAccess
(
fname
,
TDB_F_OK
)
==
0
);
fileExist
=
taosCheckExistFile
(
fname
);
if
(
fileExist
)
{
tdbGnrtFileID
(
dbfname
,
fileid
,
false
);
pPgFile
=
tdbEnvGetPageFile
(
pEnv
,
fileid
);
...
...
source/libs/tdb/src/db/tdbUtil.c
浏览文件 @
35b3edae
...
...
@@ -16,16 +16,16 @@
#include "tdbInt.h"
int
tdbGnrtFileID
(
const
char
*
fname
,
uint8_t
*
fileid
,
bool
unique
)
{
struct
stat
statbuf
;
int64_t
stDev
=
0
,
stIno
=
0
;
if
(
stat
(
fname
,
&
statbuf
)
<
0
)
{
if
(
taosDevInoFile
(
fname
,
&
stDev
,
&
stIno
)
<
0
)
{
return
-
1
;
}
memset
(
fileid
,
0
,
TDB_FILE_ID_LEN
);
((
uint64_t
*
)
fileid
)[
0
]
=
(
uint64_t
)
statbuf
.
st_ino
;
((
uint64_t
*
)
fileid
)[
1
]
=
(
uint64_t
)
statbuf
.
st_dev
;
((
uint64_t
*
)
fileid
)[
0
]
=
stDev
;
((
uint64_t
*
)
fileid
)[
1
]
=
stIno
;
if
(
unique
)
{
((
uint64_t
*
)
fileid
)[
2
]
=
rand
();
}
...
...
@@ -33,35 +33,34 @@ int tdbGnrtFileID(const char *fname, uint8_t *fileid, bool unique) {
return
0
;
}
int
tdbCheckFileAccess
(
const
char
*
pathname
,
int
mode
)
{
int
flags
=
0
;
//
int tdbCheckFileAccess(const char *pathname, int mode) {
//
int flags = 0;
if
(
mode
&
TDB_F_OK
)
{
flags
|=
F_OK
;
}
//
if (mode & TDB_F_OK) {
//
flags |= F_OK;
//
}
if
(
mode
&
TDB_R_OK
)
{
flags
|=
R_OK
;
}
//
if (mode & TDB_R_OK) {
//
flags |= R_OK;
//
}
if
(
mode
&
TDB_W_OK
)
{
flags
|=
W_OK
;
}
//
if (mode & TDB_W_OK) {
//
flags |= W_OK;
//
}
return
access
(
pathname
,
flags
);
}
//
return access(pathname, flags);
//
}
int
tdbGetFileSize
(
const
char
*
fname
,
pgsz_t
pgSize
,
pgno_t
*
pSize
)
{
struct
stat
st
;
int
ret
;
ret
=
stat
(
fname
,
&
st
);
int64_t
file_size
=
0
;
ret
=
taosStatFile
(
fname
,
&
file_size
,
NULL
);
if
(
ret
!=
0
)
{
return
-
1
;
}
ASSERT
(
st
.
st
_size
%
pgSize
==
0
);
ASSERT
(
file
_size
%
pgSize
==
0
);
*
pSize
=
st
.
st
_size
/
pgSize
;
*
pSize
=
file
_size
/
pgSize
;
return
0
;
}
\ No newline at end of file
source/libs/tdb/src/inc/tdbUtil.h
浏览文件 @
35b3edae
...
...
@@ -30,10 +30,10 @@ extern "C" {
int
tdbGnrtFileID
(
const
char
*
fname
,
uint8_t
*
fileid
,
bool
unique
);
#define TDB_F_OK 0x1
#define TDB_R_OK 0x2
#define TDB_W_OK 0x4
int
tdbCheckFileAccess
(
const
char
*
pathname
,
int
mode
);
//
#define TDB_F_OK 0x1
//
#define TDB_R_OK 0x2
//
#define TDB_W_OK 0x4
//
int tdbCheckFileAccess(const char *pathname, int mode);
int
tdbGetFileSize
(
const
char
*
fname
,
pgsz_t
pgSize
,
pgno_t
*
pSize
);
...
...
source/libs/tdb/test/tdbTest.cpp
浏览文件 @
35b3edae
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "tdb.h"
...
...
source/libs/tfs/src/tfs.c
浏览文件 @
35b3edae
...
...
@@ -389,7 +389,6 @@ static int32_t tfsMount(STfs *pTfs, SDiskCfg *pCfg) {
static
int32_t
tfsCheckAndFormatCfg
(
STfs
*
pTfs
,
SDiskCfg
*
pCfg
)
{
char
dirName
[
TSDB_FILENAME_LEN
]
=
"
\0
"
;
struct
stat
pstat
;
if
(
pCfg
->
level
<
0
||
pCfg
->
level
>=
TFS_MAX_TIERS
)
{
fError
(
"failed to mount %s to FS since invalid level %d"
,
pCfg
->
dir
,
pCfg
->
level
);
...
...
@@ -422,19 +421,13 @@ static int32_t tfsCheckAndFormatCfg(STfs *pTfs, SDiskCfg *pCfg) {
return
-
1
;
}
if
(
access
(
dirName
,
W_OK
|
R_OK
|
F_OK
)
!=
0
)
{
if
(
!
taosCheckAccessFile
(
dirName
,
TD_FILE_ACCESS_EXIST_OK
|
TD_FILE_ACCESS_READ_OK
|
TD_FILE_ACCESS_WRITE_OK
)
)
{
fError
(
"failed to mount %s to FS since no R/W access rights"
,
pCfg
->
dir
);
terrno
=
TSDB_CODE_FS_INVLD_CFG
;
return
-
1
;
}
if
(
stat
(
dirName
,
&
pstat
)
<
0
)
{
fError
(
"failed to mount %s to FS since %s"
,
pCfg
->
dir
,
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
if
(
!
S_ISDIR
(
pstat
.
st_mode
))
{
if
(
!
taosIsDir
(
dirName
))
{
fError
(
"failed to mount %s to FS since not a directory"
,
pCfg
->
dir
);
terrno
=
TSDB_CODE_FS_INVLD_CFG
;
return
-
1
;
...
...
source/libs/tfs/test/tfsTest.cpp
浏览文件 @
35b3edae
...
...
@@ -119,29 +119,29 @@ TEST_F(TfsTest, 03_Dir) {
char
p1
[]
=
"p1"
;
char
ap1
[
128
]
=
{
0
};
snprintf
(
ap1
,
128
,
"%s%s%s"
,
root
,
TD_DIRSEP
,
p1
);
EXPECT_NE
(
taosDirExist
(
ap1
),
0
);
EXPECT_NE
(
taosDirExist
(
ap1
),
1
);
EXPECT_EQ
(
tfsMkdir
(
pTfs
,
p1
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap1
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap1
),
1
);
char
p2
[]
=
"p2"
;
char
ap2
[
128
]
=
{
0
};
snprintf
(
ap2
,
128
,
"%s%s%s"
,
root
,
TD_DIRSEP
,
p2
);
SDiskID
did
=
{
0
};
EXPECT_NE
(
taosDirExist
(
ap2
),
0
);
EXPECT_NE
(
taosDirExist
(
ap2
),
1
);
EXPECT_EQ
(
tfsMkdirAt
(
pTfs
,
p2
,
did
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap2
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap2
),
1
);
char
p3
[]
=
"p3/p2/p1/p0"
;
char
ap3
[
128
]
=
{
0
};
snprintf
(
ap3
,
128
,
"%s%s%s"
,
root
,
TD_DIRSEP
,
p3
);
EXPECT_NE
(
taosDirExist
(
ap3
),
0
);
EXPECT_NE
(
taosDirExist
(
ap3
),
1
);
EXPECT_NE
(
tfsMkdir
(
pTfs
,
p3
),
0
);
EXPECT_NE
(
tfsMkdirAt
(
pTfs
,
p3
,
did
),
0
);
EXPECT_EQ
(
tfsMkdirRecurAt
(
pTfs
,
p3
,
did
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap3
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap3
),
1
);
EXPECT_EQ
(
tfsRmdir
(
pTfs
,
p3
),
0
);
EXPECT_NE
(
taosDirExist
(
ap3
),
0
);
EXPECT_NE
(
taosDirExist
(
ap3
),
1
);
char
p45
[]
=
"p5"
;
char
p44
[]
=
"p4"
;
...
...
@@ -149,12 +149,12 @@ TEST_F(TfsTest, 03_Dir) {
char
ap4
[
128
]
=
{
0
};
snprintf
(
ap4
,
128
,
"%s%s%s"
,
root
,
TD_DIRSEP
,
p4
);
EXPECT_NE
(
taosDirExist
(
ap4
),
0
);
EXPECT_NE
(
taosDirExist
(
ap4
),
1
);
EXPECT_EQ
(
tfsMkdirRecurAt
(
pTfs
,
p4
,
did
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap4
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap4
),
1
);
EXPECT_EQ
(
tfsRename
(
pTfs
,
p44
,
p45
),
0
);
EXPECT_EQ
(
tfsRmdir
(
pTfs
,
p4
),
0
);
EXPECT_NE
(
taosDirExist
(
ap4
),
0
);
EXPECT_NE
(
taosDirExist
(
ap4
),
1
);
tfsClose
(
pTfs
);
}
...
...
@@ -251,9 +251,9 @@ TEST_F(TfsTest, 04_File) {
char
af2
[
128
]
=
{
0
};
snprintf
(
af2
,
128
,
"%s%s%s"
,
root
,
TD_DIRSEP
,
n2
);
EXPECT_EQ
(
taosDirExist
(
af2
),
0
);
EXPECT_EQ
(
taosDirExist
(
af2
),
1
);
tfsRemoveFile
(
&
f2
);
EXPECT_NE
(
taosDirExist
(
af2
),
0
);
EXPECT_NE
(
taosDirExist
(
af2
),
1
);
{
STfsDir
*
pDir
=
tfsOpendir
(
pTfs
,
"t3"
);
...
...
@@ -529,35 +529,35 @@ TEST_F(TfsTest, 05_MultiDisk) {
snprintf
(
ap22
,
128
,
"%s%s%s"
,
root22
,
TD_DIRSEP
,
p1
);
char
ap23
[
128
]
=
{
0
};
snprintf
(
ap23
,
128
,
"%s%s%s"
,
root23
,
TD_DIRSEP
,
p1
);
EXPECT_NE
(
taosDirExist
(
ap00
),
0
);
EXPECT_NE
(
taosDirExist
(
ap01
),
0
);
EXPECT_NE
(
taosDirExist
(
ap10
),
0
);
EXPECT_NE
(
taosDirExist
(
ap11
),
0
);
EXPECT_NE
(
taosDirExist
(
ap12
),
0
);
EXPECT_NE
(
taosDirExist
(
ap20
),
0
);
EXPECT_NE
(
taosDirExist
(
ap21
),
0
);
EXPECT_NE
(
taosDirExist
(
ap22
),
0
);
EXPECT_NE
(
taosDirExist
(
ap23
),
0
);
EXPECT_NE
(
taosDirExist
(
ap00
),
1
);
EXPECT_NE
(
taosDirExist
(
ap01
),
1
);
EXPECT_NE
(
taosDirExist
(
ap10
),
1
);
EXPECT_NE
(
taosDirExist
(
ap11
),
1
);
EXPECT_NE
(
taosDirExist
(
ap12
),
1
);
EXPECT_NE
(
taosDirExist
(
ap20
),
1
);
EXPECT_NE
(
taosDirExist
(
ap21
),
1
);
EXPECT_NE
(
taosDirExist
(
ap22
),
1
);
EXPECT_NE
(
taosDirExist
(
ap23
),
1
);
EXPECT_EQ
(
tfsMkdir
(
pTfs
,
p1
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap00
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap01
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap10
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap11
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap12
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap20
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap21
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap22
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap23
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap00
),
1
);
EXPECT_EQ
(
taosDirExist
(
ap01
),
1
);
EXPECT_EQ
(
taosDirExist
(
ap10
),
1
);
EXPECT_EQ
(
taosDirExist
(
ap11
),
1
);
EXPECT_EQ
(
taosDirExist
(
ap12
),
1
);
EXPECT_EQ
(
taosDirExist
(
ap20
),
1
);
EXPECT_EQ
(
taosDirExist
(
ap21
),
1
);
EXPECT_EQ
(
taosDirExist
(
ap22
),
1
);
EXPECT_EQ
(
taosDirExist
(
ap23
),
1
);
EXPECT_EQ
(
tfsRmdir
(
pTfs
,
p1
),
0
);
EXPECT_NE
(
taosDirExist
(
ap00
),
0
);
EXPECT_NE
(
taosDirExist
(
ap01
),
0
);
EXPECT_NE
(
taosDirExist
(
ap10
),
0
);
EXPECT_NE
(
taosDirExist
(
ap11
),
0
);
EXPECT_NE
(
taosDirExist
(
ap12
),
0
);
EXPECT_NE
(
taosDirExist
(
ap20
),
0
);
EXPECT_NE
(
taosDirExist
(
ap21
),
0
);
EXPECT_NE
(
taosDirExist
(
ap22
),
0
);
EXPECT_NE
(
taosDirExist
(
ap23
),
0
);
EXPECT_NE
(
taosDirExist
(
ap00
),
1
);
EXPECT_NE
(
taosDirExist
(
ap01
),
1
);
EXPECT_NE
(
taosDirExist
(
ap10
),
1
);
EXPECT_NE
(
taosDirExist
(
ap11
),
1
);
EXPECT_NE
(
taosDirExist
(
ap12
),
1
);
EXPECT_NE
(
taosDirExist
(
ap20
),
1
);
EXPECT_NE
(
taosDirExist
(
ap21
),
1
);
EXPECT_NE
(
taosDirExist
(
ap22
),
1
);
EXPECT_NE
(
taosDirExist
(
ap23
),
1
);
char
p2
[]
=
"p2"
;
char
_ap21
[
128
]
=
{
0
};
...
...
@@ -565,22 +565,22 @@ TEST_F(TfsTest, 05_MultiDisk) {
SDiskID
did
=
{
0
};
did
.
level
=
2
;
did
.
id
=
1
;
EXPECT_NE
(
taosDirExist
(
_ap21
),
0
);
EXPECT_NE
(
taosDirExist
(
_ap21
),
1
);
EXPECT_EQ
(
tfsMkdirAt
(
pTfs
,
p2
,
did
),
0
);
EXPECT_EQ
(
taosDirExist
(
_ap21
),
0
);
EXPECT_EQ
(
taosDirExist
(
_ap21
),
1
);
char
p3
[]
=
"p3/p2/p1/p0"
;
char
_ap12
[
128
]
=
{
0
};
snprintf
(
_ap12
,
128
,
"%s%s%s"
,
root12
,
TD_DIRSEP
,
p3
);
did
.
level
=
1
;
did
.
id
=
2
;
EXPECT_NE
(
taosDirExist
(
_ap12
),
0
);
EXPECT_NE
(
taosDirExist
(
_ap12
),
1
);
EXPECT_NE
(
tfsMkdir
(
pTfs
,
p3
),
0
);
EXPECT_NE
(
tfsMkdirAt
(
pTfs
,
p3
,
did
),
0
);
EXPECT_EQ
(
tfsMkdirRecurAt
(
pTfs
,
p3
,
did
),
0
);
EXPECT_EQ
(
taosDirExist
(
_ap12
),
0
);
EXPECT_EQ
(
taosDirExist
(
_ap12
),
1
);
EXPECT_EQ
(
tfsRmdir
(
pTfs
,
p3
),
0
);
EXPECT_NE
(
taosDirExist
(
_ap12
),
0
);
EXPECT_NE
(
taosDirExist
(
_ap12
),
1
);
char
p45
[]
=
"p5"
;
char
p44
[]
=
"p4"
;
...
...
@@ -590,12 +590,12 @@ TEST_F(TfsTest, 05_MultiDisk) {
did
.
level
=
2
;
did
.
id
=
2
;
EXPECT_NE
(
taosDirExist
(
_ap22
),
0
);
EXPECT_NE
(
taosDirExist
(
_ap22
),
1
);
EXPECT_EQ
(
tfsMkdirRecurAt
(
pTfs
,
p4
,
did
),
0
);
EXPECT_EQ
(
taosDirExist
(
_ap22
),
0
);
EXPECT_EQ
(
taosDirExist
(
_ap22
),
1
);
EXPECT_EQ
(
tfsRename
(
pTfs
,
p44
,
p45
),
0
);
EXPECT_EQ
(
tfsRmdir
(
pTfs
,
p4
),
0
);
EXPECT_NE
(
taosDirExist
(
_ap22
),
0
);
EXPECT_NE
(
taosDirExist
(
_ap22
),
1
);
}
//------------- File -----------------//
...
...
@@ -660,7 +660,7 @@ TEST_F(TfsTest, 05_MultiDisk) {
char
af2
[
128
]
=
{
0
};
snprintf
(
af2
,
128
,
"%s%s%s"
,
root23
,
TD_DIRSEP
,
n2
);
EXPECT_EQ
(
taosDirExist
(
af2
),
0
);
EXPECT_EQ
(
taosDirExist
(
af2
),
1
);
tfsRemoveFile
(
&
f2
);
{
...
...
@@ -678,7 +678,7 @@ TEST_F(TfsTest, 05_MultiDisk) {
tfsClosedir
(
pDir
);
}
EXPECT_NE
(
taosDirExist
(
af2
),
0
);
EXPECT_NE
(
taosDirExist
(
af2
),
1
);
EXPECT_GT
(
tfsCopyFile
(
&
f1
,
&
f2
),
0
);
{
...
...
source/libs/wal/src/walMeta.c
浏览文件 @
35b3edae
...
...
@@ -64,10 +64,10 @@ static inline int64_t walScanLogGetLastVer(SWal* pWal) {
char
fnameStr
[
WAL_FILE_LEN
];
walBuildLogName
(
pWal
,
pLastFileInfo
->
firstVer
,
fnameStr
);
struct
stat
statbuf
;
stat
(
fnameStr
,
&
statbuf
);
int
readSize
=
TMIN
(
WAL_MAX_SIZE
+
2
,
statbuf
.
st
_size
);
pLastFileInfo
->
fileSize
=
statbuf
.
st
_size
;
int64_t
file_size
=
0
;
taosStatFile
(
fnameStr
,
&
file_size
,
NULL
);
int
readSize
=
TMIN
(
WAL_MAX_SIZE
+
2
,
file
_size
);
pLastFileInfo
->
fileSize
=
file
_size
;
TdFilePtr
pFile
=
taosOpenFile
(
fnameStr
,
TD_FILE_READ
);
if
(
pFile
==
NULL
)
{
...
...
@@ -177,11 +177,11 @@ int walCheckAndRepairMeta(SWal* pWal) {
SWalFileInfo
*
pLastFileInfo
=
taosArrayGet
(
pWal
->
fileInfoSet
,
newSz
-
1
);
char
fnameStr
[
WAL_FILE_LEN
];
walBuildLogName
(
pWal
,
pLastFileInfo
->
firstVer
,
fnameStr
);
struct
stat
statbuf
;
stat
(
fnameStr
,
&
statbuf
);
int64_t
file_size
=
0
;
taosStatFile
(
fnameStr
,
&
file_size
,
NULL
);
if
(
oldSz
!=
newSz
||
pLastFileInfo
->
fileSize
!=
statbuf
.
st
_size
)
{
pLastFileInfo
->
fileSize
=
statbuf
.
st
_size
;
if
(
oldSz
!=
newSz
||
pLastFileInfo
->
fileSize
!=
file
_size
)
{
pLastFileInfo
->
fileSize
=
file
_size
;
pWal
->
vers
.
lastVer
=
walScanLogGetLastVer
(
pWal
);
((
SWalFileInfo
*
)
taosArrayGetLast
(
pWal
->
fileInfoSet
))
->
lastVer
=
pWal
->
vers
.
lastVer
;
ASSERT
(
pWal
->
vers
.
lastVer
!=
-
1
);
...
...
@@ -395,9 +395,9 @@ int walLoadMeta(SWal* pWal) {
char
fnameStr
[
WAL_FILE_LEN
];
walBuildMetaName
(
pWal
,
metaVer
,
fnameStr
);
// read metafile
struct
stat
statbuf
;
stat
(
fnameStr
,
&
statbuf
);
int
size
=
statbuf
.
st
_size
;
int64_t
file_size
=
0
;
taosStatFile
(
fnameStr
,
&
file_size
,
NULL
);
int
size
=
(
int
)
file
_size
;
char
*
buf
=
malloc
(
size
+
5
);
if
(
buf
==
NULL
)
{
terrno
=
TSDB_CODE_WAL_OUT_OF_MEMORY
;
...
...
source/os/src/osDir.c
浏览文件 @
35b3edae
...
...
@@ -60,7 +60,7 @@ void taosRemoveDir(const char *dirname) {
//printf("dir:%s is removed\n", dirname);
}
int32_t
taosDirExist
(
char
*
dirname
)
{
return
access
(
dirname
,
F_OK
);
}
bool
taosDirExist
(
char
*
dirname
)
{
return
taosCheckExistFile
(
dirname
);
}
int32_t
taosMkDir
(
const
char
*
dirname
)
{
int32_t
code
=
mkdir
(
dirname
,
0755
);
...
...
source/os/src/osFile.c
浏览文件 @
35b3edae
...
...
@@ -186,6 +186,27 @@ int32_t taosStatFile(const char *path, int64_t *size, int32_t *mtime) {
return
0
;
#endif
}
int32_t
taosDevInoFile
(
const
char
*
path
,
int64_t
*
stDev
,
int64_t
*
stIno
)
{
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
return
0
;
#else
struct
stat
fileStat
;
int32_t
code
=
stat
(
path
,
&
fileStat
);
if
(
code
<
0
)
{
return
code
;
}
if
(
stDev
!=
NULL
)
{
*
stDev
=
fileStat
.
st_dev
;
}
if
(
stIno
!=
NULL
)
{
*
stIno
=
fileStat
.
st_ino
;
}
return
0
;
#endif
}
void
autoDelFileListAdd
(
const
char
*
path
)
{
return
;
}
...
...
@@ -733,3 +754,21 @@ int32_t taosEOFFile(TdFilePtr pFile) {
return
feof
(
pFile
->
fp
);
}
bool
taosCheckAccessFile
(
const
char
*
pathname
,
int32_t
tdFileAccessOptions
)
{
int
flags
=
0
;
if
(
tdFileAccessOptions
&
TD_FILE_ACCESS_EXIST_OK
)
{
flags
|=
F_OK
;
}
if
(
tdFileAccessOptions
&
TD_FILE_ACCESS_READ_OK
)
{
flags
|=
R_OK
;
}
if
(
tdFileAccessOptions
&
TD_FILE_ACCESS_WRITE_OK
)
{
flags
|=
W_OK
;
}
return
access
(
pathname
,
flags
)
==
0
;
}
bool
taosCheckExistFile
(
const
char
*
pathname
)
{
return
taosCheckAccessFile
(
pathname
,
TD_FILE_ACCESS_EXIST_OK
);
};
\ No newline at end of file
source/util/test/cacheTest.cpp
浏览文件 @
35b3edae
#include "os.h"
#include <iostream>
#include <gtest/gtest.h>
#include "os.h"
#include "taos.h"
#include "tcache.h"
...
...
source/util/test/encodeTest.cpp
浏览文件 @
35b3edae
#include <iostream>
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "tencode.h"
...
...
source/util/test/freelistTest.cpp
浏览文件 @
35b3edae
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "tfreelist.h"
...
...
source/util/test/hashTest.cpp
浏览文件 @
35b3edae
#include "os.h"
#include <gtest/gtest.h>
#include <limits.h>
#include <taosdef.h>
#include <iostream>
#include "os.h"
#include "taosdef.h"
#include "thash.h"
#include "taos.h"
...
...
tools/shell/src/backup/shellImport.c
浏览文件 @
35b3edae
...
...
@@ -93,8 +93,7 @@ static void shellCheckTablesSQLFile(const char *directoryName)
{
sprintf
(
shellTablesSQLFile
,
"%s/tables.sql"
,
directoryName
);
struct
stat
fstat
;
if
(
stat
(
shellTablesSQLFile
,
&
fstat
)
<
0
)
{
if
(
taosFStatFile
(
shellTablesSQLFile
,
NULL
,
NULL
)
<
0
)
{
shellTablesSQLFile
[
0
]
=
0
;
}
}
...
...
@@ -109,13 +108,12 @@ static void shellMallocSQLFiles()
static
void
shellGetDirectoryFileList
(
char
*
inputDir
)
{
struct
stat
fileStat
;
if
(
stat
(
inputDir
,
&
fileStat
)
<
0
)
{
if
(
!
taosDirExist
(
inputDir
))
{
fprintf
(
stderr
,
"ERROR: %s not exist
\n
"
,
inputDir
);
exit
(
0
);
}
if
(
fileStat
.
st_mode
&
S_IFDIR
)
{
if
(
taosIsDir
(
inputDir
)
)
{
shellCheckTablesSQLFile
(
inputDir
);
shellSQLFileNum
=
shellGetFilesNum
(
inputDir
,
"sql"
);
int
totalSQLFileNum
=
shellSQLFileNum
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录