1 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
2 .\" and Copyright (c) 2011 Michael Kerrisk <mtk.manpages@gmail.com>
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\" Modified by Michael Haardt <michael@moria.de>
7 .\" Modified Sat Jul 24 12:02:47 1993 by Rik Faith <faith@cs.unc.edu>
8 .\" Modified 15 Apr 1995 by Michael Chastain <mec@shell.portal.com>:
9 .\" Added reference to `bdflush(2)'.
10 .\" Modified 960414 by Andries Brouwer <aeb@cwi.nl>:
11 .\" Added the fact that since 1.3.20 sync actually waits.
12 .\" Modified Tue Oct 22 22:27:07 1996 by Eric S. Raymond <esr@thyrsus.com>
13 .\" Modified 2001-10-10 by aeb, following Michael Kerrisk.
14 .\" 2011-09-07, mtk, Added syncfs() documentation,
16 .TH SYNC 2 2021-03-22 "Linux man-pages (unreleased)"
18 sync, syncfs \- commit filesystem caches to disk
21 .RI ( libc ", " \-lc )
24 .B #include <unistd.h>
28 .BI "int syncfs(int " fd );
32 Feature Test Macro Requirements for glibc (see
33 .BR feature_test_macros (7)):
39 .\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
40 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
41 || /* Glibc <= 2.19: */ _BSD_SOURCE
50 causes all pending modifications to filesystem metadata and cached file
51 data to be written to the underlying filesystems.
56 but synchronizes just the filesystem containing file
57 referred to by the open file descriptor
62 on error, it returns \-1 and sets
64 to indicate the error.
70 can fail for at least the following reasons:
74 is not a valid file descriptor.
77 An error occurred during synchronization.
78 This error may relate to data written to any file on the filesystem, or on
79 metadata related to the filesystem itself.
82 Disk space was exhausted while synchronizing.
84 .BR ENOSPC ", " EDQUOT
85 Data was written to a file on NFS or another filesystem which does not
86 allocate space at the time of a
88 system call, and some previous write failed due to insufficient
92 first appeared in Linux 2.6.39;
93 library support was added to glibc in version 2.14.
96 POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.
101 Since glibc 2.2.2, the Linux prototype for
104 following the various standards.
105 In glibc 2.2.1 and earlier,
106 it was "int sync(void)", and
110 According to the standard specification (e.g., POSIX.1-2001),
112 schedules the writes, but may return before the actual
114 However Linux waits for I/O completions,
119 provide the same guarantees as
121 called on every file in
122 the system or filesystem respectively.
124 In mainline kernel versions prior to 5.8,
126 will fail only when passed a bad file descriptor
129 .\" commit 735e4ae5ba28c886d249ad04d3c8cc097dad6336
131 will also report an error if one or more inodes failed
132 to be written back since the last
136 Before version 1.3.20 Linux did not wait for I/O to complete