1. Home
  2. Computing & Technology
  3. Linux
Linux / Unix Command: fsync
Command Library

NAME

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

SYNOPSIS

#include <unistd.h>

int fsync(int fd);

int fdatasync(int fd);  

DESCRIPTION

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

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

ERRORS

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.
 

SEE ALSO

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


Important: Use the man command (% man) to see how a command is used on your particular computer.

>> Linux/Unix Command Library

>> Shell Command Library

Explore Linux
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Linux

©2009 About.com, a part of The New York Times Company.

All rights reserved.