FSYNC(2) | Linux Programmer's Manual | FSYNC(2) |
NAME
fsync, fdatasync - synchronize a file's in-core state with storage deviceSYNOPSIS
#include <unistd.h>Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
|| /* since glibc 2.8: */ _POSIX_C_SOURCE >= 200112L
DESCRIPTION
fsync() 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 VALUE
On success, these system calls return zero. On error, -1 is returned, and errno is set appropriately.ERRORS
- EBADF
- fd is not a valid open file descriptor.
- EIO
- An error occurred during synchronization.
- EROFS, EINVAL
- fd is bound to a special file which does not support synchronization.
CONFORMING TO
4.3BSD, POSIX.1-2001.AVAILABILITY
On 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).)NOTES
On some UNIX systems (but not Linux), fd must be a writable file descriptor.SEE ALSO
bdflush(2), open(2), sync(2), sync_file_range(2), hdparm(8), mount(8), sync(8), update(8)COLOPHON
This 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/.2012-02-27 | Linux |