Contained WithinFind More DocumentationFeatured Support Resources | Download this book in PDF (4217 KB)
fsync(3C)Name | Synopsis | Description | Return Values | Errors | Usage | Attributes | See Also Name
Synopsis#include <unistd.h> int fsync(int fildes); DescriptionThe fsync() function moves all modified data and attributes of the file descriptor fildes to a storage device. When fsync() returns, all in-memory modified copies of buffers associated with fildes have been written to the physical medium. The fsync() function is different from sync(), which schedules disk I/O for all files but returns before the I/O completes. The fsync() function forces all outstanding data operations to synchronized file integrity completion (see fcntl.h(3HEAD) definition of O_SYNC.) The fsync() function forces all currently queued I/O operations associated with the file indicated by the file descriptor fildes to the synchronized I/O completion state. All I/O operations are completed as defined for synchronized I/O file integrity completion. Return ValuesUpon successful completion, 0 is returned. Otherwise, -1 is returned and errno is set to indicate the error. If the fsync() function fails, outstanding I/O operations are not guaranteed to have been completed. Errors
The fsync() function will fail if: In the event that any of the queued I/O operations fail, fsync() returns the error conditions defined for read(2) and write(2). UsageThe fsync() function should be used by applications that require that a file be in a known state. For example, an application that contains a simple transaction facility might use fsync() to ensure that all changes to a file or files caused by a given transaction were recorded on a storage medium. The manner in which the data reach the physical medium depends on both implementation and hardware. The fsync() function returns when notified by the device driver that the write has taken place. AttributesSee attributes(5) for descriptions of the following attributes:
See Alsomount_nfs(1M), read(2), sync(2), write(2), fcntl.h(3HEAD), fdatasync(3C), attributes(5), standards(5) Name | Synopsis | Description | Return Values | Errors | Usage | Attributes | See Also |
||||||||