FSYNC(2) System Calls Manual FSYNC(2)
fsync - synchronize a file's in-core state with that on disk
fsync() moves all modified data and attributes of fd to a permanent
storage device: all in-core modified copies of buffers for the associ-
ated file have been written to a disk when the call returns. Note:
this is different than sync(2) which schedules disk I/O for all files
(as though an fsync() had been done on all files) but returns before
the I/O completes.
fsync() should be used by programs which require a file to be in a
known state; for example, a program which contains a simple transaction
facility might use it to ensure that all modifications to a file or
files caused by a transaction were recorded on disk.
0 on success.
-1 on failure and sets errno to indicate the error.
EBADF fd is not a valid descriptor.
EINVAL fd refers to a socket, not a file.
EIO An I/O error occurred while reading from or writing to
the file system.
21 January 1990 FSYNC(2)