Windows: always open files in binary mode
On Windows, open() defaults to text mode, causing control characters
to be interpreted. Avoid this by passing the _O_BINARY flag.
Signed-off-by: Jens Axboe <axboe@fb.com>
diff --git a/filesetup.c b/filesetup.c
index b6cf2e7..ad7fb85 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -69,6 +69,10 @@
if (new_layout)
flags |= O_TRUNC;
+#ifdef WIN32
+ flags |= _O_BINARY;
+#endif
+
dprint(FD_FILE, "open file %s, flags %x\n", f->file_name, flags);
f->fd = open(f->file_name, flags, 0644);
if (f->fd < 0) {
@@ -481,6 +485,10 @@
from_hash = 0;
}
+#ifdef WIN32
+ flags |= _O_BINARY;
+#endif
+
f->fd = open(f->file_name, flags, 0600);
return from_hash;
}
@@ -1040,7 +1048,7 @@
unsigned long seed;
seed = td->rand_seeds[FIO_RAND_BLOCK_OFF];
-
+
if (!lfsr_init(&f->lfsr, blocks, seed, 0))
continue;
} else if (!td->o.norandommap) {