fsync
Purpose
Writes changes in a file to permanent storage.
Syntax
int fsync (fildes)
int fildes;
Description
The fsync system call causes all modified data in the
file open on fildes to be saved to permanent storage. If
Distributed Services is installed on your system, this
file can reside on another node. If the file is mapped
onto a segment in read-write mode, then it is saved to
permanent storage. If the file is mapped copy-on-write,
then the pages of the file that have been changed are
saved to permanent storage. Saving to permanent storage
is sometimes called a commit operation.
An fsync system call can be issued by a process executing
at the node on which the file is stored or by a process
executing at another node. In either case, the file is
written to permanent storage at the node that holds the
file.
In AIX, the file identified by the fildes parameter must
be open when the fsync system call is issued or the call
fails.
Return Value
Upon successful completion, fsync returns a value of 0.
If fsync fails, a value of -1 is returned and errno is
set to indicate the error.
Diagnostics
The fsync system call fails if one or more of the fol-
lowing are true:
EIO I/O error.
EBADF fildes is not a valid file descriptor open for
writing.
If Distributed Services is installed on your system,
fsync can also fail if one or more of the following are
true:
EDIST The server has blocked new inbound
requests.
EDIST Outbound requests are currently blocked.
EAGAIN The server is too busy to accept the
request.
ENOMEM Either this node or the server does not
have enough memory available to service the
request.
EBADCONNECT An attempt to use an existing network con-
nection with a remote node failed.
Related Information
In this book: "sync."