Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Mr、小李
TDengine
提交
fd9847a2
T
TDengine
项目概览
Mr、小李
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fd9847a2
编写于
2月 01, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-1207
上级
a8928b04
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
17 addition
and
21 deletion
+17
-21
src/tfs/src/tfs.c
src/tfs/src/tfs.c
+17
-21
未找到文件。
src/tfs/src/tfs.c
浏览文件 @
fd9847a2
...
...
@@ -21,10 +21,7 @@
#include "tfs.h"
#include "tfsint.h"
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-truncation"
#endif
#define TMPNAME_LEN (TSDB_FILENAME_LEN * 2 + 32)
typedef
struct
{
pthread_spinlock_t
lock
;
...
...
@@ -190,7 +187,10 @@ void tfsInitFile(TFILE *pf, int level, int id, const char *bname) {
pf
->
level
=
level
;
pf
->
id
=
id
;
strncpy
(
pf
->
rname
,
bname
,
TSDB_FILENAME_LEN
);
snprintf
(
pf
->
aname
,
TSDB_FILENAME_LEN
,
"%s/%s"
,
DISK_DIR
(
pDisk
),
bname
);
char
tmpName
[
TMPNAME_LEN
]
=
{
0
};
snprintf
(
tmpName
,
TMPNAME_LEN
,
"%s/%s"
,
DISK_DIR
(
pDisk
),
bname
);
tstrncpy
(
pf
->
aname
,
tmpName
,
TSDB_FILENAME_LEN
);
}
bool
tfsIsSameFile
(
const
TFILE
*
pf1
,
const
TFILE
*
pf2
)
{
...
...
@@ -243,9 +243,9 @@ void tfsdirname(const TFILE *pf, char *dest) {
// DIR APIs ====================================
int
tfsMkdirAt
(
const
char
*
rname
,
int
level
,
int
id
)
{
SDisk
*
pDisk
=
TFS_DISK_AT
(
level
,
id
);
char
aname
[
T
SDB_FILE
NAME_LEN
];
char
aname
[
T
MP
NAME_LEN
];
snprintf
(
aname
,
T
SDB_FILE
NAME_LEN
,
"%s/%s"
,
DISK_DIR
(
pDisk
),
rname
);
snprintf
(
aname
,
T
MP
NAME_LEN
,
"%s/%s"
,
DISK_DIR
(
pDisk
),
rname
);
if
(
taosMkDir
(
aname
,
0755
)
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
...
...
@@ -291,14 +291,14 @@ int tfsMkdir(const char *rname) {
}
int
tfsRmdir
(
const
char
*
rname
)
{
char
aname
[
T
SDB_FILE
NAME_LEN
]
=
"
\0
"
;
char
aname
[
T
MP
NAME_LEN
]
=
"
\0
"
;
for
(
int
level
=
0
;
level
<
TFS_NLEVEL
();
level
++
)
{
STier
*
pTier
=
TFS_TIER_AT
(
level
);
for
(
int
id
=
0
;
id
<
TIER_NDISKS
(
pTier
);
id
++
)
{
SDisk
*
pDisk
=
DISK_AT_TIER
(
pTier
,
id
);
snprintf
(
aname
,
T
SDB_FILE
NAME_LEN
,
"%s/%s"
,
DISK_DIR
(
pDisk
),
rname
);
snprintf
(
aname
,
T
MP
NAME_LEN
,
"%s/%s"
,
DISK_DIR
(
pDisk
),
rname
);
taosRemoveDir
(
aname
);
}
...
...
@@ -308,16 +308,16 @@ int tfsRmdir(const char *rname) {
}
int
tfsRename
(
char
*
orname
,
char
*
nrname
)
{
char
oaname
[
T
SDB_FILE
NAME_LEN
]
=
"
\0
"
;
char
naname
[
T
SDB_FILE
NAME_LEN
]
=
"
\0
"
;
char
oaname
[
T
MP
NAME_LEN
]
=
"
\0
"
;
char
naname
[
T
MP
NAME_LEN
]
=
"
\0
"
;
for
(
int
level
=
0
;
level
<
pfs
->
nlevel
;
level
++
)
{
STier
*
pTier
=
TFS_TIER_AT
(
level
);
for
(
int
id
=
0
;
id
<
TIER_NDISKS
(
pTier
);
id
++
)
{
SDisk
*
pDisk
=
DISK_AT_TIER
(
pTier
,
id
);
snprintf
(
oaname
,
T
SDB_FILE
NAME_LEN
,
"%s/%s"
,
DISK_DIR
(
pDisk
),
orname
);
snprintf
(
naname
,
T
SDB_FILE
NAME_LEN
,
"%s/%s"
,
DISK_DIR
(
pDisk
),
nrname
);
snprintf
(
oaname
,
T
MP
NAME_LEN
,
"%s/%s"
,
DISK_DIR
(
pDisk
),
orname
);
snprintf
(
naname
,
T
MP
NAME_LEN
,
"%s/%s"
,
DISK_DIR
(
pDisk
),
nrname
);
taosRename
(
oaname
,
naname
);
}
...
...
@@ -355,7 +355,7 @@ TDIR *tfsOpendir(const char *rname) {
const
TFILE
*
tfsReaddir
(
TDIR
*
tdir
)
{
if
(
tdir
==
NULL
||
tdir
->
dir
==
NULL
)
return
NULL
;
char
bname
[
T
SDB_FILENAME_LEN
]
=
"
\0
"
;
char
bname
[
T
MPNAME_LEN
*
2
]
=
"
\0
"
;
while
(
true
)
{
struct
dirent
*
dp
=
NULL
;
...
...
@@ -364,7 +364,7 @@ const TFILE *tfsReaddir(TDIR *tdir) {
// Skip . and ..
if
(
strcmp
(
dp
->
d_name
,
"."
)
==
0
||
strcmp
(
dp
->
d_name
,
".."
)
==
0
)
continue
;
snprintf
(
bname
,
T
SDB_FILENAME_LEN
,
"%s/%s"
,
tdir
->
dirname
,
dp
->
d_name
);
snprintf
(
bname
,
T
MPNAME_LEN
*
2
,
"%s/%s"
,
tdir
->
dirname
,
dp
->
d_name
);
tfsInitFile
(
&
(
tdir
->
tfile
),
tdir
->
level
,
tdir
->
id
,
bname
);
return
&
(
tdir
->
tfile
);
}
...
...
@@ -526,7 +526,7 @@ static SDisk *tfsGetDiskByName(const char *dir) {
static
int
tfsOpendirImpl
(
TDIR
*
tdir
)
{
SDisk
*
pDisk
=
NULL
;
char
adir
[
T
SDB_FILENAME_LEN
]
=
"
\0
"
;
char
adir
[
T
MPNAME_LEN
*
2
]
=
"
\0
"
;
if
(
tdir
->
dir
!=
NULL
)
{
closedir
(
tdir
->
dir
);
...
...
@@ -540,7 +540,7 @@ static int tfsOpendirImpl(TDIR *tdir) {
tdir
->
level
=
DISK_LEVEL
(
pDisk
);
tdir
->
id
=
DISK_ID
(
pDisk
);
snprintf
(
adir
,
T
SDB_FILENAME_LEN
,
"%s/%s"
,
DISK_DIR
(
pDisk
),
tdir
->
dirname
);
snprintf
(
adir
,
T
MPNAME_LEN
*
2
,
"%s/%s"
,
DISK_DIR
(
pDisk
),
tdir
->
dirname
);
tdir
->
dir
=
opendir
(
adir
);
if
(
tdir
->
dir
!=
NULL
)
break
;
}
...
...
@@ -598,7 +598,3 @@ void taosGetDisk() {
tsAvailTmpDirectorySpace
=
(
float
)(
diskSize
.
avail
/
unit
);
}
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录