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.
This commit is contained in:
Michel Machado 2014-05-20 09:58:58 -04:00
parent 7bd73cc434
commit 44ec7ce70e

View File

@ -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);