]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/fdatasync.2
strip trailing white space
[thirdparty/man-pages.git] / man2 / fdatasync.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Copyright (C) 1996 Andries Brouwer (aeb@cwi.nl)
4 .\" Copyright (C) 1996 Markus Kuhn.
5 .\"
6 .\" [This version merged from two independently written pages - aeb]
7 .\"
8 .\" Permission is granted to make and distribute verbatim copies of this
9 .\" manual provided the copyright notice and this permission notice are
10 .\" preserved on all copies.
11 .\"
12 .\" Permission is granted to copy and distribute modified versions of this
13 .\" manual under the conditions for verbatim copying, provided that the
14 .\" entire resulting derived work is distributed under the terms of a
15 .\" permission notice identical to this one.
16 .\"
17 .\" Since the Linux kernel and libraries are constantly changing, this
18 .\" manual page may be incorrect or out-of-date. The author(s) assume no
19 .\" responsibility for errors or omissions, or for damages resulting from
20 .\" the use of the information contained herein. The author(s) may not
21 .\" have taken the same level of care in the production of this manual,
22 .\" which is licensed free of charge, as they might when working
23 .\" professionally.
24 .\"
25 .\" Formatted or processed versions of this manual, if unaccompanied by
26 .\" the source, must acknowledge the copyright and authors of this work.
27 .\"
28 .\" 1996-04-12 Andries Brouwer <aeb@cwi.nl>
29 .\" 1996-04-13 Markus Kuhn <mskuhn@cip.informatik.uni-erlangen.de>
30 .\"
31 .TH FDATASYNC 2 1996-04-13 "Linux" "Linux Programmer's Manual"
32 .SH NAME
33 fdatasync \- synchronize a file's in-core data with that on disk
34 .SH SYNOPSIS
35 .B #include <unistd.h>
36 .sp
37 .BI "int fdatasync(int " fd );
38 .SH DESCRIPTION
39 .BR fdatasync ()
40 flushes all data buffers of a file to disk (before the system
41 call returns).
42 It resembles
43 .BR fsync (2)
44 but is not required to update metadata such as the file last access time.
45
46 Applications that access databases or log files often write a tiny
47 data fragment (e.g., one line in a log file) and then call
48 .BR fsync (2)
49 immediately in order to ensure that the written data is physically
50 stored on the harddisk.
51 Unfortunately,
52 .BR fsync (2)
53 will always initiate two write operations: one for the newly written
54 data and another one in order to update the modification time stored
55 in the inode.
56 If the modification time is not a part of the transaction
57 concept
58 .BR fdatasync ()
59 can be used to avoid unnecessary inode disk write operations.
60 .SH "RETURN VALUE"
61 On success, zero is returned.
62 On error, \-1 is returned, and
63 .I errno
64 is set appropriately.
65 .SH ERRORS
66 .TP
67 .B EBADF
68 .I fd
69 is not a valid file descriptor open for writing.
70 .TP
71 .B EIO
72 An error occurred during synchronization.
73 .TP
74 .BR EROFS ", " EINVAL
75 .I fd
76 is bound to a special file which does not support synchronization.
77 .SH "CONFORMING TO"
78 POSIX.1-2001.
79 .SH AVAILABILITY
80 On POSIX systems on which
81 .BR fdatasync ()
82 is available,
83 .B _POSIX_SYNCHRONIZED_IO
84 is defined in
85 .I <unistd.h>
86 to a value greater than 0.
87 (See also
88 .BR sysconf (3).)
89 .\" POSIX.1-2001: It shall be defined to -1 or 0 or 200112L.
90 .\" -1: unavailable, 0: ask using sysconf().
91 .\" glibc defines them to 1.
92 .SH NOTES
93 In Linux 2.2 and earlier,
94 .BR fdatasync ()
95 is equivalent to
96 .BR fsync (2),
97 and so has no performance advantage.
98 .SH "SEE ALSO"
99 .BR fsync (2),
100 .BR sync_file_range (2)
101 .br
102 B.O. Gallmeister, POSIX.4, O'Reilly, pp. 220-223 and 343.