1SYNC(2) Linux Programmer's Manual SYNC(2)
2
3
4
6 sync, syncfs - commit buffer cache to disk
7
9 #include <unistd.h>
10
11 void sync(void);
12
13 int syncfs(int fd);
14
15 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
16
17 sync():
18 _BSD_SOURCE || _XOPEN_SOURCE >= 500 ||
19 _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
20
21 syncfs():
22 _GNU_SOURCE
23
25 sync() causes all buffered modifications to file metadata and data to
26 be written to the underlying file systems.
27
28 syncfs() is like sync(), but synchronizes just the file system containā
29 ing file referred to by the open file descriptor fd.
30
32 syncfs() returns 0 on success; on error, it returns -1 and sets errno
33 to indicate the error.
34
36 sync() is always successful.
37
38 syncfs() can fail for at least the following reason:
39
40 EBADF fd is not a valid file descriptor.
41
43 syncfs() first appeared in Linux 2.6.39; library support was added to
44 glibc in version 2.14.
45
47 sync(): SVr4, 4.3BSD, POSIX.1-2001.
48
49 syncfs() is Linux-specific.
50
52 Since glibc 2.2.2 the Linux prototype for sync() is as listed above,
53 following the various standards. In libc4, libc5, and glibc up to
54 2.2.1 it was "int sync(void)", and sync() always returned 0.
55
57 According to the standard specification (e.g., POSIX.1-2001), sync()
58 schedules the writes, but may return before the actual writing is done.
59 However, since version 1.3.20 Linux does actually wait. (This still
60 does not guarantee data integrity: modern disks have large caches.)
61
63 bdflush(2), fdatasync(2), fsync(2), sync(8), update(8)
64
66 This page is part of release 3.53 of the Linux man-pages project. A
67 description of the project, and information about reporting bugs, can
68 be found at http://www.kernel.org/doc/man-pages/.
69
70
71
72Linux 2012-05-04 SYNC(2)