rewritten to use writev by Sam; add Berkeley specific header
[unix-history] / usr / src / lib / libc / sys / fsync.2
CommitLineData
76a31391
KM
1.\" Copyright (c) 1983 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
7b12e899 5.\" @(#)fsync.2 6.4 (Berkeley) %G%
76a31391 6.\"
bc55b6ca 7.TH FSYNC 2 ""
76a31391
KM
8.UC 5
9.SH NAME
10fsync \- synchronize a file's in-core state with that on disk
11.SH SYNOPSIS
12.ft B
13fsync(fd)
14.br
15int fd;
16.ft R
17.SH DESCRIPTION
18.I Fsync
19causes all modified data and attributes of \fIfd\fP
20to be moved to a permanent storage device.
21This normally results in all in-core modified copies
22of buffers for the associated file to be written to a disk.
23.PP
24.I Fsync
b4c94b6d 25should be used by programs that require a file to be
7b12e899 26in a known state, for example, in building a simple transaction
76a31391
KM
27facility.
28.SH "RETURN VALUE
29A 0 value is returned on success. A \-1 value indicates
30an error.
31.SH "ERRORS
32The \fIfsync\fP fails if:
33.TP 15
34[EBADF]
35\fIFd\fP is not a valid descriptor.
36.TP 15
37[EINVAL]
38\fIFd\fP refers to a socket, not to a file.
fd690c8b
KM
39.TP 15
40[EIO]
41An I/O error occurred while reading from or writing to the file system.
76a31391
KM
42.SH "SEE ALSO"
43sync(2), sync(8), update(8)