1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright (C) 1996 Andries Brouwer (aeb@cwi.nl)
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.
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.
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
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
25 .TH MSYNC 2 2003-08-21 "Linux 2.4" "Linux Programmer's Manual"
27 msync \- synchronize a file with a memory map
29 .B #include <sys/mman.h>
31 .BI "int msync(void *" start ", size_t " length ", int " flags );
34 flushes changes made to the in-core copy of a file that was mapped
37 back to disk. Without use of this call
38 there is no guarantee that changes are written back before
40 is called. To be more precise, the part of the file that
41 corresponds to the memory area starting at
47 argument may have the bits MS_ASYNC, MS_SYNC and MS_INVALIDATE set,
48 but not both MS_ASYNC and MS_SYNC.
49 MS_ASYNC specifies that an update be scheduled, but the call
51 MS_SYNC asks for an update and waits for it to complete.
52 MS_INVALIDATE asks to invalidate other mappings of the same file
53 (so that they can be updated with the fresh values just written).
55 On success, zero is returned. On error, \-1 is returned, and
62 is not a multiple of PAGESIZE, or any bit other than
63 MS_ASYNC | MS_INVALIDATE | MS_SYNC is set in
67 The indicated memory (or part of it) was not mapped.
69 On POSIX systems on which
72 .B _POSIX_MAPPED_FILES
74 .B _POSIX_SYNCHRONIZED_IO
75 are defined in <unistd.h> to a value greater than 0. (See also
77 .\" POSIX 1003.1-2001: It shall be defined to -1 or 0 or 200112L.
78 .\" -1: unavailable, 0: ask using sysconf().
79 .\" glibc defines them to 1.
81 POSIX.1b (formerly POSIX.4)
83 This call was introduced in Linux 1.3.21, and then used EFAULT instead of
84 ENOMEM. In Linux 2.4.19 this was changed to the POSIX value ENOMEM.
88 B.O. Gallmeister, POSIX.4, O'Reilly, pp. 128-129 and 389-391.