8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / man / man3c / msync.3c
blobea6da46ee84361e34636683d76308b763e26bb85
1 '\" te
2 .\"  Copyright 1989 AT&T  Copyright (c) 2002, Sun Microsystems, Inc.  All Rights Reserved  Portions Copyright (c) 1992, X/Open Company Limited  All Rights Reserved
3 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
4 .\" http://www.opengroup.org/bookstore/.
5 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
6 .\"  This notice shall appear on any product containing this material.
7 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
9 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
10 .TH MSYNC 3C "Jul 24, 2002"
11 .SH NAME
12 msync \- synchronize memory with physical storage
13 .SH SYNOPSIS
14 .LP
15 .nf
16 #include <sys/mman.h>
18 \fBint\fR \fBmsync\fR(\fBvoid *\fR\fIaddr\fR, \fBsize_t\fR \fIlen\fR, \fBint\fR \fIflags\fR);
19 .fi
21 .SH DESCRIPTION
22 .sp
23 .LP
24 The  \fBmsync()\fR function writes all modified copies of pages over the range
25 [\fIaddr, addr + len\fR) to the underlying hardware, or invalidates any copies
26 so that further references to the pages will be obtained by the system from
27 their permanent storage locations. The permanent storage for a modified
28 \fBMAP_SHARED\fR mapping is the file the page is mapped to; the permanent
29 storage for a modified \fBMAP_PRIVATE\fR mapping is its swap area.
30 .sp
31 .LP
32 The \fIflags\fR argument is a bit pattern built from the following values:
33 .sp
34 .ne 2
35 .na
36 \fBMS_ASYNC\fR
37 .ad
38 .RS 17n
39 perform asynchronous writes
40 .RE
42 .sp
43 .ne 2
44 .na
45 \fBMS_SYNC\fR
46 .ad
47 .RS 17n
48 perform synchronous writes
49 .RE
51 .sp
52 .ne 2
53 .na
54 \fBMS_INVALIDATE\fR
55 .ad
56 .RS 17n
57 invalidate mappings
58 .RE
60 .sp
61 .LP
62 If \fIflags\fR is \fBMS_ASYNC\fR or \fBMS_SYNC\fR, the function synchronizes
63 the file contents to match the current contents of the memory region.
64 .RS +4
65 .TP
66 .ie t \(bu
67 .el o
68 All write references to the memory region made prior to the call are visible by
69 subsequent read operations on the file.
70 .RE
71 .RS +4
72 .TP
73 .ie t \(bu
74 .el o
75 All writes to the same portion of the file prior to the call may or may not be
76 visible by read references to the memory region.
77 .RE
78 .RS +4
79 .TP
80 .ie t \(bu
81 .el o
82 Unmodified pages in the specified range are not written to the underlying
83 hardware.
84 .RE
85 .sp
86 .LP
87 If \fIflags\fR is \fBMS_ASYNC\fR, the function may return immediately once all
88 write operations are scheduled; if \fIflags\fR is \fBMS_SYNC\fR, the function
89 does not return until all write operations are completed.
90 .sp
91 .LP
92 If \fIflags\fR is \fBMS_INVALIDATE\fR, the function synchronizes the contents
93 of the memory region to match the current file contents.
94 .RS +4
95 .TP
96 .ie t \(bu
97 .el o
98 All writes to the mapped portion of the file made prior to the call are visible
99 by subsequent read references to the mapped memory region.
101 .RS +4
103 .ie t \(bu
104 .el o
105 All write references prior to the call, by any process, to memory regions
106 mapped to the same portion of the file using \fBMAP_SHARED\fR, are visible by
107 read references to the region.
111 If \fBmsync()\fR causes any write to the file, then the file's \fBst_ctime\fR
112 and \fBst_mtime\fR fields are marked for update.
113 .SH RETURN VALUES
116 Upon successful completion, \fBmsync()\fR returns \fB0\fR; otherwise, it
117 returns \fB\(mi1\fR and sets \fBerrno\fR to indicate the error.
118 .SH ERRORS
121 The \fBmsync()\fR function will fail if:
123 .ne 2
125 \fB\fBEBUSY\fR\fR
127 .RS 10n
128 Some or all of the addresses in the range [\fIaddr\fR, \fIaddr\fR + \fIlen\fR)
129 are locked and \fBMS_SYNC\fR with the \fBMS_INVALIDATE\fR option is specified.
133 .ne 2
135 \fB\fBEAGAIN\fR\fR
137 .RS 10n
138 Some or all pages in the range [\fIaddr\fR,  \fIaddr\fR +  \fIlen\fR) are
139 locked for I/O.
143 .ne 2
145 \fB\fBEINVAL\fR\fR
147 .RS 10n
148 The \fIaddr\fR argument is not a multiple of the  page size as returned by
149 \fBsysconf\fR(3C).
151 The \fIflags\fR argument is not some combination of \fBMS_ASYNC\fR and
152 \fBMS_INVALIDATE\fR.
156 .ne 2
158 \fB\fBEIO\fR\fR
160 .RS 10n
161 An I/O error occurred while reading from or writing to the file system.
165 .ne 2
167 \fB\fBENOMEM\fR\fR
169 .RS 10n
170 Addresses in the range [\fIaddr, addr + len\fR) are outside the valid range for
171 the address space of a process, or specify one or more pages that are not
172 mapped.
176 .ne 2
178 \fB\fBEPERM\fR\fR
180 .RS 10n
181 \fBMS_INVALIDATE\fR was specified and one or more of the pages is locked in
182 memory.
185 .SH USAGE
188 The \fBmsync()\fR function should be used by programs that require a memory
189 object to be in a known state, for example in building transaction facilities.
192 Normal system activity can cause pages to be written to disk.  Therefore, there
193 are no guarantees that \fBmsync()\fR is the only control over when pages are or
194 are not written to disk.
195 .SH ATTRIBUTES
198 See \fBattributes\fR(5) for descriptions of the following attributes:
203 box;
204 c | c
205 l | l .
206 ATTRIBUTE TYPE  ATTRIBUTE VALUE
208 Interface Stability     Standard
210 MT-Level        MT-Safe
213 .SH SEE ALSO
216 \fBmemcntl\fR(2), \fBmmap\fR(2), \fBsysconf\fR(3C), \fBattributes\fR(5),
217 \fBstandards\fR(5)