.\" Copyright (C) 1996 Andries Brouwer (aeb@cwi.nl) .\" .\" %%%LICENSE_START(VERBATIM) .\" 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. .\" %%%LICENSE_END .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya .\" all rights reserved. .\" Translated Sun Feb 23 19:45:43 JST 1997 .\" by HANATAKA Shinya .\" Updated and revised Fri Oct 24 23:34:51 JST 2003 .\" by Suzuki Takashi. .\" Updated 2007-01-01 by Kentaro Shirakata .\" .TH MSYNC 2 2014\-04\-20 Linux "Linux Programmer's Manual" .SH 名前 msync \- ファイルをマップしたメモリと同期させる .SH 書式 \fB#include \fP .sp \fBint msync(void *\fP\fIaddr\fP\fB, size_t \fP\fIlength\fP\fB, int \fP\fIflags\fP\fB);\fP .SH 説明 \fBmsync\fP() は \fBmmap\fP(2) を使ってメモリにマップされたファイルの、 メモリ上のコピーになされた変更をディスクに反映させる。 この関数を使用しないと、 \fBmunmap\fP(2) が呼び出されるまで変更が書き戻される保証はない。 より正確には、ファイルのうち \fIaddr\fP から始まり長さ \fIlength\fP のメモリ領域に対応する部分が更新される。 \fIflags\fP 引数にはビット \fBMS_ASYNC\fP, \fBMS_SYNC\fP, \fBMS_INVALIDATE\fP を設定することができるが、 \fBMS_ASYNC\fP と \fBMS_SYNC\fP を同時に指定することはできない。 \fBMS_ASYNC\fP は更新を予定に組み込むことを表し、呼び出しは直ちに返る。 \fBMS_SYNC\fP は更新を要求し、更新が完了するまで待つ。 \fBMS_INVALIDATE\fP は(たった今書き込んだ新しい値でマッピングを更新することができるように) 同じファイルに対する他のマッピングを無効にすることを要求する。 .SH 返り値 成功した場合、 0 が返る。エラーの場合、 \-1 が返り、 \fIerrno\fP が適切に設定される。 .SH エラー .TP \fBEBUSY\fP I flags に \fBMS_INVALIDATE\fP が指定されたが、指定されたアドレス範囲にロックが存在する。 .TP \fBEINVAL\fP \fIaddr\fP が PAGESIZE の倍数でない。または、 \fIflags\fP に \fBMS_ASYNC\fP、\fBMS_INVALIDATE\fP、\fBMS_SYNC\fP 以外のビットが設定された。 または、 \fIflags\fP に \fBMS_SYNC\fP と \fBMS_ASYNC\fP の両方が設定された。 .TP \fBENOMEM\fP 指定されたメモリ (またはその一部) がマップされていない。 .SH 準拠 POSIX.1\-2001. この関数は Linux 1.3.21 で導入されたが、 \fBENOMEM\fP ではなく \fBEFAULT\fP が使われていた。 これは Linux 2.4.19 で POSIX における値 \fBENOMEM\fP に変更された。 .SH 可用性 .\" POSIX.1-2001: It shall be defined to -1 or 0 or 200112L. .\" -1: unavailable, 0: ask using sysconf(). .\" glibc defines them to 1. \fBmsync\fP() が使用可能な POSIX システムでは \fB_POSIX_MAPPED_FILES\fP と \fB_POSIX_SYNCHRONIZED_IO\fP の両方が \fI\fP で 0 より大きい値に定義される。 (\fBsysconf\fP(3) を参照すること。 ) .SH 注意 .\" commit 204ec841fbea3e5138168edbc3a76d46747cc987 POSIX では \fBMS_SYNC\fP と \fBMS_ASYNC\fP のいずれかは必ず \fIflags\fP に指定しなければならないとされており、 実際にこれらのフラグのいずれかを指定しなかった場合 \fBmsync\fP() が失敗するシステムもある。 しかし、 Linux ではこれらのフラグのいずれも指定せずに \fBmsync\fP() を呼び出すことができ、 その場合の動作は (現在のところ) \fBMS_ASYNC\fP を指定した場合と等価である。 (Linux 2.6.19 以降では \fBMS_ASYNC\fP は実際には no\-op (何もしない命令) である。 これはカーネルが正しく dirty ページを追跡し、必要に応じてストレージにそれらをフラッシュするからである。) Linux の動作に関係なく、アプリケーションの移植性を考慮し、将来も確実に動くようにするには、 \fBMS_SYNC\fP か \fBMS_ASYNC\fP のいずれかを必ず \fIflags\fP に指定するようにすべきである。 .SH 関連項目 \fBmmap\fP(2) B.O. Gallmeister, POSIX.4, O'Reilly, pp. 128\-129 and 389\-391. .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.65 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。