NAME
fdatasync - synchronize a file's in-core data with that on disk
SYNOPSIS
#include <unistd.h>
I int fdatasync(int fd );
DESCRIPTION
R fdatasync ()
flushes all data buffers of a file to disk (before the system
call returns).
It resembles
fsync(2)
but is not required to update metadata such as the file last access time.
Applications that access databases or log files often write a tiny
data fragment (e.g., one line in a log file) and then call
fsync(2)
immediately in order to ensure that the written data is physically
stored on the harddisk.
Unfortunately,
fsync(2)
will always initiate two write operations: one for the newly written
data and another one in order to update the modification time stored
in the inode.
If the modification time is not a part of the transaction
concept
R fdatasync ()
can be used to avoid unnecessary inode disk write operations.
RETURN VALUE
On success, zero is returned.
On error, -1 is returned, and
errno
is set appropriately.
ERRORS
EBADF
fd
is not a valid file descriptor open for writing.
EIO
An error occurred during synchronization.
R EROFS , EINVAL
fd
is bound to a special file which does not support synchronization.
CONFORMING TO
POSIX.1-2001.
AVAILABILITY
On POSIX systems on which
R fdatasync ()
is available,
_POSIX_SYNCHRONIZED_IO
is defined in
<unistd.h>
to a value greater than 0.
(See also
sysconf(3).)
NOTES
In Linux 2.2 and earlier,
R fdatasync ()
is equivalent to
fsync(2),
and so has no performance advantage.
SEE ALSO