SYNC

Section: Linux Programmer's Manual (2)
Updated: 2020-08-13
Index JM Home Page
 

名前

sync, syncfs - ファイルシステムキャッシュをディスクに書き込む  

書式

#include <unistd.h>

void sync(void);

int syncfs(int fd);

glibc 向けの機能検査マクロの要件 (feature_test_macros(7) 参照):

sync():

_XOPEN_SOURCE >= 500
    || /* Since glibc 2.19: */ _DEFAULT_SOURCE
    || /* Glibc versions <= 2.19: */ _BSD_SOURCE

syncfs():

_GNU_SOURCE
 

説明

sync() causes all pending modifications to filesystem metadata and cached file data to be written to the underlying filesystems.

syncfs() は sync() と同様だが、オープンされたファイルディスクリプター fd が参照するファイルを含むファイルシステムだけを同期する点が異なる。  

返り値

syncfs() は成功すると 0 を返す。エラーが発生した場合は -1 を返し、 errno にエラーを示す値を設定する。  

エラー

sync() は常に成功する。

syncfs() は少なくとも以下の理由で失敗する可能性がある:

EBADF
fd が有効なファイルディスクリプターでない。。
EIO
An error occurred during synchronization. This error may relate to data written to any file on the filesystem, or on metadata related to the filesystem itself.
ENOSPC
Disk space was exhausted while synchronizing.
ENOSPC, EDQUOT
Data was written to a files on NFS or another filesystem which does not allocate space at the time of a write(2) system call, and some previous write failed due to insufficient storage space.
 

バージョン

syncfs() は Linux 2.6.39 で初めて登場した。 ライブラリによるサポートは glibc バージョン 2.14 で追加された。  

準拠

sync(): POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.

syncfs() is Linux 固有である。  

注意

Linux での sync() のプロトタイプは、さまざまな標準規格での規定に準拠し、 glibc 2.2.2 から上述のようになった。 glibc 2.2.1 以前ではプロトタイプは "int sync(void)" で、 sync() は常に 0 を返していた。

According to the standard specification (e.g., POSIX.1-2001), sync() schedules the writes, but may return before the actual writing is done. However Linux waits for I/O completions, and thus sync() or syncfs() provide the same guarantees as fsync() called on every file in the system or filesystem respectively.

In mainline kernel versions prior to 5.8, syncfs() will fail only when passed a bad file descriptor (EBADF). Since Linux 5.8, syncfs() will also report an error if one or more inodes failed to be written back since the last syncfs() call.  

バグ

Before version 1.3.20 Linux did not wait for I/O to complete before returning.  

関連項目

sync(1), fdatasync(2), fsync(2)  

この文書について

この man ページは Linux man-pages プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は https://www.kernel.org/doc/man-pages/ に書かれている。

関連キーワード

syncfs, filesystem, SOURCE, エラー, file, written, バージョン, バグ, 準拠, int

Linux マニュアル 一覧

[man1] [man2] [man3] [man4] [man5] [man6] [man7] [man8]
[a] [b] [c] [d] [e] [f] [g] [h] [i] [j] [k] [l] [m] [n] [o] [p] [q] [r] [s] [t] [u] [v] [w] [x] [y] [z]

 

Index

名前
書式
説明
返り値
エラー
バージョン
準拠
注意
バグ
関連項目
この文書について

This document was created by man2html, using the manual pages.
Time: 12:08:49 GMT, June 11, 2022