1 .\" $NetBSD: fsync.2,v 1.17 2010/05/17 12:38:04 jruoho Exp $
3 .\" Copyright (c) 1983, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. Neither the name of the University nor the names of its contributors
15 .\" may be used to endorse or promote products derived from this software
16 .\" without specific prior written permission.
18 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" @(#)fsync.2 8.1 (Berkeley) 6/4/93
38 .Nd "synchronize a file's in-core state with that on disk"
46 .Fn fsync_range "int fd" "int how" "off_t start" "off_t length"
49 causes all modified data and attributes of
51 to be moved to a permanent storage device.
52 This normally results in all in-core modified copies
53 of buffers for the associated file to be written to a disk.
56 should be used by programs that require a file to be
57 in a known state, for example, in building a simple transaction
61 causes all modified data starting at
67 to be written to permanent storage.
70 requires that the file
72 must be open for writing.
75 may flush the file data in one of two manners:
76 .Bl -tag -width FDATASYNC -offset indent
78 Synchronize the file data and sufficient meta-data to retrieve the
79 data for the specified range.
81 Synchronize all modified file data and meta-data for the specified range.
86 does not flush disk caches, assuming that storage media are able to ensure
87 completed writes are transfered to media.
90 flag may be included in the
92 parameter to trigger flushing of all disk caches for the file.
98 will synchronize all of the file data.
100 A 0 value is returned on success.
101 A \-1 value indicates an error.
110 is not a valid descriptor.
113 refers to a socket, not to a file.
115 An I/O error occurred while reading from or writing to the file system.
124 is not open for writing.
133 For optimal efficiency, the
135 call requires that the file system containing the file referenced by
137 support partial synchronization of file data.
138 For file systems which do
139 not support partial synchronization, the entire file will be synchronized
140 and the call will be the equivalent of calling
148 function call appeared in
153 function call first appeared in
155 and is modeled after the function available in AIX.