提交 5f90bae8 编写于 作者: H Hongze Cheng

more TDB

上级 5c9c9695
......@@ -31,7 +31,39 @@ i64 tdbOsPRead(tdb_fd_t fd, void *pBuf, i64 nBytes, i64 offset) {
// tdbOsWrite
i64 taosWriteFile(tdb_fd_t fd, const void *pBuf, i64 nBytes) {
// TODO
ASSERT(0);
return 0;
}
\ No newline at end of file
// TODO
ASSERT(0);
return 0;
}
#if 0
int tdbPRead(int fd, void *pData, int count, i64 offset) {
void *pBuf;
int nbytes;
i64 ioffset;
int iread;
pBuf = pData;
nbytes = count;
ioffset = offset;
while (nbytes > 0) {
iread = pread(fd, pBuf, nbytes, ioffset);
if (iread < 0) {
/* TODO */
} else if (iread == 0) {
return (count - iread);
}
nbytes = nbytes - iread;
pBuf = (void *)((u8 *)pBuf + iread);
ioffset += iread;
}
return count;
}
int tdbWrite(int fd, void *pData, int count) {
// TODO
return write(fd, pData, count);
}
#endif
\ No newline at end of file
......@@ -209,7 +209,7 @@ int tdbPagerCommit(SPager *pPager) {
tdbOsFSync(pPager->fd);
tdbOsClose(pPager->jfd);
remove(pPager->jFileName);
tdbOsRemove(pPager->jFileName);
// pPager->jfd = -1;
return 0;
......
......@@ -33,28 +33,10 @@ int tdbGnrtFileID(const char *fname, uint8_t *fileid, bool unique) {
return 0;
}
// int tdbCheckFileAccess(const char *pathname, int mode) {
// int flags = 0;
// if (mode & TDB_F_OK) {
// flags |= F_OK;
// }
// if (mode & TDB_R_OK) {
// flags |= R_OK;
// }
// if (mode & TDB_W_OK) {
// flags |= W_OK;
// }
// return access(pathname, flags);
// }
int tdbGetFileSize(const char *fname, int pgSize, SPgno *pSize) {
struct stat st;
int ret;
int64_t file_size = 0;
int64_t file_size = 0;
ret = taosStatFile(fname, &file_size, NULL);
if (ret != 0) {
return -1;
......@@ -64,34 +46,4 @@ int tdbGetFileSize(const char *fname, int pgSize, SPgno *pSize) {
*pSize = file_size / pgSize;
return 0;
}
int tdbPRead(int fd, void *pData, int count, i64 offset) {
void *pBuf;
int nbytes;
i64 ioffset;
int iread;
pBuf = pData;
nbytes = count;
ioffset = offset;
while (nbytes > 0) {
iread = pread(fd, pBuf, nbytes, ioffset);
if (iread < 0) {
/* TODO */
} else if (iread == 0) {
return (count - iread);
}
nbytes = nbytes - iread;
pBuf = (void *)((u8 *)pBuf + iread);
ioffset += iread;
}
return count;
}
int tdbWrite(int fd, void *pData, int count) {
// TODO
return write(fd, pData, count);
}
\ No newline at end of file
......@@ -53,6 +53,7 @@ typedef TdFilePtr tdb_fd_t;
#define tdbOsWrite taosWriteFile
#define tdbOsFSync taosFsyncFile
#define tdbOsLSeek taosLSeekFile
#define tdbOsRemove remove
/* directory */
#define tdbOsMkdir taosMkDir
......@@ -70,12 +71,13 @@ i64 tdbOsRead(tdb_fd_t fd, void *pBuf, i64 nBytes);
i64 tdbOsPRead(tdb_fd_t fd, void *pBuf, i64 nBytes, i64 offset);
i64 taosWriteFile(tdb_fd_t fd, const void *pBuf, i64 nBytes);
#define tdbOsFSync fsync
#define tdbOsLSeek lseek
#define tdbOsFSync fsync
#define tdbOsLSeek lseek
#define tdbOsRemove remove
/* directory */
#define tdbOsMkdir mkdir
#define tdbOsRmdir rmdir
#define tdbOsMkdir mkdir
#define tdbOsRmdir rmdir
#endif
......
......@@ -30,16 +30,8 @@ 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);
int tdbGetFileSize(const char *fname, int pgSize, SPgno *pSize);
int tdbPRead(int fd, void *pData, int count, i64 offset);
int tdbWrite(int fd, void *pData, int count);
#define TDB_REALLOC(PTR, SIZE) \
({ \
void *nPtr; \
......@@ -55,11 +47,11 @@ int tdbWrite(int fd, void *pData, int count);
nPtr; \
})
#define TDB_FREE(PTR) \
do { \
if (PTR) { \
#define TDB_FREE(PTR) \
do { \
if (PTR) { \
tdbOsFree((char *)(PTR) - sizeof(int)); \
} \
} \
} while (0)
static inline void *tdbDefaultMalloc(void *arg, size_t size) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册