Penguin
Annotated edit history of fsync(2) version 4, including all changes. View license author blame.
Rev Author # Line
1 perry 1 !!NAME
2
3
4 fsync, fdatasync - synchronize a file's complete in-core state with that on disk
5 !!SYNOPSIS
6
7
2 PerryLorier 8 __#include <unistd>__
9 __int fsync(int__ ''fd''__);__
1 perry 10
3 PerryLorier 11 !!DESCRIPTION
2 PerryLorier 12 fsync(2) copies all in-core parts of a file to disk, and waits until the device reports that all parts are on stable storage. It also updates metadata stat information. It does not necessarily ensure that the entry in the directory containing the file has also reached disk. For that an explicit fsync(2) on the file descriptor of the directory is also needed.
1 perry 13
14 !!RETURN VALUE
2 PerryLorier 15 On success, zero is returned. On error, -1 is returned, and ''errno'' is set appropriately.
1 perry 16 !!ERRORS
17
2 PerryLorier 18 ;[EBADF]: ''fd'' is not a valid file descriptor open for writing.
19 ;[EROFS], [EINVAL]: ''fd'' is bound to a special file which does not support synchronization.
20 ;[EIO]: An error occurred during synchronization.
1 perry 21
22 !!NOTES
2 PerryLorier 23 In case the hard disk has write cache enabled, the data may not really be on permanent storage when fsync(2) returns.
1 perry 24
2 PerryLorier 25 When an ext2 file system is mounted with the ''sync'' option, directory entries are also implicitely synced by fsync(2).
1 perry 26
2 PerryLorier 27 On kernels before 2.4, fsync(2) on big files can be inefficient. An alternative might be to use the ''O_SYNC'' flag to open(2).
1 perry 28 !!CONFORMING TO
4 JohnMcPherson 29 [POSIX].1b (formerly [POSIX].4)
1 perry 30
31 !!SEE ALSO
2 PerryLorier 32 bdflush(2), open(2), sync(2), mount(8), update(8), sync(8), fdatasync(2)
4 JohnMcPherson 33 ----
34 The difference between fsync(2) and fdatasync(2) is that fsync modifies the access time metadata in the i-node, while fdatasync doesn't/shouldn't. I think this is true version kernel versions >= 2.4 - for 2.2 and earlier fdatasync was the same as fsync.
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.

PHP Warning

lib/blame.php:177: Warning: Invalid argument supplied for foreach() (...repeated 4 times)