Commit 75b72804 authored by Mike Hibler's avatar Mike Hibler
Browse files

Check that fsync is supported on output file of imagezip.

Part of our hack strategy to detect and correct transient NFS errors
is to fsync after every file write and check for errors. However, some
devices don't support fsync. So, for example, if you were trying to
imagezip to /dev/null (to benchmark or check the resulting image size)
fsync would always fail and we would keep retrying the write forever.

There is already a "-N" option to avoid such checks and retries, but
Mike can never remember that!
parent 701cb551
......@@ -818,6 +818,22 @@ main(int argc, char *argv[])
exit(1);
}
outcanseek = 1;
/*
* XXX retrywrites is a hack to avoid transient NFS
* write errors: we use fsync after every write to
* check that it worked, re-trying if not. However,
* some devices (e.g., /dev/null) do not support
* fsync, so check for that here and disable the
* retry if necessary.
*/
if (retrywrites &&
fsync(outfd) < 0 && errno == EINVAL) {
fprintf(stderr,
"WARNING: '%s' does not support fsync,"
" write errors may not be detected "
"or corrected.\n", outfilename);
retrywrites = 0;
}
}
else {
outfd = fileno(stdout);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment