From 44ec7ce70e6b0beb13019b821c3831935f01c6f9 Mon Sep 17 00:00:00 2001 From: Michel Machado Date: Tue, 20 May 2014 09:58:58 -0400 Subject: [PATCH] f3read: fix for Windows/Cygwin Windows requires that the file descriptor passed to fdatasync(2) to be writable. Tom Hall reported the issue and proposed the solution. --- f3read.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/f3read.c b/f3read.c index 60771f0..6e95385 100644 --- a/f3read.c +++ b/f3read.c @@ -54,7 +54,14 @@ static void validate_file(const char *path, int number, full_fn_from_number(full_fn, &filename, path, number); printf("Validating file %s ... %s", filename, progress ? BLANK : ""); fflush(stdout); +#ifdef CYGWIN + /* We don't need write access, but some kernels require that + * the file descriptor passed to fdatasync(2) to be writable. + */ + f = fopen(full_fn, "rb+"); +#else f = fopen(full_fn, "rb"); +#endif if (!f) err(errno, "Can't open file %s", full_fn); fd = fileno(f);