xref: /original-bsd/lib/libc/sys/fsync.2 (revision f608913f)
1.\" Copyright (c) 1983, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)fsync.2	8.1 (Berkeley) 06/04/93
7.\"
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
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.
25.Pp
26.Fn Fsync
27should be used by programs that require a file to be
28in a known state, for example, in building a simple transaction
29facility.
30.Sh RETURN VALUES
31A 0 value is returned on success.  A -1 value indicates
32an error.
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
45An I/O error occurred while reading from or writing to the file system.
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 .
56