xref: /csrg-svn/lib/libc/sys/fsync.2 (revision 61181)
1*61181Sbostic.\" Copyright (c) 1983, 1993
2*61181Sbostic.\"	The Regents of the University of California.  All rights reserved.
320217Smckusick.\"
443568Strent.\" %sccs.include.redist.man%
520217Smckusick.\"
6*61181Sbostic.\"     @(#)fsync.2	8.1 (Berkeley) 06/04/93
738053Sbostic.\"
847208Scael.Dd
947208Scael.Dt FSYNC 2
1047208Scael.Os BSD 4.2
1147208Scael.Sh NAME
1247208Scael.Nm fsync
1347208Scael.Nd "synchronize a file's in-core state with that on disk"
1447208Scael.Sh SYNOPSIS
1547208Scael.Fd #include <unistd.h>
1647208Scael.Ft int
1747208Scael.Fn fsync "int fd"
1847208Scael.Sh DESCRIPTION
1947208Scael.Fn Fsync
2047208Scaelcauses all modified data and attributes of
2147208Scael.Fa fd
2220217Smckusickto be moved to a permanent storage device.
2320217SmckusickThis normally results in all in-core modified copies
2420217Smckusickof buffers for the associated file to be written to a disk.
2547208Scael.Pp
2647208Scael.Fn Fsync
2723801Ssechrestshould be used by programs that require a file to be
2828369Sannein a known state, for example, in building a simple transaction
2920217Smckusickfacility.
3047208Scael.Sh RETURN VALUES
3147208ScaelA 0 value is returned on success.  A -1 value indicates
3220217Smckusickan error.
3347208Scael.Sh ERRORS
3447208ScaelThe
3547208Scael.Fn fsync
3647208Scaelfails if:
3747208Scael.Bl -tag -width Er
3847208Scael.It Bq Er EBADF
3947208Scael.Fa Fd
4047208Scaelis not a valid descriptor.
4147208Scael.It Bq Er EINVAL
4247208Scael.Fa Fd
4347208Scaelrefers to a socket, not to a file.
4447208Scael.It Bq Er EIO
4524440SmckusickAn I/O error occurred while reading from or writing to the file system.
4647208Scael.El
4747208Scael.Sh SEE ALSO
4847208Scael.Xr sync 2 ,
4947208Scael.Xr sync 8 ,
5047208Scael.Xr update 8
5147208Scael.Sh HISTORY
5247208ScaelThe
5347208Scael.Nm
5447208Scaelfunction call appeared in
5547208Scael.Bx 4.2 .
56