int fd = -1;
#ifdef O_TMPFILE
fd = open(path.c_str(), O_WRONLY | O_TMPFILE, 0640);
- if (fd == -1 && errno != EOPNOTSUPP) {
+ if (fd == -1 && errno != EOPNOTSUPP && errno != EISDIR) {
perror(path.c_str());
exit(1);
}
fseek(outfp, 0, SEEK_SET);
fwrite(&hdr, sizeof(hdr), 1, outfp);
+ // This is needed on systems that simulate linkat() by copying
+ // the contents of the file instead of linking.
+ fflush(outfp);
+
if (!temp_filename.empty()) {
if (rename(temp_filename.c_str(), outfile.c_str()) == -1) {
perror("rename");