date and time created 91/05/27 21:44:42 by mckusick
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Tue, 28 May 1991 12:44:42 +0000 (04:44 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Tue, 28 May 1991 12:44:42 +0000 (04:44 -0800)
SCCS-vsn: lib/libc/sys/mmap.2 6.1

usr/src/lib/libc/sys/mmap.2 [new file with mode: 0644]

diff --git a/usr/src/lib/libc/sys/mmap.2 b/usr/src/lib/libc/sys/mmap.2
new file mode 100644 (file)
index 0000000..c6363ad
--- /dev/null
@@ -0,0 +1,96 @@
+.\" Copyright (c) 1991 Regents of the University of California.
+.\" All rights reserved.
+.\"
+.\" %sccs.include.redist.man%
+.\"
+.\"    @(#)mmap.2      6.1 (Berkeley) %G%
+.\"
+.TH MMAP 2 ""
+.UC 7
+.SH NAME
+mmap \- map files or devices into memory
+.SH SYNOPSIS
+.nf
+.B caddr_t
+mmap(addr, len, prot, flags, fd, pos)
+.B caddr_t addr;
+.B int len, prot, flags, fd;
+.B off_t pos;
+.fi
+.SH DESCRIPTION
+.PP
+The \fImmap\fP system call
+causes the pages starting at \fIaddr\fP and continuing
+for at most \fIlen\fP bytes to be mapped from the object represented by
+descriptor \fIfd\fP, starting at byte offset \fIpos\fP.
+The starting address of the region is returned;
+for the convenience of the system,
+it may differ from that supplied
+unless the MAP_FIXED flag is given,
+in which case the exact address will be used or the call will fail.
+The \fIaddr\fP, \fIlen\fP, and \fIpos\fP parameters
+must all be multiples of the pagesize.
+A successful \fImmap\fP will delete any previous mapping
+in the allocated address range.
+.PP
+The system supports sharing of data between processes
+by allowing pages to be mapped into memory.  These mapped
+pages may be \fIshared\fP with other processes or \fIprivate\fP
+to the process.
+Protection and sharing options are defined in \fI<sys/mman.h>\fP as:
+.DS
+.ta \w'#define\ \ 'u +\w'MAP_HASSEMAPHORE\ \ 'u +\w'0x0080\ \ 'u
+/* protections are chosen from these bits, or-ed together */
+#define        PROT_READ       0x04    /* pages can be read */
+#define        PROT_WRITE      0x02    /* pages can be written */
+#define        PROT_EXEC       0x01    /* pages can be executed */
+.DE
+.DS
+.ta \w'#define\ \ 'u +\w'MAP_HASSEMAPHORE\ \ 'u +\w'0x0080\ \ 'u
+/* flags contain mapping type, sharing type and options */
+/* mapping type; choose one */
+#define MAP_FILE       0x0001  /* mapped from a file or device */
+#define MAP_ANON       0x0002  /* allocated from memory, swap space */
+#define MAP_TYPE       0x000f  /* mask for type field */
+.DE
+.DS
+.ta \w'#define\ \ 'u +\w'MAP_HASSEMAPHORE\ \ 'u +\w'0x0080\ \ 'u
+/* sharing types; choose one */
+#define        MAP_SHARED      0x0010  /* share changes */
+#define        MAP_PRIVATE     0x0000  /* changes are private */
+.DE
+.DS
+.ta \w'#define\ \ 'u +\w'MAP_HASSEMAPHORE\ \ 'u +\w'0x0080\ \ 'u
+/* other flags */
+#define MAP_FIXED      0x0020  /* map addr must be exactly as requested */
+#define MAP_INHERIT    0x0040  /* region is retained after exec */
+#define MAP_HASSEMAPHORE       0x0080  /* region may contain semaphores */
+.DE
+.PP
+The parameter \fIprot\fP specifies the accessibility
+of the mapped pages.
+The parameter \fIflags\fP specifies
+the type of object to be mapped,
+mapping options, and
+whether modifications made to
+this mapped copy of the page
+are to be kept \fIprivate\fP, or are to be \fIshared\fP with
+other references.
+Possible types include MAP_FILE,
+mapping a regular file or character-special device memory,
+and MAP_ANON, which maps memory not associated with any specific file.
+The file descriptor used for creating MAP_ANON regions is used only
+for naming, and may be given as \-1 if no name
+is associated with the region.\(dg
+.FS
+\(dg The current design does not allow a process
+to specify the location of swap space.
+In the future we may define an additional mapping type, MAP_SWAP,
+in which the file descriptor argument specifies a file
+or device to which swapping should be done.
+.FE
+The MAP_INHERIT flag allows a region to be inherited after an \fIexec\fP.
+The MAP_HASSEMAPHORE flag allows special handling for
+regions that may contain semaphores.
+.SH "SEE ALSO"
+msync.2, munmap.2, mprotect.2, madvise.2, mincore.2