199 lines
4.0 KiB
HTML
199 lines
4.0 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of SYNC</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>SYNC</H1>
|
|
Section: Linux Programmer's Manual (2)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
sync, syncfs - commit filesystem caches to disk
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>#include <<A HREF="file:///usr/include/unistd.h">unistd.h</A>></B>
|
|
|
|
<P>
|
|
|
|
<B>void sync(void);</B>
|
|
|
|
<P>
|
|
|
|
<B>int syncfs(int </B><I>fd</I><B>);</B>
|
|
|
|
<P>
|
|
|
|
|
|
Feature Test Macro Requirements for glibc (see
|
|
<B><A HREF="/cgi-bin/man/man2html?7+feature_test_macros">feature_test_macros</A></B>(7)):
|
|
|
|
|
|
<P>
|
|
|
|
<B>sync</B>():
|
|
|
|
|
|
<DL COMPACT><DT id="1"><DD>
|
|
_XOPEN_SOURCE >= 500
|
|
|
|
<BR> || /* Since glibc 2.19: */ _DEFAULT_SOURCE
|
|
<BR> || /* Glibc versions <= 2.19: */ _BSD_SOURCE
|
|
</DL>
|
|
|
|
|
|
<P>
|
|
|
|
<B>syncfs</B>():
|
|
|
|
|
|
<DL COMPACT><DT id="2"><DD>
|
|
_GNU_SOURCE
|
|
</DL>
|
|
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
<B>sync</B>()
|
|
|
|
causes all pending modifications to filesystem metadata and cached file
|
|
data to be written to the underlying filesystems.
|
|
<P>
|
|
|
|
<B>syncfs</B>()
|
|
|
|
is like
|
|
<B>sync</B>(),
|
|
|
|
but synchronizes just the filesystem containing file
|
|
referred to by the open file descriptor
|
|
<I>fd</I>.
|
|
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
<B>syncfs</B>()
|
|
|
|
returns 0 on success;
|
|
on error, it returns -1 and sets
|
|
<I>errno</I>
|
|
|
|
to indicate the error.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>ERRORS</H2>
|
|
|
|
<B>sync</B>()
|
|
|
|
is always successful.
|
|
<P>
|
|
|
|
<B>syncfs</B>()
|
|
|
|
can fail for at least the following reason:
|
|
<DL COMPACT>
|
|
<DT id="3"><B>EBADF</B>
|
|
|
|
<DD>
|
|
<I>fd</I>
|
|
|
|
is not a valid file descriptor.
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>VERSIONS</H2>
|
|
|
|
<B>syncfs</B>()
|
|
|
|
first appeared in Linux 2.6.39;
|
|
library support was added to glibc in version 2.14.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
<B>sync</B>():
|
|
|
|
POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.
|
|
<P>
|
|
|
|
<B>syncfs</B>()
|
|
|
|
is Linux-specific.
|
|
<A NAME="lbAI"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
Since glibc 2.2.2, the Linux prototype for
|
|
<B>sync</B>()
|
|
|
|
is as listed above,
|
|
following the various standards.
|
|
In glibc 2.2.1 and earlier,
|
|
it was "int sync(void)", and
|
|
<B>sync</B>()
|
|
|
|
always returned 0.
|
|
<P>
|
|
|
|
According to the standard specification (e.g., POSIX.1-2001),
|
|
<B>sync</B>()
|
|
|
|
schedules the writes, but may return before the actual
|
|
writing is done. However Linux waits for I/O completions,
|
|
and thus
|
|
<B>sync</B>()
|
|
|
|
or
|
|
<B>syncfs</B>()
|
|
|
|
provide the same guarantees as fsync called on every file in
|
|
the system or filesystem respectively.
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>BUGS</H2>
|
|
|
|
Before version 1.3.20 Linux did not wait for I/O to complete
|
|
before returning.
|
|
<A NAME="lbAK"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?1+sync">sync</A></B>(1),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+fdatasync">fdatasync</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+fsync">fsync</A></B>(2)
|
|
|
|
<A NAME="lbAL"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="4"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="5"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="6"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="7"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="8"><A HREF="#lbAF">ERRORS</A><DD>
|
|
<DT id="9"><A HREF="#lbAG">VERSIONS</A><DD>
|
|
<DT id="10"><A HREF="#lbAH">CONFORMING TO</A><DD>
|
|
<DT id="11"><A HREF="#lbAI">NOTES</A><DD>
|
|
<DT id="12"><A HREF="#lbAJ">BUGS</A><DD>
|
|
<DT id="13"><A HREF="#lbAK">SEE ALSO</A><DD>
|
|
<DT id="14"><A HREF="#lbAL">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:35 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|