[Previous] [Contents] [Next]

fsync()

Synchronize the file state

Synopsis:

#include <unistd.h>

int fsync( int filedes );

Library:

libc

Description:

The fsync() function forces all queued I/O operations for the file specified by the filedes file descriptor to finish, synchronizing the file's state.

Although similar to fdatasync(), fsync() also guarantees the integrity of file information such as access and modification times.

Returns:

0 for success, or -1 if an error occurs (errno is set).

Errors:

EBADF
The filedes argument isn't a valid file descriptor open for writing.
EINVAL
The implementation doesn't support synchronized I/O for the given file.
ENOSYS
The fsync() function isn't supported for the filesystem specified by filedes.

Classification:

POSIX 1003.1

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

aio_fsync(), close(), fcntl(), fdatasync(), open(), read(), sync(), write()


[Previous] [Contents] [Next]