2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
5 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 #include <linux/mman.h>
40 #if defined(LINUX) && defined(__i386__)
49 tprintf("%#lx", tcp->u_arg[0]);
63 tprintf("%lu", tcp->u_arg[0]);
68 static struct xlat mmap_prot[] = {
69 { PROT_NONE, "PROT_NONE", },
70 { PROT_READ, "PROT_READ" },
71 { PROT_WRITE, "PROT_WRITE" },
72 { PROT_EXEC, "PROT_EXEC" },
76 static struct xlat mmap_flags[] = {
77 { MAP_SHARED, "MAP_SHARED" },
78 { MAP_PRIVATE, "MAP_PRIVATE" },
79 { MAP_FIXED, "MAP_FIXED" },
81 { MAP_ANONYMOUS,"MAP_ANONYMOUS" },
84 { MAP_RENAME, "MAP_RENAME" },
87 { MAP_NORESERVE,"MAP_NORESERVE" },
90 * XXX - this was introduced in SunOS 4.x to distinguish between
91 * the old pre-4.x "mmap()", which:
93 * only let you map devices with an "mmap" routine (e.g.,
96 * required you to specify the mapping address;
98 * returned 0 on success and -1 on failure;
100 * memory and which, and the 4.x "mmap()" which:
102 * can map plain files;
104 * can be asked to pick where to map the file;
106 * returns the address where it mapped the file on success
109 * It's not actually used in source code that calls "mmap()"; the
110 * "mmap()" routine adds it for you.
112 * It'd be nice to come up with some way of eliminating it from
113 * the flags, e.g. reporting calls *without* it as "old_mmap()"
114 * and calls with it as "mmap()".
117 { _MAP_NEW, "_MAP_NEW" },
120 { MAP_GROWSDOWN,"MAP_GROWSDOWN" },
123 { MAP_DENYWRITE,"MAP_DENYWRITE" },
125 #ifdef MAP_EXECUTABLE
126 { MAP_EXECUTABLE,"MAP_EXECUTABLE"},
129 { MAP_INHERIT,"MAP_INHERIT" },
132 { MAP_FILE,"MAP_FILE"},
135 { MAP_LOCKED,"MAP_LOCKED"},
142 print_mmap(tcp,u_arg)
151 tprintf("%#lx, ", u_arg[0]);
153 tprintf("%lu, ", u_arg[1]);
155 printflags(mmap_prot, u_arg[2]);
158 printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???");
159 addflags(mmap_flags, u_arg[3] & ~MAP_TYPE);
161 tprintf(", %ld, ", u_arg[4]);
163 tprintf("%#lx", u_arg[5]);
169 int sys_old_mmap(tcp)
174 if (umoven(tcp, tcp->u_arg[0], sizeof u_arg, (char *) u_arg) == -1)
176 return print_mmap(tcp, u_arg);
185 return print_mmap(tcp, tcp->u_arg);
194 tcp->u_arg[0], tcp->u_arg[1]);
204 tprintf("%#lx, %lu, ",
205 tcp->u_arg[0], tcp->u_arg[1]);
206 if (!printflags(mmap_prot, tcp->u_arg[2]))
214 static struct xlat mremap_flags[] = {
215 { MREMAP_MAYMOVE, "MREMAP_MAYMOVE" },
223 tprintf("%#lx, %lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1],
225 printflags(mremap_flags, tcp->u_arg[3]);
234 static struct xlat mctl_sync[] = {
235 { MS_ASYNC, "MS_ASYNC" },
236 { MS_INVALIDATE,"MS_INVALIDATE" },
238 { MS_SYNC, "MS_SYNC" },
249 tprintf("%#lx", tcp->u_arg[0]);
251 tprintf(", %lu, ", tcp->u_arg[1]);
253 if (!printflags(mctl_sync, tcp->u_arg[2]))
259 #endif /* MS_ASYNC */
263 static struct xlat mctl_funcs[] = {
264 { MC_LOCK, "MC_LOCK" },
265 { MC_LOCKAS, "MC_LOCKAS" },
266 { MC_SYNC, "MC_SYNC" },
267 { MC_UNLOCK, "MC_UNLOCK" },
268 { MC_UNLOCKAS, "MC_UNLOCKAS" },
272 static struct xlat mctl_lockas[] = {
273 { MCL_CURRENT, "MCL_CURRENT" },
274 { MCL_FUTURE, "MCL_FUTURE" },
286 tprintf("%#lx", tcp->u_arg[0]);
288 tprintf(", %lu, ", tcp->u_arg[1]);
290 function = tcp->u_arg[2];
291 if (!printflags(mctl_funcs, function))
298 if (!printflags(mctl_sync, arg))
302 if (!printflags(mctl_lockas, arg))
323 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
326 if (syserror(tcp) || tcp->u_arg[2] == 0 ||
327 (vec = malloc((u_int)len)) == NULL ||
328 umoven(tcp, tcp->u_arg[2], len, vec) < 0)
329 tprintf("%#lx", tcp->u_arg[2]);
332 for (i = 0; i < len; i++) {
333 if (abbrev(tcp) && i >= max_strlen) {
337 tprintf((vec[i] & 1) ? "1" : "0");
356 #if defined(LINUX) && defined(__i386__)
362 struct modify_ldt_ldt_s copy;
363 tprintf("%ld", tcp->u_arg[0]);
364 if (tcp->u_arg[1] == 0
365 || tcp->u_arg[2] != sizeof (struct modify_ldt_ldt_s)
366 || umove(tcp, tcp->u_arg[1], ©) == -1)
367 tprintf(", %lx", tcp->u_arg[1]);
369 tprintf(", {entry_number:%d, ", copy.entry_number);
373 tprintf("base_addr:%#08lx, "
377 "read_exec_only:%d, "
378 "limit_in_pages:%d, "
379 "seg_not_present:%d, "
387 copy.seg_not_present,
391 tprintf(", %lu", tcp->u_arg[2]);
395 #endif /* LINUX && __i386__ */