update from Donn -- fixes for pcc
[unix-history] / usr / src / lib / libc / sys / fsync.2
CommitLineData
88b3ccf2
KB
1.\" Copyright (c) 1983 The Regents of the University of California.
2.\" All rights reserved.
76a31391 3.\"
91cff1e1 4.\" %sccs.include.redist.man%
88b3ccf2 5.\"
931b8415 6.\" @(#)fsync.2 6.7 (Berkeley) %G%
76a31391 7.\"
931b8415
CL
8.Dd
9.Dt FSYNC 2
10.Os BSD 4.2
11.Sh NAME
12.Nm fsync
13.Nd "synchronize a file's in-core state with that on disk"
14.Sh SYNOPSIS
15.Fd #include <unistd.h>
16.Ft int
17.Fn fsync "int fd"
18.Sh DESCRIPTION
19.Fn Fsync
20causes all modified data and attributes of
21.Fa fd
76a31391
KM
22to be moved to a permanent storage device.
23This normally results in all in-core modified copies
24of buffers for the associated file to be written to a disk.
931b8415
CL
25.Pp
26.Fn Fsync
b4c94b6d 27should be used by programs that require a file to be
7b12e899 28in a known state, for example, in building a simple transaction
76a31391 29facility.
931b8415
CL
30.Sh RETURN VALUES
31A 0 value is returned on success. A -1 value indicates
76a31391 32an error.
931b8415
CL
33.Sh ERRORS
34The
35.Fn fsync
36fails if:
37.Bl -tag -width Er
38.It Bq Er EBADF
39.Fa Fd
40is not a valid descriptor.
41.It Bq Er EINVAL
42.Fa Fd
43refers to a socket, not to a file.
44.It Bq Er EIO
fd690c8b 45An I/O error occurred while reading from or writing to the file system.
931b8415
CL
46.El
47.Sh SEE ALSO
48.Xr sync 2 ,
49.Xr sync 8 ,
50.Xr update 8
51.Sh HISTORY
52The
53.Nm
54function call appeared in
55.Bx 4.2 .