File: mmap.2

package info (click to toggle)
manpages-ja 0.4.0.0.20020315-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 14,808 kB
  • ctags: 4
  • sloc: sh: 9,595; perl: 157; makefile: 62
file content (204 lines) | stat: -rw-r--r-- 6,100 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
.\" 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 <esr@thyrsus.com>
.\" Modified Sat Mar 25 08:11:16 2000 by Jim Van Zandt <jrv@vanzandt.mv.com>
.\"
.\" Japanese Version Copyright (c) 1997-2000 SUTO, Mitsuaki and NAKANO Takeo
.\"         all rights reserved.
.\" Translated Thu Jun 26 21:00:25 JST 1997
.\"         by SUTO, Mitsuaki <suto@av.crl.sony.co.jp>
.\" Updated & Modified Mon Mar 1 1999
.\"         by NAKANO Takeo <nakano@apm.seikei.ac.jp>
.\" Updated Thu Oct 12 2000 by Nakano Takeo
.\" Updated Thu Aug 16 2001 by Nakano Takeo
.\"
.\"WORD		file descriptor		ե뵭һ
.\"
.TH MMAP 2 "25 March 2000" "Linux 2.3.51" "Linux Programmer's Manual"
.SH ̾
mmap, munmap \- եǥХ˥ޥå/ޥåפ
.SH 
.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 
.B mmap
ؿϡե뵭һ (file descriptor)
.I fd
ǻꤵ줿ե(⤷Ϥ¾Υ֥)Ρեå
.I offset

.I length
ХȤϰϤ˥ޥåפ(ĥդ)
ΤȤʤ٤
.IR start
ɥ쥹Ϥ褦˥ޥåפ롣Υɥ쥹ϼºݤϴؿФ
ΥҥȤǤʤ̾ 0 ꤹ롣
ºݤ˥֥Ȥޥåפ줿ɥ쥹
.BR mmap
֤ͤ˥åȤ롣

.I prot
ˤϥݸɤΤ褦˹Ԥʤꤹ
(եΥץ⡼ɤȾͤʤ褦ˤʤФʤʤ)
ʲΤ褦ʥӥåȥǡ¸ߤ롣
.TP 1.1i
.B PROT_EXEC
ڡϼ¹ԲǽǤ롣
.TP
.B PROT_READ
ڡɤ߹߲ǽǤ롣
.TP
.B PROT_WRITE
ڡ˽񤭹߲ǽǤ롣
.TP
.B PROT_NONE
ڡˤϥǤʤ
.LP

.I flags
ˤϡޥåפ줿֥ȤΥסޥå׻ΥץȤȤˡ
ޥåפ줿ڡԡؤѹԤΤƤӽФץʤΤ
Ȥ⤽Υڡ򻲾Ȥ¾ΥץǽʤΤꤹ롣
ʲΤ褦ʥӥåȥǡ¸ߤ롣
.TP 1.1i
.B MAP_FIXED
ꤵ줿ɥ쥹ʳΥɥ쥹˥ޥåԥ󥰤Ԥʤʤ
⤷ꤵ줿ɥ쥹ѤǤʤ硢
.B mmap
ϼԤ롣 MAP_FIXED ꤷ
.I start
ϥڡܿǤʤƤϤʤ
ΥץϻѤʤɤ
.TP
.B MAP_SHARED
Υޥåԥ󥰤򡢤Υ֥Ȥޥåפ¾ƤΥץȶͭ롣
ΰؤ¸ϡեؤν񤭹ߤǤ롣
ե뤬ºݤ˹Τϡ
.BR msync (2)
ޤ
.BR munmap (2)
ƤФ줿ȤǤ롣
.TP
.B MAP_PRIVATE
ץ饤١Ȥ copy-on-write (񤭹߻ԡ) ޥåפ롣
ΰؤν񤭹ߤϡꥸʥΥե˱ƶʤ
.LP
MAP_SHARED  MAP_PRIVATE ϡɬɤ餫ҤȤĤ
ꤷʤФʤʤ
.LP
ʾ3ĤΥե饰 POSIX.1b ( POSIX.4) ǵꤵƤ롣
Linux ˤϤ¾ MAP_DENYWRITE, MAP_EXECUTABLE,
MAP_NORESERVE, MAP_LOCKED, MAP_GROWSDOWN and MAP_ANON(YMOUS)
.LP
.I offset
̾
.BR getpagesize (2)
֤ڡܤǤʤФʤʤ
.LP
.B mmap
ˤäƥޥåפ줿°
.BR fork (2)
¸롣

ƥॳ
.B munmap
ϻꤵ줿ɥ쥹ϰϤΥޥåפõ
ʹߤΤϰؤλȤ̵ʥ껲Ȥˤ롣
ΰϡץλȤˤ⼫ưŪ˥ޥåפ롣
ե뵭һҤ򥯥Ƥ⡢ΰϥޥåפʤ

.SH ֤
.B mmap
ȥޥåפ줿ΰؤΥݥ󥿤֤
Ԥ MAP_FAILED (\-1) ֤
.I errno
顼ƤˤäƥåȤ롣
.B munmap
 0 ֤Ԥ \-1 ֤
.I errno
åȤ (餯 EINVAL ˤʤ)
.SH 顼
.TP
.B EBADF
.I fd
ͭʥե뵭һ (file descriptor) ǤϤʤ
( MAP_ANONYMOUS åȤƤʤ)
.TP
.B EACCES
MAP_PRIVATE ׵ᤷ
.I fd
ɤ߹Ѥ˥ץ󤵤Ƥʤ
ޤ MAP_SHARED ׵ᤷ PROT_WRITE 򥻥åȤ
.I fd
ɤ߽񤭥⡼ (O_RDWR) ǥץ󤵤Ƥʤ
.TP
.B EINVAL
.I start

.I length

.IR offset 
դʤ
(Ĥޤ礭뤫 PAGESIZE ˥饤ȤƤʤ)
.TP
.B ETXTBSY
MAP_DENYWRITE åȤƤ뤬
.I fd
ǻꤵƤ륪֥ȤϽ񤭹Ѥ˳Ƥ롣
.TP
.B EAGAIN
ե뤬åƤ롣ޤϥåƤ꤬¿롣
.TP
.B ENOMEM
˶ʤ
.LP
ޥåΰѤ˺ݤʲΥʥ뤬ȯ뤳Ȥ:
.TP
.B SIGSEGV
ɤ߹Ѥ mmap 줿ΰؽ񤭹ߤԤȤ
.TP
.B SIGBUS
ХåեΤե˴ϢŤƤʤʬ˥ԤȤ
(㤨Хեۤʬʤɡ
¾Υץեڤͤ᤿ʤɤͤ)
.SH 
SVr4, POSIX.1b ( POSIX.4), 4.4BSDSVr4 ˤ¾ ENXIO  ENODEV 
Υ顼ɤˤĤƤεҤ롣
.SH Ϣ
.BR getpagesize (2),
.BR msync (2),
.BR shm_open (2),
B.O. Gallmeister, POSIX.4, O'Reilly, pp. 128-129 and 389-391.