Writes changes in a file to permanent storage.
Standard C Library (libc.a)
#include <unistd.h> int fsync ( FileDescriptor) int FileDescriptor; int fsync_range (FileDescriptor, how, start, length) int FileDescriptor; int how; off_t start; off_t length;
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.
The fsync_range subroutine causes all modified data in the specified range of the open file specified by the FileDescriptor parameter to be saved to permanent storage. On return from the fsync_range subroutine, all updates in the specified range 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_range or fsync call 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.
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.
Upon successful completion, the fsync_range 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:
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.2 General Programming Concepts: Writing and Debugging Programs contains information about i-nodes, file descriptors, file-space allocation, and more.