Seth Woolley's Man Viewer

fdatasync(2) - fdatasync, fdatasync - synchronize a file's in-core data with that on disk - man 2 fdatasync

([section] manual, -k keyword, -K [section] search, -f whatis)
man plain no title

FDATASYNC(2)               Linux Programmer's Manual              FDATASYNC(2)



NAME
       fdatasync - synchronize a file(1,n)'s in-core data with that on disk

SYNOPSIS
       #include <unistd.h>

       int fdatasync(int fd);

DESCRIPTION
       fdatasync flushes all data buffers of a file(1,n) to disk (before the system
       call returns).  It resembles fsync but is not required  to  update(7,n)  the
       metadata such as access(2,5) time.

       Applications that access(2,5) databases or log files often write(1,2) a tiny data
       fragment (e.g., one line in(1,8) a log file(1,n)) and then call fsync immediately
       in(1,8)  order  to  ensure that the written data is physically stored on the
       harddisk. Unfortunately, fsync will always initiate  two  write(1,2)  opera-
       tions:  one  for  the  newly  written  data and another one in(1,8) order to
       update(7,n) the modification time(1,2,n) stored in(1,8) the inode. If  the  modification
       time(1,2,n)  is not a part of the transaction concept fdatasync can be used to
       avoid unnecessary inode disk write(1,2) operations.

RETURN VALUE
       On success, zero is returned.  On error(8,n), -1 is returned, and  errno  is
       set(7,n,1 builtins) appropriately.

ERRORS
       EBADF  fd is not a valid file(1,n) descriptor open(2,3,n) for writing.

       EIO    An error(8,n) occurred during synchronization.

       EROFS, EINVAL
              fd  is  bound  to a special file(1,n) which does not support synchro-
              nization.

BUGS
       Currently (Linux 2.2) fdatasync is equivalent to fsync.

AVAILABILITY
       On POSIX systems  on  which  fdatasync  is  available,  _POSIX_SYNCHRO-
       NIZED_IO  is defined in(1,8) <unistd.h> to a value greater than 0. (See also
       sysconf(3).)

CONFORMING TO
       POSIX1b (formerly POSIX.4)

SEE ALSO
       fsync(2)
       B.O. Gallmeister, POSIX.4, O'Reilly, pp. 220-223 and 343.



Linux 1.3.86                      1996-04-13                      FDATASYNC(2)

References for this manual (incoming links)