From: aggieNick02 Date: Fri, 2 Sep 2022 23:19:43 +0000 (-0500) Subject: Fix log compression storage on windows X-Git-Tag: fio-3.33~50^2 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=a7c386edc19f3ef121b037b60b02852ffbcd6d65;p=fio.git Fix log compression storage on windows Set the file open mode to be binary instead of text when dealing with compressed log files. This fixes log compression storage not working on windows, and lets the test added in PR https://github.com/axboe/fio/pull/1458 pass on windows. Signed-off-by: Nick Neumann --- diff --git a/iolog.c b/iolog.c index 41d3e473..aa9c3bb1 100644 --- a/iolog.c +++ b/iolog.c @@ -1218,7 +1218,7 @@ int iolog_file_inflate(const char *file) void *buf; FILE *f; - f = fopen(file, "r"); + f = fopen(file, "rb"); if (!f) { perror("fopen"); return 1; @@ -1300,10 +1300,21 @@ void flush_log(struct io_log *log, bool do_append) void *buf; FILE *f; + /* + * If log_gz_store is true, we are writing a binary file. + * Set the mode appropriately (on all platforms) to avoid issues + * on windows (line-ending conversions, etc.) + */ if (!do_append) - f = fopen(log->filename, "w"); + if (log->log_gz_store) + f = fopen(log->filename, "wb"); + else + f = fopen(log->filename, "w"); else - f = fopen(log->filename, "a"); + if (log->log_gz_store) + f = fopen(log->filename, "ab"); + else + f = fopen(log->filename, "a"); if (!f) { perror("fopen log"); return;