1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
|
.\" Hey Emacs! This file is -*- nroff -*- source.
.\"
.\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu) and
.\" and Copyright 2006 Michael Kerrisk <mtk.manpages@gmail.com>
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date. The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein. The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" Modified 21 Aug 1994 by Michael Chastain <mec@shell.portal.com>:
.\" Removed note about old libc (pre-4.5.26) translating to 'sync'.
.\" Modified 15 Apr 1995 by Michael Chastain <mec@shell.portal.com>:
.\" Added `see also' section.
.\" Modified 13 Apr 1996 by Markus Kuhn <mskuhn@cip.informatik.uni-erlangen.de>
.\" Added remarks about fdatasync.
.\" Modified Fri Jan 31 16:27:42 1997 by Eric S. Raymond <esr@thyrsus.com>
.\" Modified 31 Jan 1997 by Eric S. Raymond <esr@thyrsus.com>
.\" Modified 18 Apr 2001 by Andi Kleen
.\" Fix description to describe what it really does; add a few caveats.
.\" 2006-04-28, mtk, substantial rewrite of various parts.
.\"
.\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
.\" all rights reserved.
.\" Translated 1997-02-22, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Modified 2001-05-19, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Updated 2005-09-06, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\" Updated 2006-07-30, Kentaro Shirakata <argrath@ub32.org>
.\" Updated 2007-10-13, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.65
.\"
.\"WORD: core
.\"WORD: disk ǥ
.\"WORD: synchronize Ʊ
..\"
.TH FSYNC 2 2007-07-26 "Linux" "Linux Programmer's Manual"
.SH ̾
fsync \- ˤեƤȥ졼ǥХΤΤƱ
.SH
.B #include <unistd.h>
.sp
.BI "int fsync(int " fd );
.sp
.BI "int fdatasync(int " fd );
.sp
.in -4n
glibc εǽޥ
.RB ( feature_test_macros (7)
):
.in
.sp
.BR fsync ():
_BSD_SOURCE || _XOPEN_SOURCE
.br
.BR fdatasync ():
_POSIX_C_SOURCE\ >=\ 199309L || _XOPEN_SOURCE\ >=\ 500
.SH
.BR fsync ()
ϡե뵭һ
.I fd
ǻȤեǻäƤǡ
(ĤޤХåեåڡ) Τ줿ǡ
Υե뤬°ǥǥХ (ޤϤ¾α³ȥ졼ǥХ)
ž (֥եå) 롣
θƤӽФžäȥǥХ𤹤ޤǥ֥å롣
ޤե˷ӤĤǡ
.RB ( stat (2)
) եå夹롣
.BR fsync ()
θƤӽФϡե뤬¸ߤƤǥ쥯ȥΥȥ꤬ǥ
ޤ줿Ȥݾڤ櫓ǤϤʤ
ݾڤ뤿ˤŪˤΥǥ쥯ȥΥե뵭һҤФƤ
.BR fsync ()
ɬפ롣
.BR fdatasync ()
.BR fsync ()
ƱͤǤ뤬ǡΰۤʤ롣
.BR fdatasync ()
ϡʹߤΥǡɤ߹ߤˤΥǡɬפ
ʤʤ¤ꡢѹ줿ǡեå夷ʤ
㤨С
st_atime st_mtime
(줾ǽǽ;
.BR stat (2)
) ѹϥեåɬפȤʤ
ʤʤ餳ϤʹߤΥǡɤ߹ߤ
ɬפǤϤʤǤ롣
ե륵
.RB ( ftruncate (2)
Ǥ
.IR st_size )
ѹϥǡΥեå夬ɬפǤ롣
.BR fdatasync ()
ϡƤΥǡǥƱɬפΤʤ
ץꥱФơǥ餹ȤǤ롣
.SH ֤
硢Υƥॳϥ֤
顼ξ硢\-1 ֤졢
.I errno
Ŭڤꤵ롣
.SH 顼
.TP
.B EBADF
.I fd
ߤΤ˥ץ줿ե뵭һҤǤʤ
.TP
.B EIO
Ʊδ֤˥顼ȯ
.TP
.BR EROFS ", " EINVAL
.I fd
ƱݡȤƤʤüʥեȤƤ롣
.SH
4.3BSD, POSIX.1-2001
.SH
.BR fdatasync ()
Ѳǽ POSIX ƥǤϡ
.B _POSIX_SYNCHRONIZED_IO
.I <unistd.h>
0 礭ͤ
.RB ( sysconf (3)
)
.\" POSIX.1-2001: It shall be defined to -1 or 0 or 200112L.
.\" -1: unavailable, 0: ask using sysconf().
.\" glibc defines them to 1.
.SH
ǡ١ե˥륢ץꥱϡ
˾ʥǡҤνߤԤθ夹
.BR fsync ()
ƤӽФơǡϡɥǥʪŪ
μ¤˳Ǽ褦ˤ뤳Ȥ¿
ǰʤ顢
.BR fsync ()
Ͼ 2ĤνϤ롣
ĤϿޤ줿ǡФΤǤꡢ
⤦Ĥ inode ˳Ǽ뽤 (modification time)
뤿ΤΤǤ롣
ιԲʬ (ȥ) ΰǤϤʤ硢
.BR fdatasync ()
ȤȤǡɬפ inode Υǥ뤳ȤǤ롣
ǡ֤Ƥϡɥǥνߥå夬ͭ
ʤäƤ硢
.BR fsync ()
/
.BR fdatasync ()
äƤȤƤ⡢Υǡϼºݤˤϱ³ŪʵΤ
ǼƤʤ⤷ʤ
.\" IDE ǥΥå̵ˤˡˤĤƤ
.\" .BR hdparm (8)
.\" ȤΤȡ
.LP
ext2 ե롦ƥब
.I sync
ץĤǥޥȤƤ硢
.BR fsync ()
ǥǥ쥯ȥꡦȥۤΤƱ롣
.LP
2.4 ΥͥǤϵʥե
.BR fsync ()
Ѥ뤳ȤϸΨ礬롣
̤ˡȤ
.BR open (2)
κݤ
.B O_SYNC
ե饰ѤΤɤ⤷ʤ
Linux 2.2 Ǥϡ
.BR fdatasync ()
.BR fsync ()
Ǥꡢǽ̤ǤΥåȤϤʤ
.SH Ϣ
.BR bdflush (2),
.BR open (2),
.BR sync (2),
.BR sync_file_range (2),
.BR hdparm (8),
.BR mount (8),
.BR sync (8),
.BR update (8)
|