diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2014-10-10 15:30:36 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2014-10-10 15:30:36 -0400 |
commit | 1588626525293cc0579ff3e3a6b13888ccb8c464 (patch) | |
tree | 8c0310dd26636c9b6c4bcef56fe50b6e5b1b59f3 | |
parent | 81fe5f64f88a5d8027e32b281522b5ee4b4d4401 (diff) | |
download | mongo-1588626525293cc0579ff3e3a6b13888ccb8c464.tar.gz |
Fix backup on Windows by using O_BINARY
-rw-r--r-- | src/include/posix.h | 3 | ||||
-rw-r--r-- | src/utilities/util_backup.c | 5 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/include/posix.h b/src/include/posix.h index 1f422b3ebd4..7cb34b82c47 100644 --- a/src/include/posix.h +++ b/src/include/posix.h @@ -15,3 +15,6 @@ #ifndef LLONG_MIN #define LLONG_MIN (-0x7fffffffffffffffLL - 1) #endif + +/* Define O_BINARY for Posix systems */ +#define O_BINARY 0 diff --git a/src/utilities/util_backup.c b/src/utilities/util_backup.c index 1ad6a181e00..eaa823334e3 100644 --- a/src/utilities/util_backup.c +++ b/src/utilities/util_backup.c @@ -127,13 +127,14 @@ copy(const char *name, const char *directory) /* Open the read file. */ if (snprintf(cbuf, CBUF_LEN, "%s/%s", home, name) >= CBUF_LEN) goto memerr; - if ((ifd = open(cbuf, O_RDONLY, 0)) < 0) + if ((ifd = open(cbuf, O_BINARY | O_RDONLY, 0)) < 0) goto readerr; /* Open the write file. */ if (snprintf(cbuf, CBUF_LEN, "%s/%s", directory, name) >= CBUF_LEN) goto memerr; - if ((ofd = open(cbuf, O_CREAT | O_WRONLY | O_TRUNC, 0666)) < 0) + if ((ofd = open( + cbuf, O_BINARY | O_CREAT | O_WRONLY | O_TRUNC, 0666)) < 0) goto writerr; /* Copy the file. */ |