From: Bruce Cran Date: Mon, 28 Apr 2014 21:54:43 +0000 (-0600) Subject: Windows: always open files in binary mode X-Git-Tag: fio-2.1.9~11 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=9c0f3f3279985b724c2f1358bb05cc2c795f2265;ds=sidebyside 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 --- diff --git a/filesetup.c b/filesetup.c index b6cf2e7d..ad7fb855 100644 --- a/filesetup.c +++ b/filesetup.c @@ -69,6 +69,10 @@ static int extend_file(struct thread_data *td, struct fio_file *f) 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 @@ int file_lookup_open(struct fio_file *f, int flags) from_hash = 0; } +#ifdef WIN32 + flags |= _O_BINARY; +#endif + f->fd = open(f->file_name, flags, 0600); return from_hash; } @@ -1040,7 +1048,7 @@ int init_random_map(struct thread_data *td) 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) {