.\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" %sccs.include.redist.roff% .\" .\" @(#)msync.2 8.2 (Berkeley) 06/21/94 .\" .Dd .Dt MSYNC 2 .Os .Sh NAME .Nm msync .Nd synchronize a mapped region .Sh SYNOPSIS .Fn msync "caddr_t addr" "int len" .Sh DESCRIPTION The .Fn msync system call writes any modified pages back to the filesystem and updates the file modification time. If .Fa len is 0, all modified pages within the region containing .Fa addr will be flushed; if .Fa len is non-zero, only the pages containing .Fa addr and .Fa len succeeding locations will be examined. Any required synchronization of memory caches will also take place at this time. Filesystem operations on a file that is mapped for shared modifications are unpredictable except after an .Fn msync . .Sh ERRORS The following errors may be reported: .Bl -tag -width Er .It Bq Er EINVAL The .Fa addr parameter was not page aligned. .It Bq Er EINVAL The .Fa addr parameter did not specify an address part of a mapped region. .It Bq Er EINVAL The .Fa len parameter was negative. .It Bq Er EIO An I/O error occured while writing to the file system. .Sh SEE ALSO .Xr madvise 2 , .Xr munmap 2 , .Xr mprotect 2 , .Xr mincore 2 .Sh HISTORY The .Fn msync function first appeared in 4.4BSD.