Writes changes in a file to permanent storage.
Standard C Library (libc.a)
int fsync ( FileDescriptor)
The fsync subroutine causes all modified data in the open file specified by the FileDescriptor parameter to be saved to permanent storage. On return from the fsync subroutine, all updates have been saved on permanent storage.
Data written to a file that a process has opened for deferred update (with the O_DEFER flag) is not written to permanent storage until another process issues an fsync subroutine against this file or runs a synchronous write subroutine (with the O_SYNC flag) on this file. See the fcntl.h file and the open subroutine for descriptions of the O_DEFER and O_SYNC flags respectively.
Note: The file identified by the FileDescriptor parameter must be open for writing when the fsync subroutine is issued or the call is unsuccessful. This restriction was not enforced in BSD systems.
|FileDescriptor||A valid, open file descriptor.|
Upon successful completion, the fsync subroutine returns a value of 0. Otherwise, a value of -1 is returned and the errno global variable is set to indicate the error.
The fsync subroutine is
unsuccessful if one or more of the following are true:
|EIO||An I/O error occurred while reading from or writing to the file system.|
|EBADF||The FileDescriptor parameter is not a valid file descriptor open for writing.|
|EINVAL||The file is not a regular file.|
|EINTR||The fsync subroutine was interrupted by a signal.|
This subroutine is part of Base Operating System (BOS) Runtime.
The open, openx, or creat (open, openx, open64, creat, or creat64 Subroutine) subroutine, sync subroutine, write, writex, writev, or writevx subroutine.
The fcntl.h file.
Files, Directories, and File Systems Overview for Programmers in AIX 5L Version 5.1 General Programming Concepts: Writing and Debugging Programs contains information about i-nodes, file descriptors, file-space allocation, and more.