File: mmap.2

package info (click to toggle)
manpages-fr 0.8-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 5,760 kB
  • ctags: 4
  • sloc: makefile: 57; sh: 8
file content (165 lines) | stat: -rw-r--r-- 4,828 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
.\" 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.
.\"
.\" Traduction 14/10/1996 par Christophe Blaess (ccb@club-internet.fr)
.\" Mise a Jour 08/04/1997
.\" Mise a Jour 19/07/1997
.\" Mise a Jour 02/10/1999
.TH MMAP 2 "2 Octobre 1999" "Linux" "Manuel du programmeur Linux"
.SH NOM
mmap, munmap \- Etablir / supprimer une projection en mmoire (map / unmap) des fichiers ou des priphriques.
.SH SYNOPSIS
.B #include <unistd.h>
.br
.B #include <sys/mman.h>
.sp
.B #ifdef _POSIX_MAPPED_FILES
.sp
.BI "void * 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 );
.sp
.B #endif
.SH DESCRIPTION

La fonction
.B mmap
demande la projection en mmoire de
.I length
octets commencant  la position
.I offset
depuis un fichier (ou un autre objet) indiqu par
.I fd,
de prfrence  l'adresse pointe par
.IR start.
Cette adresse n'est qu'une prfrence, gnralement 0.
La vritable adresse o l'objet est projet est renvoye par la
fonction
.BR mmap.

L'argument
.I prot
indique la protection que l'on dsire pour cette zone de mmoire.
Les protections possibles sont les suivantes :
.TP
.B PROT_EXEC
On peut excuter du code dans la zone mmoire.
.TP
.B PROT_READ
On peut lire le contenu de la zone mmoire
.TP
.B PROT_WRITE
On peut crire dans la zone mmoire.
.TP
.B PROT_NONE
Le contenu de la zone memoire est inaccessible.
.LP
Le paramtre
.I flags
indique le type de fichier projet, les options de projection, et si
les modifications faites sur la portion projete sont prives ou doivent
tre partages avec les autres rfrences. Les options sont :
.TP
.B MAP_FIXED
N'utiliser que l'adresse indique. Si c'est impossible,
.B mmap
chouera.  Si MAP_FIXED est spcifi
.I start
doit tre un multiple de la longueur de page. Il est dconseill d'utiliser
cette option.
.TP
.B MAP_SHARED
Partager la projection avec tout autre processus utilisant l'objet.
.TP
.B MAP_PRIVATE
Crer une projection prive, utilisant la mthode de copie  l'criture.
.LP
Vous devez indiquer soit MAP_SHARED, soit MAP_PRIVATE.

Ces trois attributs sont dcrits dans POSIX.1b (anciennement POSIX.4).
Linux propose
galement les options MAP_DENYWRITE, MAP_EXECUTABLE et MAP_ANON(YMOUS).

L'appel systme
.B munmap
dtruit la projection dans la zone de mmoire spcifie, et s'arrange pour
que toute rfrence ultrieure  cette zone mmoire dclenche une
erreur d'adressage.

.SH "VALEUR RENVOYE"
.B mmap
renvoie un pointeur sur la zone de mmoire, s'il russit. En
cas d'chec il retourne MAP_FAILED (\-1) et 
.I errno
contient le code d'erreur.

.B munmap
renvoie 0 s'il russit. En cas d'chec \-1 est renvoy et
.I errno
contient le code d'erreur (probablement EINVAL).
.SH ERREURS
.TP
.B EBADF
.I fd
n'est pas un descripteur de fichier valide (et MAP_ANONYMOUS n'tait pas prcis).
.TP
.B EACCES
On demande une projection prive MAP_PRIVATE mais
.I fd
n'est pas ouvert en lecture, ou on demande une projection
partage MAP_SHARED avec protection PROT_WRITE, mais
.I fd
n'est pas ouvert en ecriture.
.TP
.B EINVAL
.I start
ou
.I length
ou
.IR offset 
sont invalides.
(par exemple : zone trop grande, ou non aligne sur une frontire de page).
.TP
.B ETXTBUSY
MAP_DENYWRITE a t rclam mais
.I fd
est ouvert en criture
.TP
.B EAGAIN
Le fichier est verrouill, ou trop de mmoire est verrouille.
.TP
.B ENOMEM
pas assez de mmoire.
.SH "CONFORMIT"
SVr4, POSIX.1b (anciennement POSIX.4), BSD 4.4. SVr4 documente les codes
d'erreur supplmentaires ENXIO et ENODEV.
.SH "VOIR AUSSI"
.BR getpagesize (2),
.BR msync (2),
.BR shm_open (2),
B.O. Gallmeister, POSIX.4, O'Reilly, pp. 119-124 et 365-369.

.SH TRADUCTION
Christophe Blaess, 1997.