sync_file_range

Force committing of data to disk

Declaration

Source position: linux.pp line 388

  function sync_file_range(fd: cint; offset: off64_t; nbytes: off64_t; 
                          flags: cuint) : cint;

Description

sync_file_range forces the Linux kernel to write any data pages of a specified file (file descriptor fd) to disk. The range of the file is specified by the offset offset and the number of bytes nbytes. Options is an OR-ed combination of

SYNC_FILE_RANGE_WAIT_BEFORE
Wait for write-out of previously-submitted specified pages before writing more data.
SYNC_FILE_RANGE_WRITE
Initiate write of all dirty pages in the specified range.
SYNC_FILE_RANGE_WAIT_AFTER
Wait upon write-out of specified pages in the range after performing any write.

If none is specified, the operation does nothing.

Errors

On return -1 is returned and fperrno is set to the actual error code. See the Linux man page for more on the error codes.

See also

Name Description
fdatasync Synchronize the data in memory with the data on storage device