Skip to content

Commit

Permalink
fileutil_fsync: use F_FULLFSYNC if available
Browse files Browse the repository at this point in the history
We only expect to see this flag on macOS, but it's not impossible that
other OSes may add F_FULLFSYNC in the future.
  • Loading branch information
gperciva committed Feb 23, 2025
1 parent 54b41e7 commit afea5cb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib-platform/util/fileutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ fileutil_fsync(FILE * fp, const char * name)
goto err0;
}

#ifdef F_FULLFSYNC
/*
* MacOS-specific "ask the drive to flush all buffered data".
* Not supported on all filesystems. Even on supported filesystems,
* some FireWire drives are known to ignore this request.
*/
if (fcntl(fd, F_FULLFSYNC)) {
warnp("fcntl");
goto err0;
}
#endif

/* Success! */
return (0);

Expand Down

0 comments on commit afea5cb

Please sign in to comment.