]>
Commit | Line | Data |
---|---|---|
fea681da | 1 | .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992 |
56fe7791 | 2 | .\" and Copyright (c) 2011 Michael Kerrisk <mtk.manpages@gmail.com> |
fea681da | 3 | .\" |
93015253 | 4 | .\" %%%LICENSE_START(VERBATIM) |
fea681da MK |
5 | .\" Permission is granted to make and distribute verbatim copies of this |
6 | .\" manual provided the copyright notice and this permission notice are | |
7 | .\" preserved on all copies. | |
8 | .\" | |
9 | .\" Permission is granted to copy and distribute modified versions of this | |
10 | .\" manual under the conditions for verbatim copying, provided that the | |
11 | .\" entire resulting derived work is distributed under the terms of a | |
12 | .\" permission notice identical to this one. | |
c13182ef | 13 | .\" |
fea681da MK |
14 | .\" Since the Linux kernel and libraries are constantly changing, this |
15 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
16 | .\" responsibility for errors or omissions, or for damages resulting from | |
17 | .\" the use of the information contained herein. The author(s) may not | |
18 | .\" have taken the same level of care in the production of this manual, | |
19 | .\" which is licensed free of charge, as they might when working | |
20 | .\" professionally. | |
c13182ef | 21 | .\" |
fea681da MK |
22 | .\" Formatted or processed versions of this manual, if unaccompanied by |
23 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 24 | .\" %%%LICENSE_END |
fea681da MK |
25 | .\" |
26 | .\" Modified by Michael Haardt <michael@moria.de> | |
27 | .\" Modified Sat Jul 24 12:02:47 1993 by Rik Faith <faith@cs.unc.edu> | |
28 | .\" Modified 15 Apr 1995 by Michael Chastain <mec@shell.portal.com>: | |
29 | .\" Added reference to `bdflush(2)'. | |
30 | .\" Modified 960414 by Andries Brouwer <aeb@cwi.nl>: | |
31 | .\" Added the fact that since 1.3.20 sync actually waits. | |
32 | .\" Modified Tue Oct 22 22:27:07 1996 by Eric S. Raymond <esr@thyrsus.com> | |
33 | .\" Modified 2001-10-10 by aeb, following Michael Kerrisk. | |
56fe7791 | 34 | .\" 2011-09-07, mtk, Added syncfs() documentation, |
fea681da | 35 | .\" |
4b8c67d9 | 36 | .TH SYNC 2 2017-09-15 "Linux" "Linux Programmer's Manual" |
fea681da | 37 | .SH NAME |
cf8bac92 | 38 | sync, syncfs \- commit filesystem caches to disk |
fea681da MK |
39 | .SH SYNOPSIS |
40 | .B #include <unistd.h> | |
68e4db0a | 41 | .PP |
fea681da | 42 | .B void sync(void); |
68e4db0a | 43 | .PP |
c799ca62 | 44 | .BI "int syncfs(int " fd ); |
68e4db0a | 45 | .PP |
cc4615cc MK |
46 | .in -4n |
47 | Feature Test Macro Requirements for glibc (see | |
48 | .BR feature_test_macros (7)): | |
49 | .in | |
68e4db0a | 50 | .PP |
cc4615cc | 51 | .BR sync (): |
733e68f5 MK |
52 | .ad l |
53 | .RS 4 | |
f8619b6a | 54 | _XOPEN_SOURCE\ >=\ 500 |
cf7fa0a1 | 55 | .\" || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED |
f8619b6a MK |
56 | || /* Since glibc 2.19: */ _DEFAULT_SOURCE |
57 | || /* Glibc versions <= 2.19: */ _BSD_SOURCE | |
733e68f5 MK |
58 | .RE |
59 | .ad | |
68e4db0a | 60 | .PP |
56fe7791 MK |
61 | .BR syncfs (): |
62 | .ad l | |
63 | .RS 4 | |
64 | _GNU_SOURCE | |
65 | .RE | |
66 | .ad | |
fea681da | 67 | .SH DESCRIPTION |
e511ffb6 | 68 | .BR sync () |
5991f44e | 69 | causes all pending modifications to filesystem metadata and cached file |
cf8bac92 | 70 | data to be written to the underlying filesystems. |
efeece04 | 71 | .PP |
56fe7791 MK |
72 | .BR syncfs () |
73 | is like | |
74 | .BR sync (), | |
9ee4a2b6 | 75 | but synchronizes just the filesystem containing file |
56fe7791 MK |
76 | referred to by the open file descriptor |
77 | .IR fd . | |
78 | .SH RETURN VALUE | |
79 | .BR syncfs () | |
80 | returns 0 on success; | |
81 | on error, it returns \-1 and sets | |
82 | .I errno | |
83 | to indicate the error. | |
fea681da | 84 | .SH ERRORS |
bedbb533 MK |
85 | .BR sync () |
86 | is always successful. | |
efeece04 | 87 | .PP |
56fe7791 MK |
88 | .BR syncfs () |
89 | can fail for at least the following reason: | |
90 | .TP | |
91 | .B EBADF | |
92 | .I fd | |
93 | is not a valid file descriptor. | |
94 | .SH VERSIONS | |
95 | .BR syncfs () | |
c95b6ae1 MK |
96 | first appeared in Linux 2.6.39; |
97 | library support was added to glibc in version 2.14. | |
47297adb | 98 | .SH CONFORMING TO |
bedbb533 | 99 | .BR sync (): |
4920923f | 100 | POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD. |
efeece04 | 101 | .PP |
56fe7791 MK |
102 | .BR syncfs () |
103 | is Linux-specific. | |
2dd578fd | 104 | .SH NOTES |
64e67357 | 105 | Since glibc 2.2.2, the Linux prototype for |
bedbb533 MK |
106 | .BR sync () |
107 | is as listed above, | |
2dd578fd | 108 | following the various standards. |
7537792e | 109 | In glibc 2.2.1 and earlier, |
2dd578fd MK |
110 | it was "int sync(void)", and |
111 | .BR sync () | |
112 | always returned 0. | |
efeece04 | 113 | .PP |
97c1eac8 | 114 | According to the standard specification (e.g., POSIX.1-2001), |
60a90ecd MK |
115 | .BR sync () |
116 | schedules the writes, but may return before the actual | |
cf8bac92 CH |
117 | writing is done. However Linux waits for I/O completions, |
118 | and thus | |
119 | .BR sync () | |
120 | or | |
121 | .BR syncfs () | |
122 | provide the same guarantees as fsync called on every file in | |
123 | the system or filesystem respectively. | |
124 | .SH BUGS | |
125 | Before version 1.3.20 Linux did not wait for I/O to complete | |
126 | before returning. | |
47297adb | 127 | .SH SEE ALSO |
7d11c72f | 128 | .BR sync (1), |
fea681da | 129 | .BR fdatasync (2), |
7d11c72f | 130 | .BR fsync (2) |