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__)
44 #ifdef HAVE_LONG_LONG_OFF_T
46 * Ugly hacks for systems that have a long long off_t
48 #define sys_mmap64 sys_mmap
56 tprintf("%#lx", tcp->u_arg[0]);
70 tprintf("%lu", tcp->u_arg[0]);
75 static struct xlat mmap_prot[] = {
76 { PROT_NONE, "PROT_NONE", },
77 { PROT_READ, "PROT_READ" },
78 { PROT_WRITE, "PROT_WRITE" },
79 { PROT_EXEC, "PROT_EXEC" },
83 static struct xlat mmap_flags[] = {
84 { MAP_SHARED, "MAP_SHARED" },
85 { MAP_PRIVATE, "MAP_PRIVATE" },
86 { MAP_FIXED, "MAP_FIXED" },
88 { MAP_ANONYMOUS,"MAP_ANONYMOUS" },
91 { MAP_RENAME, "MAP_RENAME" },
94 { MAP_NORESERVE,"MAP_NORESERVE" },
97 * XXX - this was introduced in SunOS 4.x to distinguish between
98 * the old pre-4.x "mmap()", which:
100 * only let you map devices with an "mmap" routine (e.g.,
103 * required you to specify the mapping address;
105 * returned 0 on success and -1 on failure;
107 * memory and which, and the 4.x "mmap()" which:
109 * can map plain files;
111 * can be asked to pick where to map the file;
113 * returns the address where it mapped the file on success
116 * It's not actually used in source code that calls "mmap()"; the
117 * "mmap()" routine adds it for you.
119 * It'd be nice to come up with some way of eliminating it from
120 * the flags, e.g. reporting calls *without* it as "old_mmap()"
121 * and calls with it as "mmap()".
124 { _MAP_NEW, "_MAP_NEW" },
127 { MAP_GROWSDOWN,"MAP_GROWSDOWN" },
130 { MAP_DENYWRITE,"MAP_DENYWRITE" },
132 #ifdef MAP_EXECUTABLE
133 { MAP_EXECUTABLE,"MAP_EXECUTABLE"},
136 { MAP_INHERIT,"MAP_INHERIT" },
139 { MAP_FILE,"MAP_FILE"},
142 { MAP_LOCKED,"MAP_LOCKED"},
146 { MAP_ANON, "MAP_ANON" },
148 #ifdef MAP_HASSEMAPHORE
149 { MAP_HASSEMAPHORE, "MAP_HASSEMAPHORE" },
152 { MAP_STACK, "MAP_STACK" },
155 { MAP_NOSYNC, "MAP_NOSYNC" },
158 { MAP_NOCORE, "MAP_NOCORE" },
163 #if !HAVE_LONG_LONG_OFF_T
166 print_mmap(tcp,u_arg)
175 tprintf("%#lx, ", u_arg[0]);
177 tprintf("%lu, ", u_arg[1]);
179 printflags(mmap_prot, u_arg[2]);
183 printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???");
184 addflags(mmap_flags, u_arg[3] & ~MAP_TYPE);
186 printflags(mmap_flags, u_arg[3]);
189 tprintf(", %ld, ", u_arg[4]);
191 tprintf("%#lx", u_arg[5]);
197 int sys_old_mmap(tcp)
205 * IA64 processes never call this routine, they only use the
206 * new `sys_mmap' interface. This code converts the integer
207 * arguments that the IA32 process pushed onto the stack into
210 * Note that addresses with bit 31 set will be sign extended.
211 * Fortunately, those addresses are not currently being generated
212 * for IA32 processes so it's not a problem.
214 for (i = 0; i < 6; i++)
215 if (umove(tcp, tcp->u_arg[0] + (i * sizeof(int)), &v) == -1)
219 #else // defined(IA64)
220 if (umoven(tcp, tcp->u_arg[0], sizeof u_arg, (char *) u_arg) == -1)
222 #endif // defined(IA64)
223 return print_mmap(tcp, u_arg);
232 return print_mmap(tcp, tcp->u_arg);
234 #endif /* !HAVE_LONG_LONG_OFF_T */
236 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
243 long *u_arg = tcp->u_arg;
248 long *u_arg = tcp->u_arg;
254 if (umoven(tcp, tcp->u_arg[0], sizeof u_arg,
255 (char *) u_arg) == -1)
259 ALIGN64 (tcp, 5); /* FreeBSD wierdies */
262 tprintf("%#lx, ", u_arg[0]);
264 tprintf("%lu, ", u_arg[1]);
266 printflags(mmap_prot, u_arg[2]);
270 printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???");
271 addflags(mmap_flags, u_arg[3] & ~MAP_TYPE);
273 printflags(mmap_flags, u_arg[3]);
276 tprintf(", %ld, ", u_arg[4]);
278 tprintf("%#llx", LONG_LONG(u_arg[5], u_arg[6]));
291 tcp->u_arg[0], tcp->u_arg[1]);
301 tprintf("%#lx, %lu, ",
302 tcp->u_arg[0], tcp->u_arg[1]);
303 if (!printflags(mmap_prot, tcp->u_arg[2]))
311 static struct xlat mremap_flags[] = {
312 { MREMAP_MAYMOVE, "MREMAP_MAYMOVE" },
321 tprintf("%#lx, %lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1],
323 printflags(mremap_flags, tcp->u_arg[3]);
328 static struct xlat madvise_flags[] = {
330 { MADV_NORMAL, "MADV_NORMAL" },
333 { MADV_RANDOM, "MADV_RANDOM" },
335 #ifdef MADV_SEQUENTIAL
336 { MADV_SEQUENTIAL, "MADV_SEQUENTIAL" },
339 { MADV_WILLNEED, "MADV_WILLNEED" },
342 { MADV_DONTNEED, "MADV_DONTNEED" },
353 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
354 printflags(madvise_flags, tcp->u_arg[2]);
360 static struct xlat mlockall_flags[] = {
362 { MCL_CURRENT, "MCL_CURRENT" },
365 { MCL_FUTURE, "MCL_FUTURE" },
375 printflags(mlockall_flags, tcp->u_arg[0]);
385 static struct xlat mctl_sync[] = {
387 { MS_SYNC, "MS_SYNC" },
389 { MS_ASYNC, "MS_ASYNC" },
390 { MS_INVALIDATE,"MS_INVALIDATE" },
400 tprintf("%#lx", tcp->u_arg[0]);
402 tprintf(", %lu, ", tcp->u_arg[1]);
404 if (!printflags(mctl_sync, tcp->u_arg[2]))
410 #endif /* MS_ASYNC */
414 static struct xlat mctl_funcs[] = {
415 { MC_LOCK, "MC_LOCK" },
416 { MC_LOCKAS, "MC_LOCKAS" },
417 { MC_SYNC, "MC_SYNC" },
418 { MC_UNLOCK, "MC_UNLOCK" },
419 { MC_UNLOCKAS, "MC_UNLOCKAS" },
423 static struct xlat mctl_lockas[] = {
424 { MCL_CURRENT, "MCL_CURRENT" },
425 { MCL_FUTURE, "MCL_FUTURE" },
437 tprintf("%#lx", tcp->u_arg[0]);
439 tprintf(", %lu, ", tcp->u_arg[1]);
441 function = tcp->u_arg[2];
442 if (!printflags(mctl_funcs, function))
449 if (!printflags(mctl_sync, arg))
453 if (!printflags(mctl_lockas, arg))
474 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
477 if (syserror(tcp) || tcp->u_arg[2] == 0 ||
478 (vec = malloc((u_int)len)) == NULL ||
479 umoven(tcp, tcp->u_arg[2], len, vec) < 0)
480 tprintf("%#lx", tcp->u_arg[2]);
483 for (i = 0; i < len; i++) {
484 if (abbrev(tcp) && i >= max_strlen) {
488 tprintf((vec[i] & 1) ? "1" : "0");
507 #if defined(LINUX) && defined(__i386__)
513 struct modify_ldt_ldt_s copy;
514 tprintf("%ld", tcp->u_arg[0]);
515 if (tcp->u_arg[1] == 0
516 || tcp->u_arg[2] != sizeof (struct modify_ldt_ldt_s)
517 || umove(tcp, tcp->u_arg[1], ©) == -1)
518 tprintf(", %lx", tcp->u_arg[1]);
520 tprintf(", {entry_number:%d, ", copy.entry_number);
524 tprintf("base_addr:%#08lx, "
528 "read_exec_only:%d, "
529 "limit_in_pages:%d, "
530 "seg_not_present:%d, "
538 copy.seg_not_present,
542 tprintf(", %lu", tcp->u_arg[2]);
546 #endif /* LINUX && __i386__ */