.\" 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 2020\-06\-09 Linux "Linux Programmer's Manual" .SH 名前 msync \- ファイルをマップしたメモリーと同期させる .SH 書式 \fB#include \fP .PP \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 のメモリー領域に対応する部分が更新される。 .PP The \fIflags\fP argument should specify exactly one of \fBMS_ASYNC\fP and \fBMS_SYNC\fP, and may additionally include the \fBMS_INVALIDATE\fP bit. These bits have the following meanings: .TP \fBMS_ASYNC\fP Specifies that an update be scheduled, but the call returns immediately. .TP \fBMS_SYNC\fP Requests an update and waits for it to complete. .TP \fBMS_INVALIDATE\fP .\" Since Linux 2.4, this seems to be a no-op (other than the .\" EBUSY check for VM_LOCKED). Asks to invalidate other mappings of the same file (so that they can be updated with the fresh values just written). .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, POSIX.1\-2008. .PP この関数は Linux 1.3.21 で導入されたが、 \fBENOMEM\fP ではなく \fBEFAULT\fP が使われていた。 これは Linux 2.4.19 で POSIX における値 \fBENOMEM\fP に変更された。 .PP .\" 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) .PP B.O. Gallmeister, POSIX.4, O'Reilly, pp. 128\(en129 and 389\(en391. .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は \%https://www.kernel.org/doc/man\-pages/ に書かれている。