1.\" $NetBSD: msync.2,v 1.9 1997/10/16 23:21:57 christos Exp $ 2.\" 3.\" Copyright (c) 1991, 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. All advertising materials mentioning features or use of this software 15.\" must display the following acknowledgement: 16.\" This product includes software developed by the University of 17.\" California, Berkeley and its contributors. 18.\" 4. Neither the name of the University nor the names of its contributors 19.\" may be used to endorse or promote products derived from this software 20.\" without specific prior written permission. 21.\" 22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32.\" SUCH DAMAGE. 33.\" 34.\" @(#)msync.2 8.1 (Berkeley) 6/9/93 35.\" 36.Dd October 10, 1997 37.Dt MSYNC 2 38.Os NetBSD 1.3 39.Sh NAME 40.Nm msync 41.Nd synchronize a mapped region 42.Sh SYNOPSIS 43.Fd #include <sys/mman.h> 44.Ft int 45.Fn msync "void *addr" "size_t len" "int flags" 46.Sh DESCRIPTION 47The 48.Fn msync 49system call writes all pages with shared modifications 50in the specified 51region of the process's address space back to permanent 52storage, and, if requested, invalidates cached data mapped 53in the region. 54If 55.Fa len 56is 0, all modified pages within the region containing 57.Fa addr 58will be flushed; 59if 60.Fa len 61is non-zero, only modified pages containing 62.Fa addr 63and 64.Fa len 65succeeding locations will be flushed. 66Any required synchronization of memory caches 67will also take place at this time. 68Filesystem operations on a file that is mapped for shared modifications 69are unpredictable except after an 70.Fn msync . 71.Pp 72The 73.Fa flags 74argument is formed by 75.Em or Ns 'ing 76the following values 77.Pp 78.Bd -literal -offset indent -compact 79MS_ASYNC Perform asynchronous writes. 80MS_SYNC Perform synchronous writes. 81MS_INVALIDATE Invalidate cached data after writing. 82.Ed 83.Sh ERRORS 84The following errors may be reported: 85.Bl -tag -width Er 86.It Bq Er EBUSY 87The 88.Dv MS_INVALIDATE 89flag was specified and a portion of the specified region 90was locked with 91.Xr mlock 2 . 92.It Bq Er EINVAL 93The specified 94.Fa flags 95argument was invalid. 96.It Bq Er EINVAL 97The 98.Fa addr 99parameter was not page aligned. 100.It Bq Er EIO 101An I/O error occured while writing. 102.It Bq Er ENOMEM 103Addresses in the specified region are outside the range allowed 104for the address space of the process, or specify one or more pages 105which are unmapped. 106.Sh SEE ALSO 107.Xr mlock 2 , 108.Xr mmap 2 , 109.Xr munlock 2 110.Sh BUGS 111Writes are currently done synchronously even if the 112.Dv MS_ASYNC 113flag is specified. 114.Sh HISTORY 115The 116.Fn msync 117function first appeared in 118.Bx 4.4 . 119It was modified to conform to 120.St -p1003.1b-93 121in 122.Nx 1.3 . 123.P 124