Hi,
A small nitpick here: + struct stat image_stat; + if (fstat(fileno(image), &image_stat) != 0) { + msg_gerr("Error: getting metadata of file "%s" failed: %s\n", filename, strerror(errno)); + ret = 1; + goto out; + } + // Try to fsync() only regular files if that function is available at all (e.g. not provided by MinGW). +#if defined(_POSIX_FSYNC) && (_POSIX_FSYNC != -1) + if (S_ISREG(image_stat.st_mode)) { + if (fsync(fileno(image))) { + msg_gerr("Error: fsyncing file "%s" failed: %s\n", filename, strerror(errno)); + ret = 1; + } + } +#endif
Do we want to fstat if we're not using the results (on mingw), meaning i suggest move the ifdef above struct stat definition. Atleast with that moved, Acked-by: Urja Rannikko urjaman@gmail.com