|FSYNC(2)||Linux Programmer's Manual||FSYNC(2)|
NAMEfsync, fdatasync - synchronize a file's in-core state with storage device
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
|| /* since glibc 2.8: */ _POSIX_C_SOURCE >= 200112L
DESCRIPTIONfsync() transfers ("flushes") all modified in-core data of (i.e., modified buffer cache pages for) the file referred to by the file descriptor fd to the disk device (or other permanent storage device) so that all changed information can be retrieved even after the system crashed or was rebooted. This includes writing through or flushing a disk cache if present. The call blocks until the device reports that the transfer has completed. It also flushes metadata information associated with the file (see stat(2)).
RETURN VALUEOn success, these system calls return zero. On error, -1 is returned, and errno is set appropriately.
- fd is not a valid open file descriptor.
- An error occurred during synchronization.
- EROFS, EINVAL
- fd is bound to a special file which does not support synchronization.
CONFORMING TO4.3BSD, POSIX.1-2001.
AVAILABILITYOn POSIX systems on which fdatasync() is available, _POSIX_SYNCHRONIZED_IO is defined in <unistd.h> to a value greater than 0. (See also sysconf(3).)
NOTESOn some UNIX systems (but not Linux), fd must be a writable file descriptor.
SEE ALSObdflush(2), open(2), sync(2), sync_file_range(2), hdparm(8), mount(8), sync(8), update(8)
COLOPHONThis page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/.