diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 459a2c32beb641a03ad04e97ccce7ee3b7b11a83..b5856013f6dbb9fbe67afd1e1647f73bfdf29944 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -415,7 +415,7 @@ int32_t readFromFile(char *name, uint32_t *len, void **buf) { return TSDB_CODE_TSC_OUT_OF_MEMORY; } - int fd = open(name, O_RDONLY); + int fd = open(name, O_RDONLY | O_BINARY); if (fd < 0) { tscError("open file %s failed, error:%s", name, strerror(errno)); tfree(*buf); diff --git a/src/dnode/src/dnodeMain.c b/src/dnode/src/dnodeMain.c index 5291fb73a05da27f98252b680542a83ec41c94a7..417a3d764d87c3db5eb571823449ef3e2762f026 100644 --- a/src/dnode/src/dnodeMain.c +++ b/src/dnode/src/dnodeMain.c @@ -226,7 +226,7 @@ static void dnodeCheckDataDirOpenned(char *dir) { char filepath[256] = {0}; sprintf(filepath, "%s/.running", dir); - int fd = open(filepath, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG | S_IRWXO); + int fd = open(filepath, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRWXU | S_IRWXG | S_IRWXO); if (fd < 0) { dError("failed to open lock file:%s, reason: %s, quit", filepath, strerror(errno)); exit(0); diff --git a/src/dnode/src/dnodeTelemetry.c b/src/dnode/src/dnodeTelemetry.c index 22a6dc5b1993b6d15510b078ac4245909221ae78..ec09ab5d752cfbd4219787c0438c9b8bf4d1a9c4 100644 --- a/src/dnode/src/dnodeTelemetry.c +++ b/src/dnode/src/dnodeTelemetry.c @@ -266,7 +266,7 @@ static void* telemetryThread(void* param) { } static void dnodeGetEmail(char* filepath) { - int32_t fd = open(filepath, O_RDONLY); + int32_t fd = open(filepath, O_RDONLY | O_BINARY); if (fd < 0) { return; } diff --git a/src/inc/tfs.h b/src/inc/tfs.h index e72620eca6965d78609bbbd283fff8085d08a4b8..dacd5978c1b44c4d54e377697212da08f9c9c86d 100644 --- a/src/inc/tfs.h +++ b/src/inc/tfs.h @@ -63,7 +63,7 @@ typedef struct { #define TFILE_NAME(pf) ((pf)->aname) #define TFILE_REL_NAME(pf) ((pf)->rname) -#define tfsopen(pf, flags) open(TFILE_NAME(pf), flags) +#define tfsopen(pf, flags) open(TFILE_NAME(pf), flags | O_BINARY) #define tfsclose(fd) close(fd) #define tfsremove(pf) remove(TFILE_NAME(pf)) #define tfscopy(sf, df) taosCopy(TFILE_NAME(sf), TFILE_NAME(df)) diff --git a/src/os/src/detail/osRand.c b/src/os/src/detail/osRand.c index 0dda908bb35c68513dba150e8380846c36aa2893..e1d81ea5d3ed1fccd0b8b96cb8c3991475f9c714 100644 --- a/src/os/src/detail/osRand.c +++ b/src/os/src/detail/osRand.c @@ -22,7 +22,7 @@ uint32_t taosSafeRand(void) { int fd; int seed; - fd = open("/dev/urandom", 0); + fd = open("/dev/urandom", 0 | O_BINARY); if (fd < 0) { seed = (int)time(0); } else { diff --git a/src/os/src/detail/osSysinfo.c b/src/os/src/detail/osSysinfo.c index 8f39459f2ebf95146d6d90c78a4b648e7b2332f3..8412e0f3d44cdc6c7c69db9b657530e145d63243 100644 --- a/src/os/src/detail/osSysinfo.c +++ b/src/os/src/detail/osSysinfo.c @@ -652,7 +652,7 @@ bool taosGetSystemUid(char *uid) { int fd; int len = 0; - fd = open("/proc/sys/kernel/random/uuid", 0); + fd = open("/proc/sys/kernel/random/uuid", 0 | O_BINARY); if (fd < 0) { return false; } else { diff --git a/src/os/src/linux/linuxEnv.c b/src/os/src/linux/linuxEnv.c index e31364e2224e82bcc36e8e72a70b44620172be3f..1dc7abb13ab2ad0e488cf532e8846d28673fd9a0 100644 --- a/src/os/src/linux/linuxEnv.c +++ b/src/os/src/linux/linuxEnv.c @@ -35,7 +35,7 @@ char* taosGetCmdlineByPID(int pid) { static char cmdline[1024]; sprintf(cmdline, "/proc/%d/cmdline", pid); - int fd = open(cmdline, O_RDONLY); + int fd = open(cmdline, O_RDONLY | O_BINARY); if (fd >= 0) { int n = read(fd, cmdline, sizeof(cmdline) - 1); if (n < 0) n = 0; diff --git a/src/rpc/test/rserver.c b/src/rpc/test/rserver.c index e9c5fc47b8d75f9c14fe10cc5a94b5c82ee7a3dc..05f328a6fccf1fcbd6544be2849a160cfe006440 100644 --- a/src/rpc/test/rserver.c +++ b/src/rpc/test/rserver.c @@ -172,7 +172,7 @@ int main(int argc, char *argv[]) { tInfo("RPC server is running, ctrl-c to exit"); if (commit) { - dataFd = open(dataName, O_APPEND | O_CREAT | O_WRONLY, S_IRWXU | S_IRWXG | S_IRWXO); + dataFd = open(dataName, O_APPEND | O_CREAT | O_WRONLY | O_BINARY, S_IRWXU | S_IRWXG | S_IRWXO); if (dataFd<0) tInfo("failed to open data file, reason:%s", strerror(errno)); } diff --git a/src/sync/test/syncServer.c b/src/sync/test/syncServer.c index a9d9af666775c87f0e2159bdcbc64b71a7e9a1ef..82892d6e75044ae65dce8da6dbbcbc204b785558 100644 --- a/src/sync/test/syncServer.c +++ b/src/sync/test/syncServer.c @@ -43,7 +43,7 @@ int writeIntoWal(SWalHead *pHead) { char walName[280]; snprintf(walName, sizeof(walName), "%s/wal/wal.%d", path, walNum); (void)remove(walName); - dataFd = open(walName, O_CREAT | O_WRONLY, S_IRWXU | S_IRWXG | S_IRWXO); + dataFd = open(walName, O_CREAT | O_WRONLY | O_BINARY, S_IRWXU | S_IRWXG | S_IRWXO); if (dataFd < 0) { uInfo("failed to open wal file:%s(%s)", walName, strerror(errno)); return -1; diff --git a/src/tsdb/inc/tsdbFile.h b/src/tsdb/inc/tsdbFile.h index b9d5431de6bc3864a4a13ea30356033de76da178..2bbe9444cb3f60d2d9f054d3a5254656b70c2bc7 100644 --- a/src/tsdb/inc/tsdbFile.h +++ b/src/tsdb/inc/tsdbFile.h @@ -75,7 +75,7 @@ static FORCE_INLINE void tsdbSetMFileInfo(SMFile* pMFile, SMFInfo* pInfo) { pMFi static FORCE_INLINE int tsdbOpenMFile(SMFile* pMFile, int flags) { ASSERT(TSDB_FILE_CLOSED(pMFile)); - pMFile->fd = open(TSDB_FILE_FULL_NAME(pMFile), flags); + pMFile->fd = open(TSDB_FILE_FULL_NAME(pMFile), flags | O_BINARY); if (pMFile->fd < 0) { terrno = TAOS_SYSTEM_ERROR(errno); return -1; @@ -189,7 +189,7 @@ static FORCE_INLINE void tsdbSetDFileInfo(SDFile* pDFile, SDFInfo* pInfo) { pDFi static FORCE_INLINE int tsdbOpenDFile(SDFile* pDFile, int flags) { ASSERT(!TSDB_FILE_OPENED(pDFile)); - pDFile->fd = open(TSDB_FILE_FULL_NAME(pDFile), flags); + pDFile->fd = open(TSDB_FILE_FULL_NAME(pDFile), flags | O_BINARY); if (pDFile->fd < 0) { terrno = TAOS_SYSTEM_ERROR(errno); return -1; diff --git a/src/util/src/tlog.c b/src/util/src/tlog.c index 567402f3ed621a67654133ce43907c64a609dedd..a5ef86ee5a8d8c9304136d96730a7669386f857f 100644 --- a/src/util/src/tlog.c +++ b/src/util/src/tlog.c @@ -179,7 +179,7 @@ static void *taosThreadToOpenNewFile(void *param) { umask(0); - int32_t fd = open(name, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG | S_IRWXO); + int32_t fd = open(name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRWXU | S_IRWXG | S_IRWXO); if (fd < 0) { tsLogObj.openInProgress = 0; tsLogObj.lines = tsLogObj.maxLines - 1000; @@ -240,7 +240,7 @@ void taosResetLog() { } static bool taosCheckFileIsOpen(char *logFileName) { - int32_t fd = open(logFileName, O_WRONLY, S_IRWXU | S_IRWXG | S_IRWXO); + int32_t fd = open(logFileName, O_WRONLY | O_BINARY, S_IRWXU | S_IRWXG | S_IRWXO); if (fd < 0) { if (errno == ENOENT) { return false; @@ -328,7 +328,7 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) { pthread_mutex_init(&tsLogObj.logMutex, NULL); umask(0); - tsLogObj.logHandle->fd = open(fileName, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO); + tsLogObj.logHandle->fd = open(fileName, O_WRONLY | O_CREAT | O_BINARY, S_IRWXU | S_IRWXG | S_IRWXO); if (tsLogObj.logHandle->fd < 0) { printf("\nfailed to open log file:%s, reason:%s\n", fileName, strerror(errno)); diff --git a/src/util/src/tnote.c b/src/util/src/tnote.c index b691abc5b9f6f828edcc46ec3a5989baa083f443..193ad3263cfa502d2eae6507cf4e12d6033c8a8c 100644 --- a/src/util/src/tnote.c +++ b/src/util/src/tnote.c @@ -92,7 +92,7 @@ static void *taosThreadToOpenNewNote(void *param) { umask(0); - int32_t fd = open(name, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG | S_IRWXO); + int32_t fd = open(name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRWXU | S_IRWXG | S_IRWXO); if (fd < 0) { return NULL; } @@ -132,7 +132,7 @@ static int32_t taosOpenNewNote(SNoteObj *pNote) { } static bool taosCheckNoteIsOpen(char *noteName, SNoteObj *pNote) { - int32_t fd = open(noteName, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO); + int32_t fd = open(noteName, O_WRONLY | O_CREAT | O_BINARY, S_IRWXU | S_IRWXG | S_IRWXO); if (fd < 0) { fprintf(stderr, "failed to open note:%s reason:%s\n", noteName, strerror(errno)); return true; @@ -207,7 +207,7 @@ static int32_t taosOpenNoteWithMaxLines(char *fn, int32_t maxLines, int32_t maxN pthread_mutex_init(&pNote->mutex, NULL); umask(0); - pNote->fd = open(noteName, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO); + pNote->fd = open(noteName, O_WRONLY | O_CREAT | O_BINARY, S_IRWXU | S_IRWXG | S_IRWXO); if (pNote->fd < 0) { fprintf(stderr, "failed to open note file:%s reason:%s\n", noteName, strerror(errno));