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 { MAP_POPULATE, "MAP_POPULATE" },
100 { MAP_NONBLOCK, "MAP_NONBLOCK" },
103 * XXX - this was introduced in SunOS 4.x to distinguish between
104 * the old pre-4.x "mmap()", which:
106 * only let you map devices with an "mmap" routine (e.g.,
109 * required you to specify the mapping address;
111 * returned 0 on success and -1 on failure;
113 * memory and which, and the 4.x "mmap()" which:
115 * can map plain files;
117 * can be asked to pick where to map the file;
119 * returns the address where it mapped the file on success
122 * It's not actually used in source code that calls "mmap()"; the
123 * "mmap()" routine adds it for you.
125 * It'd be nice to come up with some way of eliminating it from
126 * the flags, e.g. reporting calls *without* it as "old_mmap()"
127 * and calls with it as "mmap()".
130 { _MAP_NEW, "_MAP_NEW" },
133 { MAP_GROWSDOWN,"MAP_GROWSDOWN" },
136 { MAP_DENYWRITE,"MAP_DENYWRITE" },
138 #ifdef MAP_EXECUTABLE
139 { MAP_EXECUTABLE,"MAP_EXECUTABLE"},
142 { MAP_INHERIT,"MAP_INHERIT" },
145 { MAP_FILE,"MAP_FILE"},
148 { MAP_LOCKED,"MAP_LOCKED"},
152 { MAP_ANON, "MAP_ANON" },
154 #ifdef MAP_HASSEMAPHORE
155 { MAP_HASSEMAPHORE, "MAP_HASSEMAPHORE" },
158 { MAP_STACK, "MAP_STACK" },
161 { MAP_NOSYNC, "MAP_NOSYNC" },
164 { MAP_NOCORE, "MAP_NOCORE" },
169 #if !HAVE_LONG_LONG_OFF_T
172 print_mmap(tcp,u_arg)
181 tprintf("%#lx, ", u_arg[0]);
183 tprintf("%lu, ", u_arg[1]);
185 printflags(mmap_prot, u_arg[2]);
189 printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???");
190 addflags(mmap_flags, u_arg[3] & ~MAP_TYPE);
192 printflags(mmap_flags, u_arg[3]);
194 /* fd (is always int, not long) */
195 tprintf(", %d, ", (int)u_arg[4]);
197 tprintf("%#lx", u_arg[5]);
203 int sys_old_mmap(tcp)
211 * IA64 processes never call this routine, they only use the
212 * new `sys_mmap' interface. This code converts the integer
213 * arguments that the IA32 process pushed onto the stack into
216 * Note that addresses with bit 31 set will be sign extended.
217 * Fortunately, those addresses are not currently being generated
218 * for IA32 processes so it's not a problem.
220 for (i = 0; i < 6; i++)
221 if (umove(tcp, tcp->u_arg[0] + (i * sizeof(int)), &v) == -1)
225 #else // defined(IA64)
226 if (umoven(tcp, tcp->u_arg[0], sizeof u_arg, (char *) u_arg) == -1)
228 #endif // defined(IA64)
229 return print_mmap(tcp, u_arg);
238 return print_mmap(tcp, tcp->u_arg);
240 #endif /* !HAVE_LONG_LONG_OFF_T */
242 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
249 long *u_arg = tcp->u_arg;
254 long *u_arg = tcp->u_arg;
260 if (umoven(tcp, tcp->u_arg[0], sizeof u_arg,
261 (char *) u_arg) == -1)
265 ALIGN64 (tcp, 5); /* FreeBSD wierdies */
268 tprintf("%#lx, ", u_arg[0]);
270 tprintf("%lu, ", u_arg[1]);
272 printflags(mmap_prot, u_arg[2]);
276 printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???");
277 addflags(mmap_flags, u_arg[3] & ~MAP_TYPE);
279 printflags(mmap_flags, u_arg[3]);
282 tprintf(", %ld, ", u_arg[4]);
284 tprintf("%#llx", LONG_LONG(u_arg[5], u_arg[6]));
297 tcp->u_arg[0], tcp->u_arg[1]);
307 tprintf("%#lx, %lu, ",
308 tcp->u_arg[0], tcp->u_arg[1]);
309 if (!printflags(mmap_prot, tcp->u_arg[2]))
317 static struct xlat mremap_flags[] = {
318 { MREMAP_MAYMOVE, "MREMAP_MAYMOVE" },
327 tprintf("%#lx, %lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1],
329 printflags(mremap_flags, tcp->u_arg[3]);
334 static struct xlat madvise_flags[] = {
336 { MADV_NORMAL, "MADV_NORMAL" },
339 { MADV_RANDOM, "MADV_RANDOM" },
341 #ifdef MADV_SEQUENTIAL
342 { MADV_SEQUENTIAL, "MADV_SEQUENTIAL" },
345 { MADV_WILLNEED, "MADV_WILLNEED" },
348 { MADV_DONTNEED, "MADV_DONTNEED" },
359 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
360 printflags(madvise_flags, tcp->u_arg[2]);
366 static struct xlat mlockall_flags[] = {
368 { MCL_CURRENT, "MCL_CURRENT" },
371 { MCL_FUTURE, "MCL_FUTURE" },
381 printflags(mlockall_flags, tcp->u_arg[0]);
391 static struct xlat mctl_sync[] = {
393 { MS_SYNC, "MS_SYNC" },
395 { MS_ASYNC, "MS_ASYNC" },
396 { MS_INVALIDATE,"MS_INVALIDATE" },
406 tprintf("%#lx", tcp->u_arg[0]);
408 tprintf(", %lu, ", tcp->u_arg[1]);
410 if (!printflags(mctl_sync, tcp->u_arg[2]))
416 #endif /* MS_ASYNC */
420 static struct xlat mctl_funcs[] = {
421 { MC_LOCK, "MC_LOCK" },
422 { MC_LOCKAS, "MC_LOCKAS" },
423 { MC_SYNC, "MC_SYNC" },
424 { MC_UNLOCK, "MC_UNLOCK" },
425 { MC_UNLOCKAS, "MC_UNLOCKAS" },
429 static struct xlat mctl_lockas[] = {
430 { MCL_CURRENT, "MCL_CURRENT" },
431 { MCL_FUTURE, "MCL_FUTURE" },
443 tprintf("%#lx", tcp->u_arg[0]);
445 tprintf(", %lu, ", tcp->u_arg[1]);
447 function = tcp->u_arg[2];
448 if (!printflags(mctl_funcs, function))
455 if (!printflags(mctl_sync, arg))
459 if (!printflags(mctl_lockas, arg))
480 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
483 if (syserror(tcp) || tcp->u_arg[2] == 0 ||
484 (vec = malloc((u_int)len)) == NULL ||
485 umoven(tcp, tcp->u_arg[2], len, vec) < 0)
486 tprintf("%#lx", tcp->u_arg[2]);
489 for (i = 0; i < len; i++) {
490 if (abbrev(tcp) && i >= max_strlen) {
494 tprintf((vec[i] & 1) ? "1" : "0");
513 #if defined(LINUX) && defined(__i386__)
515 print_ldt_entry (ldt_entry)
516 struct modify_ldt_ldt_s *ldt_entry;
518 tprintf("base_addr:%#08lx, "
522 "read_exec_only:%d, "
523 "limit_in_pages:%d, "
524 "seg_not_present:%d, "
526 ldt_entry->base_addr,
528 ldt_entry->seg_32bit,
530 ldt_entry->read_exec_only,
531 ldt_entry->limit_in_pages,
532 ldt_entry->seg_not_present,
541 struct modify_ldt_ldt_s copy;
542 tprintf("%ld", tcp->u_arg[0]);
543 if (tcp->u_arg[1] == 0
544 || tcp->u_arg[2] != sizeof (struct modify_ldt_ldt_s)
545 || umove(tcp, tcp->u_arg[1], ©) == -1)
546 tprintf(", %lx", tcp->u_arg[1]);
548 tprintf(", {entry_number:%d, ", copy.entry_number);
552 print_ldt_entry(©);
555 tprintf(", %lu", tcp->u_arg[2]);
561 sys_set_thread_area(tcp)
564 struct modify_ldt_ldt_s copy;
566 if (umove(tcp, tcp->u_arg[0], ©) != -1) {
567 if (copy.entry_number == -1)
568 tprintf("{entry_number:%d -> ",
571 tprintf("{entry_number:");
574 if (umove(tcp, tcp->u_arg[0], ©) != -1) {
575 tprintf("%d, ", copy.entry_number);
579 print_ldt_entry(©);
582 tprintf("%lx", tcp->u_arg[0]);
590 sys_get_thread_area(tcp)
593 struct modify_ldt_ldt_s copy;
595 if (umove(tcp, tcp->u_arg[0], ©) != -1) {
596 tprintf("{entry_number:%d, ", copy.entry_number);
600 print_ldt_entry(©);
603 tprintf("%lx", tcp->u_arg[0]);
609 #endif /* LINUX && __i386__ */
613 sys_remap_file_pages(tcp)
617 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
618 printflags(mmap_prot, tcp->u_arg[2]);
619 tprintf(", %lu, ", tcp->u_arg[3]);
621 printxval(mmap_flags, tcp->u_arg[4] & MAP_TYPE, "MAP_???");
622 addflags(mmap_flags, tcp->u_arg[4] & ~MAP_TYPE);
624 printflags(mmap_flags, tcp->u_arg[4]);