*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->Linux man pages -> fsync (2)              
Title
Content
Arch
Section
 

FSYNC(2)

Contents


NAME    [Toc]    [Back]

       fsync,  fdatasync  -  synchronize  a file's complete in-core state with
       that on disk

SYNOPSIS    [Toc]    [Back]

       #include <unistd.h>

       int fsync(int fd);

       int fdatasync(int fd);

DESCRIPTION    [Toc]    [Back]

       fsync 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 on the file descriptor of the directory is  also
       needed.

       fdatasync  does	the  same as fsync but only flushes user data, not the
       meta data like the mtime or atime.

RETURN VALUE    [Toc]    [Back]

       On success, zero is returned.  On error, -1 is returned, and  errno  is
       set appropriately.

ERRORS    [Toc]    [Back]

       EBADF  fd is not a valid file descriptor open for writing.

       EROFS, EINVAL
	      fd  is  bound  to a special file which does not support synchronization.


       EIO    An error occurred during synchronization.

NOTES    [Toc]    [Back]

       In case the hard disk has write cache enabled, the data may not	really
       be on permanent storage when fsync/fdatasync return.

       When  an  ext2  file  system is mounted with the sync option, directory
       entries are also implicitely synced by fsync.

       On kernels before 2.4, fsync on	big  files  can  be  inefficient.   An
       alternative might be to use the O_SYNC flag to open(2).

CONFORMING TO    [Toc]    [Back]

       POSIX.1b (formerly POSIX.4)

SEE ALSO    [Toc]    [Back]

      
      
       bdflush(2), open(2), sync(2), mount(8), update(8), sync(8)



Linux 1.3.85			  2001-04-18			      FSYNC(2)
[ Back ]
 Similar pages
Name OS Title
fsync FreeBSD synchronize a file's in-core state with that on disk
fsync NetBSD synchronize a file's in-core state with that on disk
fsync OpenBSD synchronize a file's in-core state with that on disk
sync OpenBSD synchronize disk block in-core status with that on disk
sync NetBSD synchronize disk block in-core status with that on disk
fdatasync Linux synchronize a file's in-core data with that on disk
fdatasync HP-UX synchronize a file's in-core and on-disk states
fsync HP-UX synchronize a file's in-core and on-disk states
fsync IRIX synchronize a file's in-memory state with that on the physical medium
aio_fsync IRIX asynchronously synchronize a file's in-memory state with that on the physical medium
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service