xref: /minix3/lib/libc/sys/msync.2 (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc.\"	$NetBSD: msync.2,v 1.25 2014/05/09 17:25:11 njoly Exp $
22fe8fb19SBen Gras.\"
32fe8fb19SBen Gras.\" Copyright (c) 1991, 1993
42fe8fb19SBen Gras.\"	The Regents of the University of California.  All rights reserved.
52fe8fb19SBen Gras.\"
62fe8fb19SBen Gras.\" Redistribution and use in source and binary forms, with or without
72fe8fb19SBen Gras.\" modification, are permitted provided that the following conditions
82fe8fb19SBen Gras.\" are met:
92fe8fb19SBen Gras.\" 1. Redistributions of source code must retain the above copyright
102fe8fb19SBen Gras.\"    notice, this list of conditions and the following disclaimer.
112fe8fb19SBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright
122fe8fb19SBen Gras.\"    notice, this list of conditions and the following disclaimer in the
132fe8fb19SBen Gras.\"    documentation and/or other materials provided with the distribution.
142fe8fb19SBen Gras.\" 3. Neither the name of the University nor the names of its contributors
152fe8fb19SBen Gras.\"    may be used to endorse or promote products derived from this software
162fe8fb19SBen Gras.\"    without specific prior written permission.
172fe8fb19SBen Gras.\"
182fe8fb19SBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
192fe8fb19SBen Gras.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
202fe8fb19SBen Gras.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
212fe8fb19SBen Gras.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
222fe8fb19SBen Gras.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
232fe8fb19SBen Gras.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
242fe8fb19SBen Gras.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
252fe8fb19SBen Gras.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
262fe8fb19SBen Gras.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
272fe8fb19SBen Gras.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
282fe8fb19SBen Gras.\" SUCH DAMAGE.
292fe8fb19SBen Gras.\"
302fe8fb19SBen Gras.\"	@(#)msync.2	8.2 (Berkeley) 6/21/94
312fe8fb19SBen Gras.\"
32*0a6a1f1dSLionel Sambuc.Dd May 9, 2014
332fe8fb19SBen Gras.Dt MSYNC 2
342fe8fb19SBen Gras.Os
352fe8fb19SBen Gras.Sh NAME
362fe8fb19SBen Gras.Nm msync
372fe8fb19SBen Gras.Nd synchronize a mapped region
382fe8fb19SBen Gras.Sh LIBRARY
392fe8fb19SBen Gras.Lb libc
402fe8fb19SBen Gras.Sh SYNOPSIS
412fe8fb19SBen Gras.In sys/mman.h
422fe8fb19SBen Gras.Ft int
432fe8fb19SBen Gras.Fn msync "void *addr" "size_t len" "int flags"
442fe8fb19SBen Gras.Sh DESCRIPTION
452fe8fb19SBen GrasThe
462fe8fb19SBen Gras.Fn msync
472fe8fb19SBen Grassystem call writes all pages with shared modifications
482fe8fb19SBen Grasin the specified
492fe8fb19SBen Grasregion of the process's address space back to permanent
502fe8fb19SBen Grasstorage, and, if requested, invalidates cached data mapped
512fe8fb19SBen Grasin the region.
522fe8fb19SBen GrasIf
532fe8fb19SBen Gras.Fa len
542fe8fb19SBen Grasis 0, all modified pages within the region containing
552fe8fb19SBen Gras.Fa addr
562fe8fb19SBen Graswill be flushed;
572fe8fb19SBen Grasif
582fe8fb19SBen Gras.Fa len
592fe8fb19SBen Grasis non-zero, only modified pages containing
602fe8fb19SBen Gras.Fa addr
612fe8fb19SBen Grasand
622fe8fb19SBen Gras.Fa len
632fe8fb19SBen Grassucceeding locations will be flushed.
642fe8fb19SBen GrasAny required synchronization of memory caches
652fe8fb19SBen Graswill also take place at this time.
662fe8fb19SBen GrasFilesystem operations on a file that is mapped for shared modifications
672fe8fb19SBen Grasare unpredictable except after an
682fe8fb19SBen Gras.Fn msync .
692fe8fb19SBen Gras.Pp
702fe8fb19SBen GrasThe
712fe8fb19SBen Gras.Fa flags
722fe8fb19SBen Grasargument is formed by
732fe8fb19SBen Gras.Em or Ns 'ing
742fe8fb19SBen Grasthe following values
752fe8fb19SBen Gras.Pp
762fe8fb19SBen Gras.Bl -column -offset indent -compact MS_INVALIDATE
772fe8fb19SBen Gras.It Dv MS_ASYNC Ta Perform asynchronous writes.
782fe8fb19SBen Gras.It Dv MS_SYNC Ta Perform synchronous writes.
792fe8fb19SBen Gras.It Dv MS_INVALIDATE Ta Invalidate cached data after writing.
802fe8fb19SBen Gras.El
812fe8fb19SBen Gras.Sh RETURN VALUES
822fe8fb19SBen GrasUpon successful completion,
832fe8fb19SBen Grasa value of 0 is returned.
842fe8fb19SBen GrasOtherwise, a value of \-1 is returned and
852fe8fb19SBen Gras.Va errno
862fe8fb19SBen Grasis set to indicate the error.
872fe8fb19SBen Gras.Sh ERRORS
882fe8fb19SBen GrasThe following errors may be reported:
892fe8fb19SBen Gras.Bl -tag -width Er
902fe8fb19SBen Gras.It Bq Er EBUSY
912fe8fb19SBen GrasThe
922fe8fb19SBen Gras.Dv MS_INVALIDATE
932fe8fb19SBen Grasflag was specified and a portion of the specified region
942fe8fb19SBen Graswas locked with
952fe8fb19SBen Gras.Xr mlock 2 .
962fe8fb19SBen Gras.It Bq Er EINVAL
972fe8fb19SBen GrasThe specified
982fe8fb19SBen Gras.Fa flags
992fe8fb19SBen Grasargument was invalid.
1002fe8fb19SBen Gras.It Bq Er EINVAL
1012fe8fb19SBen GrasThe
1022fe8fb19SBen Gras.Fa addr
1032fe8fb19SBen Grasparameter was not page aligned.
1042fe8fb19SBen Gras.It Bq Er EINVAL
1052fe8fb19SBen GrasThe
1062fe8fb19SBen Gras.Fa addr
1072fe8fb19SBen Grasparameter did not specify an address part of a mapped region.
1082fe8fb19SBen Gras.It Bq Er EIO
1092fe8fb19SBen GrasAn I/O error occurred while writing to the file system.
1102fe8fb19SBen Gras.It Bq Er ENOMEM
1112fe8fb19SBen GrasAddresses in the specified region are outside the range allowed
1122fe8fb19SBen Grasfor the address space of the process, or specify one or more pages
1132fe8fb19SBen Graswhich are unmapped.
1142fe8fb19SBen Gras.El
1152fe8fb19SBen Gras.Sh SEE ALSO
1162fe8fb19SBen Gras.Xr mlock 2 ,
1172fe8fb19SBen Gras.Xr mmap 2 ,
1182fe8fb19SBen Gras.Xr munlock 2
119f14fb602SLionel Sambuc.Sh STANDARDS
120f14fb602SLionel SambucThe
121f14fb602SLionel Sambuc.Fn msync
122f14fb602SLionel Sambucfunction conforms to
123f14fb602SLionel Sambuc.St -p1003.1b-93
1242fe8fb19SBen Gras.Sh HISTORY
1252fe8fb19SBen GrasThe
1262fe8fb19SBen Gras.Fn msync
1272fe8fb19SBen Grasfunction first appeared in
1282fe8fb19SBen Gras.Bx 4.4 .
1292fe8fb19SBen GrasIt was modified to conform to
1302fe8fb19SBen Gras.St -p1003.1b-93
1312fe8fb19SBen Grasin
1322fe8fb19SBen Gras.Nx 1.3 .
133