Commit | Line | Data |
---|---|---|
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 | |
20 | causes all modified data and attributes of | |
21 | .Fa fd | |
76a31391 KM |
22 | to be moved to a permanent storage device. |
23 | This normally results in all in-core modified copies | |
24 | of buffers for the associated file to be written to a disk. | |
931b8415 CL |
25 | .Pp |
26 | .Fn Fsync | |
b4c94b6d | 27 | should be used by programs that require a file to be |
7b12e899 | 28 | in a known state, for example, in building a simple transaction |
76a31391 | 29 | facility. |
931b8415 CL |
30 | .Sh RETURN VALUES |
31 | A 0 value is returned on success. A -1 value indicates | |
76a31391 | 32 | an error. |
931b8415 CL |
33 | .Sh ERRORS |
34 | The | |
35 | .Fn fsync | |
36 | fails if: | |
37 | .Bl -tag -width Er | |
38 | .It Bq Er EBADF | |
39 | .Fa Fd | |
40 | is not a valid descriptor. | |
41 | .It Bq Er EINVAL | |
42 | .Fa Fd | |
43 | refers to a socket, not to a file. | |
44 | .It Bq Er EIO | |
fd690c8b | 45 | An 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 | |
52 | The | |
53 | .Nm | |
54 | function call appeared in | |
55 | .Bx 4.2 . |