diff --git a/src/bin/pg_test_fsync/pg_test_fsync.c b/src/bin/pg_test_fsync/pg_test_fsync.c index c607b5371c0..dfe1991d551 100644 --- a/src/bin/pg_test_fsync/pg_test_fsync.c +++ b/src/bin/pg_test_fsync/pg_test_fsync.c @@ -223,7 +223,7 @@ test_open(void) /* * test if we can open the target file */ - if ((tmpfile = open(filename, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR)) == -1) + if ((tmpfile = open(filename, O_RDWR | O_CREAT | PG_BINARY, S_IRUSR | S_IWUSR)) == -1) die("could not open output file"); needs_unlink = 1; if (write(tmpfile, full_buf, XLOG_SEG_SIZE) != XLOG_SEG_SIZE) @@ -257,7 +257,7 @@ test_sync(int writes_per_op) fflush(stdout); #ifdef OPEN_DATASYNC_FLAG - if ((tmpfile = open(filename, O_RDWR | O_DSYNC | PG_O_DIRECT, 0)) == -1) + if ((tmpfile = open(filename, O_RDWR | O_DSYNC | PG_O_DIRECT | PG_BINARY, 0)) == -1) { printf(NA_FORMAT, _("n/a*")); fs_warning = true; @@ -287,7 +287,7 @@ test_sync(int writes_per_op) fflush(stdout); #ifdef HAVE_FDATASYNC - if ((tmpfile = open(filename, O_RDWR, 0)) == -1) + if ((tmpfile = open(filename, O_RDWR | PG_BINARY, 0)) == -1) die("could not open output file"); START_TIMER; for (ops = 0; alarm_triggered == false; ops++) @@ -311,7 +311,7 @@ test_sync(int writes_per_op) printf(LABEL_FORMAT, "fsync"); fflush(stdout); - if ((tmpfile = open(filename, O_RDWR, 0)) == -1) + if ((tmpfile = open(filename, O_RDWR | PG_BINARY, 0)) == -1) die("could not open output file"); START_TIMER; for (ops = 0; alarm_triggered == false; ops++) @@ -334,7 +334,7 @@ test_sync(int writes_per_op) fflush(stdout); #ifdef HAVE_FSYNC_WRITETHROUGH - if ((tmpfile = open(filename, O_RDWR, 0)) == -1) + if ((tmpfile = open(filename, O_RDWR | PG_BINARY, 0)) == -1) die("could not open output file"); START_TIMER; for (ops = 0; alarm_triggered == false; ops++) @@ -360,7 +360,7 @@ test_sync(int writes_per_op) fflush(stdout); #ifdef OPEN_SYNC_FLAG - if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG | PG_O_DIRECT, 0)) == -1) + if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG | PG_O_DIRECT | PG_BINARY, 0)) == -1) { printf(NA_FORMAT, _("n/a*")); fs_warning = true; @@ -427,7 +427,7 @@ test_open_sync(const char *msg, int writes_size) fflush(stdout); #ifdef OPEN_SYNC_FLAG - if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG | PG_O_DIRECT, 0)) == -1) + if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG | PG_O_DIRECT | PG_BINARY, 0)) == -1) printf(NA_FORMAT, _("n/a*")); else { @@ -475,7 +475,7 @@ test_file_descriptor_sync(void) START_TIMER; for (ops = 0; alarm_triggered == false; ops++) { - if ((tmpfile = open(filename, O_RDWR, 0)) == -1) + if ((tmpfile = open(filename, O_RDWR | PG_BINARY, 0)) == -1) die("could not open output file"); if (write(tmpfile, buf, XLOG_BLCKSZ) != XLOG_BLCKSZ) die("write failed"); @@ -487,7 +487,7 @@ test_file_descriptor_sync(void) * open and close the file again to be consistent with the following * test */ - if ((tmpfile = open(filename, O_RDWR, 0)) == -1) + if ((tmpfile = open(filename, O_RDWR | PG_BINARY, 0)) == -1) die("could not open output file"); close(tmpfile); } @@ -503,13 +503,13 @@ test_file_descriptor_sync(void) START_TIMER; for (ops = 0; alarm_triggered == false; ops++) { - if ((tmpfile = open(filename, O_RDWR, 0)) == -1) + if ((tmpfile = open(filename, O_RDWR | PG_BINARY, 0)) == -1) die("could not open output file"); if (write(tmpfile, buf, XLOG_BLCKSZ) != XLOG_BLCKSZ) die("write failed"); close(tmpfile); /* reopen file */ - if ((tmpfile = open(filename, O_RDWR, 0)) == -1) + if ((tmpfile = open(filename, O_RDWR | PG_BINARY, 0)) == -1) die("could not open output file"); if (fsync(tmpfile) != 0) die("fsync failed"); @@ -534,7 +534,7 @@ test_non_sync(void) START_TIMER; for (ops = 0; alarm_triggered == false; ops++) { - if ((tmpfile = open(filename, O_RDWR, 0)) == -1) + if ((tmpfile = open(filename, O_RDWR | PG_BINARY, 0)) == -1) die("could not open output file"); if (write(tmpfile, buf, XLOG_BLCKSZ) != XLOG_BLCKSZ) die("write failed");