sync(2)


NAME

   sync, syncfs - commit filesystem caches to disk

SYNOPSIS

   #include <unistd.h>

   void sync(void);

   int syncfs(int fd);

   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

   sync():
       _XOPEN_SOURCE >= 500
           || /* Since glibc 2.19: */ _DEFAULT_SOURCE
           || /* Glibc versions <= 2.19: */ _BSD_SOURCE

   syncfs():
       _GNU_SOURCE

DESCRIPTION

   sync()  causes  all  pending  modifications  to filesystem metadata and
   cached file data to be written to the underlying filesystems.

   syncfs()  is  like  sync(),  but  synchronizes  just   the   filesystem
   containing file referred to by the open file descriptor fd.

RETURN VALUE

   syncfs()  returns  0 on success; on error, it returns -1 and sets errno
   to indicate the error.

ERRORS

   sync() is always successful.

   syncfs() can fail for at least the following reason:

   EBADF  fd is not a valid file descriptor.

VERSIONS

   syncfs() first appeared in Linux 2.6.39; library support was  added  to
   glibc in version 2.14.

CONFORMING TO

   sync(): POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.

   syncfs() is Linux-specific.

NOTES

   Since  glibc  2.2.2, the Linux prototype for sync() is as listed above,
   following the various standards.  In glibc 2.2.1 and  earlier,  it  was
   "int sync(void)", and sync() always returned 0.

   According  to  the  standard specification (e.g., POSIX.1-2001), sync()
   schedules the writes, but may return before the actual writing is done.
   However  Linux  waits  for I/O completions, and thus sync() or syncfs()
   provide the same guarantees as fsync called on every file in the system
   or filesystem respectively.

BUGS

   Before  version  1.3.20  Linux  did not wait for I/O to complete before
   returning.

SEE ALSO

   sync(1), fdatasync(2), fsync(2)

COLOPHON

   This page is part of release 4.09 of the Linux  man-pages  project.   A
   description  of  the project, information about reporting bugs, and the
   latest    version    of    this    page,    can     be     found     at
   https://www.kernel.org/doc/man-pages/.


More Linux Commands

manpages/git-gc.1.html
git-gc(1) - Cleanup unnecessary files and optimize the local
Runs a number of housekeeping tasks within the current repository, such as compressing file revisions (to reduce disk space and increase performance) and removi

manpages/inet_network.3.html
inet_addr(3) - Internet address manipulation routines.......
inet_aton() converts the Internet host address cp from the IPv4 numbers-and-dots notation into binary form (in network byte order) and stores it in the structur

manpages/attr_off.3ncurses.html
attr_off(3ncurses) - curses character and window attribute c
These routines manipulate the current attributes of the named window. The current attributes of a window apply to all characters that are written into the windo

manpages/Module::Build::Bundling.3pm.html
Module::Build::Bundling(3pm) - How to bundle Module::Build w
WARNING -- THIS IS AN EXPERIMENTAL FEATURE In order to install a distribution using Module::Build, users must have Module::Build available on their systems. The

manpages/strfile.1.html
strfile(1) create a random access file for storing strings b
strfile reads a file containing groups of lines separated by a line containing a single percent % sign (or other specified delimiter character) and creates a da

manpages/gnutls_x509_crt_deinit.3.html
gnutls_x509_crt_deinit(3) - API function - Linux man page...
This function will deinitialize a certificate structure. REPORTING BUGS Report bugs to &lt;bug-gnutls@gnu.org&gt;. GnuTLS home page: http://www.gnu.org/software/gnutl

manpages/pthread_attr_setguardsize.3.html
pthread_attr_setguardsize(3) - set/get guard size attribute
The pthread_attr_setguardsize() function sets the guard size attribute of the thread attributes object referred to by attr to the value specified in guardsize.

manpages/getgroups32.2.html
getgroups32(2) - get/set list of supplementary group IDs....
getgroups() returns the supplementary group IDs of the calling process in list. The argument size should be set to the maximum number of items that can be store

manpages/reboot.8.html
reboot(8) - Halt, power-off or reboot the machine (ManPage)
halt, poweroff, reboot may be used to halt, power-off or reboot the machine. OPTIONS The following options are understood: --help Print a short help text and ex

manpages/sha1.1ssl.html
sha1(1ssl) message digests (Commands - Linux manual page)...
The digest functions output the message digest of a supplied file or files in hexadecimal. The digest functions also generate and verify digital signatures usin

manpages/Tcl_GetChannelName.3.html
Tcl_GetChannelName(3) - procedures for creating and manipula
Tcl uses a two-layered channel architecture. It provides a generic upper layer to enable C and Tcl programs to perform input and output using the same APIs for

manpages/sigaddset.3.html
sigaddset(3) - POSIX signal set operations. - Linux man page
These functions allow the manipulation of POSIX signal sets. sigemptyset() initializes the signal set given by set to empty, with all signals excluded from the





We can't live, work or learn in freedom unless the software we use is free.