1FDATASYNC(2)               Linux Programmer's Manual              FDATASYNC(2)
2
3
4

NAME

6       fdatasync - synchronize a file's in-core data with that on disk
7

SYNOPSIS

9       #include <unistd.h>
10
11       int fdatasync(int fd);
12

DESCRIPTION

14       fdatasync() flushes all data buffers of a file to disk (before the sys‐
15       tem call returns).  It resembles fsync() but is not required to  update
16       the metadata such as access time.
17
18       Applications that access databases or log files often write a tiny data
19       fragment (e.g., one line in a log file) and then call  fsync()  immedi‐
20       ately  in order to ensure that the written data is physically stored on
21       the harddisk. Unfortunately, fsync() will  always  initiate  two  write
22       operations:  one for the newly written data and another one in order to
23       update the modification time stored in the inode. If  the  modification
24       time  is  not a part of the transaction concept fdatasync() can be used
25       to avoid unnecessary inode disk write operations.
26

RETURN VALUE

28       On success, zero is returned.  On error, -1 is returned, and  errno  is
29       set appropriately.
30

ERRORS

32       EBADF  fd is not a valid file descriptor open for writing.
33
34       EIO    An error occurred during synchronization.
35
36       EROFS, EINVAL
37              fd  is  bound  to a special file which does not support synchro‐
38              nization.
39

BUGS

41       Currently (Linux 2.2) fdatasync() is equivalent to fsync().
42

AVAILABILITY

44       On POSIX systems on which  fdatasync()  is  available,  _POSIX_SYNCHRO‐
45       NIZED_IO  is defined in <unistd.h> to a value greater than 0. (See also
46       sysconf(3).)
47

CONFORMING TO

49       POSIX.1-2001.
50

SEE ALSO

52       fsync(2), sync_file_range(2)
53       B.O. Gallmeister, POSIX.4, O'Reilly, pp. 220-223 and 343.
54
55
56
57Linux 1.3.86                      1996-04-13                      FDATASYNC(2)
Impressum