.\" Hey Emacs! This file is -*- nroff -*- source. .\" .\" Copyright (C) 1996 Andries Brouwer (aeb@cwi.nl) .\" .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .\" Modified Fri Jan 31 16:38:25 1997 by Eric S. Raymond .\" Translation revised May 3 1998 by Juan Piernas .\" .TH MMAP 2 "12 Abril 1996" "Linux 1.3.86" "Manual del Programador de Linux" .SH NOMBRE mmap, munmap \- ubica o elimina ficheros o dispositivos en memoria .SH SINOPSIS .B #include .br .B #include .sp .BI "caddr_t mmap(void *" start ", size_t " length ", int " prot .BI ", int " flags ", int " fd ", off_t " offset ); .sp .BI "int munmap(void *" start ", size_t " length ); .SH DESCRIPCIÓN La función .B mmap intenta ubicar .I length bytes comenzando en el desplazamiento .I offset desde el fichero (u otro objeto) espeficicado por .I fd en memoria, preferiblemente en la dirección .IR start . Esta última dirección es una sugerencia y normalmente se especifica como 0. El lugar donde es ubicado el objeto es devuelto por .BR mmap . El argumento .I prot describe la protección de memoria deseada. Lo forman los siguientes bits: .TP 1.1i .B PROT_EXEC Las páginas deben ser ejecutadas. .TP .B PROT_READ Las páginas deben ser leídas. .TP .B PROT_WRITE Las páginas deben ser escritas. .TP .B PROT_NONE Las páginas no pueden ser accedidas. .LP El parámetro .I flags especifica el tipo de objeto insertado, las opciones de asociación y si las modificaciones hechas a la copia insertada en memoria son privadas al proceso o son compartidas por otras referencias. Tiene los bits: .TP 1.1i .B MAP_FIXED No seleccionar una dirección diferente a la especificada. Si la dirección especificada no puede ser utilizada, .B mmap fallará. Si MAP_FIXED es especificado, .I start debe ser un múltiplo del tamaño de página. Utilizar esta opción es desaconsejable. .TP .B MAP_SHARED Comparte este área con todos los otros objetos que señalan a este objeto. .TP .B MAP_PRIVATE Crear un área privada "copy-on-write". .LP Debe especificarse exactamente uno de los parámetros MAP_SHARED o MAP_PRIVATE. .LP Los tres parámetros anteriores están descritos en POSIX.1b (formalmente POSIX.4). Linux también reconoce MAP_DENYWRITE, MAP_EXECUTABLE y MAP_ANON(YMOUS). La llamada al sistema .B munmap borra las ubicaciones para el rango de direcciones especificado, y produce referencias a las direcciones dentro del rango a fin de generar referencias a memoria inválidas. .SH "VALOR DEVUELTO" Si ha funcionado .B mmap devuelve un puntero al área reservada. En caso de error, es devuelto \-1, y .I errno es modificado apropiadamente. Si ha funcionado .B munmap devuelve 0, si hay error \-1, y .I errno es fijada (probablemente a EINVAL). .SH ERRORES .TP .B EBADF .I fd no es un descriptor de fichero válido (y MAP_ANONYMOUS no ha sido fijado). .TP .B EACCES MAP_PRIVATE fue indicado, pero .I fd no ha sido abierto para lectura. O MAP_SHARED fue invocado y PROT_WRITE fue fijado, y .I fd no está abierto para escritura. .TP .B EINVAL No es correcto .I start o .I length o .IR offset . (E.g., son demasiado grandes, o no están alineados en los límites de un valor múltiplo de PAGESIZE). .TP .B ETXTBUSY MAP_DENYWRITE fue fijado pero el objeto especificado por .I fd está abierto para escritura. .TP .B EAGAIN El fichero ha sido bloqueado, o se ha bloqueado una cantidad excesiva de memoria. .TP .B ENOMEM No hay memoria disponible. .SH "CONFORME A" SVr4, POSIX.1b (formalmente POSIX.4), 4.4BSD. Svr4 documenta los códigos de error ENXIO y ENODEV. .SH "VÉASE TAMBIÉN" .BR getpagesize (2), .BR msync (2), .BR shm_open (2), B.O. Gallmeister, POSIX.4, O'Reilly, pp. 128-129 and 389-391.