OSDN Git Service

info/GNU_which: Add some explanations.
[linuxjm/jm.git] / manual / LDP_man-pages / release / man2 / fsync.2
1 .\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu) and
2 .\" and Copyright 2006 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
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.
13 .\"
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.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .\" Modified 21 Aug 1994 by Michael Chastain <mec@shell.portal.com>:
27 .\"   Removed note about old libc (pre-4.5.26) translating to 'sync'.
28 .\" Modified 15 Apr 1995 by Michael Chastain <mec@shell.portal.com>:
29 .\"   Added `see also' section.
30 .\" Modified 13 Apr 1996 by Markus Kuhn <mskuhn@cip.informatik.uni-erlangen.de>
31 .\"   Added remarks about fdatasync.
32 .\" Modified 31 Jan 1997 by Eric S. Raymond <esr@thyrsus.com>
33 .\" Modified 18 Apr 2001 by Andi Kleen
34 .\"   Fix description to describe what it really does; add a few caveats.
35 .\" 2006-04-28, mtk, substantial rewrite of various parts.
36 .\" 2012-02-27 Various changes by Christoph Hellwig <hch@lst.de>
37 .\"
38 .\"*******************************************************************
39 .\"
40 .\" This file was generated with po4a. Translate the source file.
41 .\"
42 .\"*******************************************************************
43 .\"
44 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
45 .\"         all rights reserved.
46 .\" Translated 1997-02-22, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
47 .\" Modified 2001-05-19, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
48 .\" Updated 2005-09-06, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
49 .\" Updated 2006-07-30, Kentaro Shirakata <argrath@ub32.org>
50 .\" Updated 2007-10-13, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.65
51 .\" Updated 2012-04-30, Akihiro MOTOKI <amotoki@gmail.com>
52 .\"
53 .TH FSYNC 2 2020\-06\-09 Linux "Linux Programmer's Manual"
54 .SH 名前
55 fsync \- メモリー上にあるファイルの内容をストレージデバイス上のものと同期させる
56 .SH 書式
57 \fB#include <unistd.h>\fP
58 .PP
59 \fBint fsync(int \fP\fIfd\fP\fB);\fP
60 .PP
61 \fBint fdatasync(int \fP\fIfd\fP\fB);\fP
62 .PP
63 .RS -4
64 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
65 .RE
66 .PP
67 \fBfsync\fP():
68     2.16 以降:
69         No feature test macros need be defined
70     glibc 2.15 以前:
71         _BSD_SOURCE || _XOPEN_SOURCE
72             || /* since glibc 2.8: */ _POSIX_C_SOURCE\ >=\ 200112L
73 .br
74  \fBfdatasync\fP():
75     _POSIX_C_SOURCE\ >=\ 199309L || _XOPEN_SOURCE\ >=\ 500
76 .SH 説明
77 \fBfsync\fP()  transfers ("flushes") all modified in\-core data of (i.e.,
78 modified buffer cache pages for) the file referred to by the file descriptor
79 \fIfd\fP to the disk device (or other permanent storage device) so that all
80 changed information can be retrieved even if the system crashes or is
81 rebooted.  This includes writing through or flushing a disk cache if
82 present.  The call blocks until the device reports that the transfer has
83 completed.
84 .PP
85 As well as flushing the file data, \fBfsync\fP()  also flushes the metadata
86 information associated with the file (see \fBinode\fP(7)).
87 .PP
88 \fBfsync\fP()  の呼び出しは、ファイルが存在しているディレクトリのエントリーがディスクへ 書き込まれたことを保証するわけではない。
89 保証するためには明示的にそのディレクトリのファイルディスクリプターに対しても \fBfsync\fP()  する必要がある。
90 .PP
91 \fBfdatasync\fP()  は \fBfsync\fP()  と同様であるが、メタデータの扱いが異なる。 \fBfdatasync\fP()
92 は、それ以降のデータ読み込みを正しく扱うためにそのメタデータが必要に ならない限り、変更されたメタデータをフラッシュしない。 例えば、 st_atime
93 や st_mtime (それぞれ最終アクセス時刻、最終修正時刻; \fBinode\fP(7) 参照) の変更はフラッシュを必要としない。
94 なぜならこれらはそれ以降のデータ読み込みを正しく扱うために 必要ではないからである。 一方、ファイルサイズ (\fBftruncate\fP(2)  では
95 \fIst_size\fP)  の変更はメタデータのフラッシュが必要である。
96 .PP
97 \fBfdatasync\fP()  の狙いは、全てのメタデータをディスクと同期する必要のない アプリケーションに対して、ディスクアクセスを減らすことである。
98 .SH 返り値
99 成功した場合、これらのシステムコールはゼロを返す。 エラーの場合、\-1 が返され、 \fIerrno\fP が適切に設定される。
100 .SH エラー
101 .TP 
102 \fBEBADF\fP
103 \fIfd\fP が有効なオープンされたディスクリプターでない。
104 .TP 
105 \fBEIO\fP
106 .\" commit 088737f44bbf6378745f5b57b035e57ee3dc4750
107 An error occurred during synchronization.  This error may relate to data
108 written to some other file descriptor on the same file.  Since Linux 4.13,
109 errors from write\-back will be reported to all file descriptors that might
110 have written the data which triggered the error.  Some filesystems (e.g.,
111 NFS) keep close track of which data came through which file descriptor, and
112 give more precise reporting.  Other filesystems (e.g., most local
113 filesystems) will report errors to all file descriptors that were open on
114 the file when the error was recorded.
115 .TP 
116 \fBENOSPC\fP
117 Disk space was exhausted while synchronizing.
118 .TP 
119 \fBEROFS\fP, \fBEINVAL\fP
120 \fIfd\fP が同期操作をサポートしてない特殊なファイル (パイプ、FIFO、ソケットなど) を参照している。
121 .TP 
122 \fBENOSPC\fP, \fBEDQUOT\fP
123 \fIfd\fP is bound to a file on NFS or another filesystem which does not
124 allocate space at the time of a \fBwrite\fP(2)  system call, and some previous
125 write failed due to insufficient storage space.
126 .SH 準拠
127  POSIX.1\-2001, POSIX.1\-2008, 4.3BSD.
128 .PP
129 .\" POSIX.1-2001: It shall be defined to -1 or 0 or 200112L.
130 .\" -1: unavailable, 0: ask using sysconf().
131 .\" glibc defines them to 1.
132 \fBfdatasync\fP()  が利用可能な POSIX システムでは、 \fB_POSIX_SYNCHRONIZED_IO\fP が
133 \fI<unistd.h>\fP で 0 より大きな値に定義される (\fBsysconf\fP(3)  参照)。
134 .SH 注意
135 (Linux はそうではないが) いくつかの UNIX システムでは
136 \fIfd\fP が\fI書き込み可能な\fPファイルディスクリプターでなければならない。
137 .PP
138 Linux 2.2 以前では、 \fBfdatasync\fP()  は \fBfsync\fP()  と等価であり、性能面でのメリットはない。
139 .PP
140 古いカーネルやあまり使われていないファイルシステムの \fBfsync\fP()
141 の実装では、ディスクキャッシュをフラッシュする方法が分からない場合がある。そのような場合には、安全に操作が行われることを保証するため、\fBhdparm\fP(8)
142 や \fBsdparm\fP(8) を使ってディスクキャッシュを無効にする必要がある。
143 .SH 関連項目
144  \fBsync\fP(1), \fBbdflush\fP(2), \fBopen\fP(2), \fBposix_fadvise\fP(2), \fBpwritev\fP(2),
145 \fBsync\fP(2), \fBsync_file_range\fP(2), \fBfflush\fP(3), \fBfileno\fP(3), \fBhdparm\fP(8),
146 \fBmount\fP(8)
147 .SH この文書について
148 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は
149 \%https://www.kernel.org/doc/man\-pages/ に書かれている。