int
fsync(
int fd
)
int
fsync_range(
int fd
, int how
, off_t start
, off_t length
)
)
causes all modified data and attributes of
fd
to be moved to a permanent storage device.
This normally results in all in-core modified copies
of buffers for the associated file to be written to a disk.
fsync()
should be used by programs that require a file to be
in a known state, for example, in building a simple transaction
facility.
fsync_range()
causes all modified data starting at
start
for length
length
of
fd
to be written to permanent storage.
Note that
fsync_range()
requires that the file
fd
must be open for writing.
fsync_range()
may flush the file data in one of two manners:
FDATASYNC
FFILESYNC
By default,
fsync_range()
does not flush disk caches, assuming that storage media are able to ensure
completed writes are transfered to media.
The
FDISKSYNC
flag may be included in the
how
parameter to trigger flushing of all disk caches for the file.
If the
length
parameter is zero,
fsync_range()
will synchronize all of the file data.
)
or
fsync_range(
)
fail if:
EBADF
]
fd
is not a valid descriptor.
EINVAL
]
fd
refers to a socket, not to a file.
EIO
]
Additionally,
fsync_range()
fails if:
EBADF
]
fd
is not open for writing.
EINVAL
]
start
+
length
is less than
start
.
)
call requires that the file system containing the file referenced by
fd
support partial synchronization of file data.
For file systems which do
not support partial synchronization, the entire file will be synchronized
and the call will be the equivalent of calling
fsync(
).
)
function call appeared in
4.2BSD.
The
fsync_range()
function call first appeared in
NetBSD2.0
and is modeled after the function available in AIX.