fsync(2) System Calls Manual fsync(2) fsync, fdatasync - LIBRARY Standard C library (libc, -lc) #include int fsync(int fd); int fdatasync(int fd); glibc (. feature_test_macros(7)): fsync(): glibc 2.16 and later: No feature test macros need be defined glibc up to and including 2.15: _BSD_SOURCE || _XOPEN_SOURCE || /* Since glibc 2.8: */ _POSIX_C_SOURCE >= 200112L fdatasync(): _POSIX_C_SOURCE >= 199309L || _XOPEN_SOURCE >= 500 fsync() (<<>>) (in-core) (. ., ) , fd, ( ) , . ( ). , , . , , ( inode(7)). fsync() , , , . fsync() . fdatasync() fsync(), , . , st_atime st_mtime ( , ; inode(7)) , . , (st_size, , , ftruncate(2)) . fdatasync() , . On success, these system calls return zero. On error, -1 is returned, and errno is set to indicate the error. EBADF fd . EINTR The function was interrupted by a signal; see signal(7). EIO . , - . Linux 4.13, (write-back) , . (, NFS) , . (, ) , . ENOSPC . EROFS EINVAL fd (, , FIFO ), . ENOSPC EDQUOT fd NFS , write(2), - - . POSIX, fdatasync(), _POSIX_SYNCHRONIZED_IO 0 (. sysconf(3)). POSIX.1-2008. POSIX.1-2001, 4.2BSD. Linux 2.2 , fdatasync() fsync(), . fsync() , , (flush) . hdparm(8) sdparm(8), . Under AT&T UNIX System V Release 4 fd needs to be opened for writing. This is by itself incompatible with the original BSD interface and forbidden by POSIX, but nevertheless survives in HP-UX and AIX. . sync(1), bdflush(2), open(2), posix_fadvise(2), pwritev(2), sync(2), sync_file_range(2), fflush(3), fileno(3), hdparm(8), mount(8) Azamat Hackimov , Dmitry Bolkhovskikh , Yuri Kozlov ; GNU 3 , . . , , . Linux man-pages 6.06 31 2023 . fsync(2)