2 .\" Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
3 .\" Copyright 1989 AT&T
4 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
5 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
6 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
7 .TH FSYNC 3C "Feb 5, 2008"
9 fsync \- synchronize changes to a file
15 \fBint\fR \fBfsync\fR(\fBint\fR \fIfildes\fR);
21 The \fBfsync()\fR function moves all modified data and attributes of the file
22 descriptor \fIfildes\fR to a storage device. When \fBfsync()\fR returns, all
23 in-memory modified copies of buffers associated with \fIfildes\fR have been
24 written to the physical medium. The \fBfsync()\fR function is different from
25 \fBsync()\fR, which schedules disk I/O for all files but returns before the
26 I/O completes. The \fBfsync()\fR function forces all outstanding data
27 operations to synchronized file integrity completion (see \fBfcntl.h\fR(3HEAD)
28 definition of \fBO_SYNC\fR.)
31 The \fBfsync()\fR function forces all currently queued I/O operations
32 associated with the file indicated by the file descriptor \fIfildes\fR to the
33 synchronized I/O completion state. All I/O operations are completed as defined
34 for synchronized I/O file integrity completion.
38 Upon successful completion, \fB0\fR is returned. Otherwise, \fB\(mi1\fR is
39 returned and \fBerrno\fR is set to indicate the error. If the \fBfsync()\fR
40 function fails, outstanding I/O operations are not guaranteed to have been
45 The \fBfsync()\fR function will fail if:
52 The \fIfildes\fR argument is not a valid file descriptor.
61 A signal was caught during execution of the \fBfsync()\fR function.
70 An I/O error occurred while reading from or writing to the file system.
79 There was no free space remaining on the device containing the file.
88 Remote connection timed out. This occurs when the file is on an \fBNFS\fR file
89 system mounted with the \fIsoft\fR option. See \fBmount_nfs\fR(1M).
94 In the event that any of the queued I/O operations fail, \fBfsync()\fR returns
95 the error conditions defined for \fBread\fR(2) and \fBwrite\fR(2).
99 The \fBfsync()\fR function should be used by applications that require that a
100 file be in a known state. For example, an application that contains a simple
101 transaction facility might use \fBfsync()\fR to ensure that all changes to a
102 file or files caused by a given transaction were recorded on a storage medium.
105 The manner in which the data reach the physical medium depends on both
106 implementation and hardware. The \fBfsync()\fR function returns when notified
107 by the device driver that the write has taken place.
111 See \fBattributes\fR(5) for descriptions of the following attributes:
119 ATTRIBUTE TYPE ATTRIBUTE VALUE
121 Interface Stability Committed
123 MT-Level Async-Signal-Safe
125 Standard See \fBstandards\fR(5).
131 \fBmount_nfs\fR(1M), \fBread\fR(2), \fBsync\fR(2), \fBwrite\fR(2),
132 \fBfcntl.h\fR(3HEAD), \fBfdatasync\fR(3C), \fBattributes\fR(5),