FSYNC(2) — SYSTEM CALLS
NAME
fsync − synchronize a file’s in-core state with that on disk
SYNOPSIS
int fsync(fd)
int fd;
DESCRIPTION
fsync() moves all modified data and attributes of fd to a permanent storage device: all in-core modified copies of buffers for the associated 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.
RETURN VALUES
fsync() returns:
0 on success.
−1 on failure and sets errno to indicate the error.
ERRORS
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.
SEE ALSO
Solbourne Computer, Inc. — 12 Dec 1990