]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/msync.2
Automated addition of parentheses by add_parens_for_own_funcs.sh
[thirdparty/man-pages.git] / man2 / msync.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Copyright (C) 1996 Andries Brouwer (aeb@cwi.nl)
4 .\"
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 .\"
25 .TH MSYNC 2 2003-08-21 "Linux 2.4" "Linux Programmer's Manual"
26 .SH NAME
27 msync \- synchronize a file with a memory map
28 .SH SYNOPSIS
29 .B #include <sys/mman.h>
30 .sp
31 .BI "int msync(void *" start ", size_t " length ", int " flags );
32 .SH DESCRIPTION
33 .BR msync ()
34 flushes changes made to the in-core copy of a file that was mapped
35 into memory using
36 .BR mmap (2)
37 back to disk. Without use of this call
38 there is no guarantee that changes are written back before
39 .BR munmap (2)
40 is called. To be more precise, the part of the file that
41 corresponds to the memory area starting at
42 .I start
43 and having length
44 .I length
45 is updated. The
46 .I flags
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
50 returns immediately.
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).
54 .SH "RETURN VALUE"
55 On success, zero is returned. On error, \-1 is returned, and
56 .I errno
57 is set appropriately.
58 .SH ERRORS
59 .TP
60 .BR EINVAL
61 .I start
62 is not a multiple of PAGESIZE, or any bit other than
63 MS_ASYNC | MS_INVALIDATE | MS_SYNC is set in
64 .IR flags .
65 .TP
66 .B ENOMEM
67 The indicated memory (or part of it) was not mapped.
68 .SH AVAILABILITY
69 On POSIX systems on which
70 .BR msync ()
71 is available, both
72 .B _POSIX_MAPPED_FILES
73 and
74 .B _POSIX_SYNCHRONIZED_IO
75 are defined in <unistd.h> to a value greater than 0. (See also
76 .BR sysconf (3).)
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.
80 .SH "CONFORMING TO"
81 POSIX.1b (formerly POSIX.4)
82
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.
85 .SH "SEE ALSO"
86 .BR mmap (2)
87 .br
88 B.O. Gallmeister, POSIX.4, O'Reilly, pp. 128-129 and 389-391.