Visit Our UNIX and Linux User Community

Linux and UNIX Man Pages

Test Your Knowledge in Computers #263
Difficulty: Easy
Alan Turing played a key role in cracking intercepted coded messages that enabled the Allies to defeat the Nazis in many crucial engagements, including the Battle of the Atlantic, and in so doing helped win and end the war.
True or False?
Linux & Unix Commands - Search Man Pages

fsync(2) [bsd man page]

FSYNC(2)							System Calls Manual							  FSYNC(2)

NAME
fsync - synchronize a file's in-core state with that on disk SYNOPSIS
fsync(fd) int fd; DESCRIPTION
Fsync causes all modified data and attributes of fd to be moved to a permanent storage device. This normally results in all in-core modi- fied 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. RETURN VALUE
A 0 value is returned on success. A -1 value indicates an error. ERRORS
The fsync fails if: [EBADF] Fd is not a valid descriptor. [EINVAL] Fd refers to a socket, not to a file. [EIO] An I/O error occurred while reading from or writing to the file system. SEE ALSO
sync(2), sync(8), update(8) 4.2 Berkeley Distribution May 22, 1986 FSYNC(2)

Check Out this Related Man Page

FSYNC(2)						     Linux Programmer's Manual							  FSYNC(2)

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. NOTES
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 implicitly 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
POSIX.1b (formerly POSIX.4) SEE ALSO
bdflush(2), open(2), sync(2), mount(8), update(8), sync(8) Linux 1.3.85 2001-04-18 FSYNC(2)

Featured Tech Videos