blob: 44e67e6eeb96796286c48a8db2c446951f730ff4 [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
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>
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00005 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
Roland McGrathe1e584b2003-06-02 19:18:58 +00006 * Copyright (c) 2000 PocketPenguins Inc. Linux for Hitachi SuperH
7 * port by Greg Banks <gbanks@pocketpenguins.com>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00008 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 * $Id$
33 */
34
35#include "defs.h"
36
Wichert Akkerman2e2553a1999-05-09 00:29:58 +000037#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000038#include <linux/mman.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000039#endif
Wichert Akkerman2e2553a1999-05-09 00:29:58 +000040#include <sys/mman.h>
Wichert Akkerman5daa0281999-03-15 19:49:42 +000041
Roland McGrath909875b2002-12-22 03:34:36 +000042#if defined(LINUX) && defined(I386)
Wichert Akkerman8bc6cfd1999-04-21 15:57:38 +000043#include <asm/ldt.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000044#endif
Roland McGrathe1e584b2003-06-02 19:18:58 +000045#if defined(LINUX) && defined(SHMEDIA)
46#include <asm/page.h> /* for PAGE_SHIFT */
47#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000048
John Hughes70623be2001-03-08 13:59:00 +000049#ifdef HAVE_LONG_LONG_OFF_T
50/*
51 * Ugly hacks for systems that have a long long off_t
52 */
53#define sys_mmap64 sys_mmap
54#endif
55
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000056int
57sys_brk(tcp)
58struct tcb *tcp;
59{
60 if (entering(tcp)) {
61 tprintf("%#lx", tcp->u_arg[0]);
62 }
Wichert Akkerman5daa0281999-03-15 19:49:42 +000063#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000064 return RVAL_HEX;
65#else
66 return 0;
67#endif
68}
69
70int
71sys_sbrk(tcp)
72struct tcb *tcp;
73{
74 if (entering(tcp)) {
75 tprintf("%lu", tcp->u_arg[0]);
76 }
77 return RVAL_HEX;
78}
79
80static struct xlat mmap_prot[] = {
81 { PROT_NONE, "PROT_NONE", },
82 { PROT_READ, "PROT_READ" },
83 { PROT_WRITE, "PROT_WRITE" },
84 { PROT_EXEC, "PROT_EXEC" },
85 { 0, NULL },
86};
87
88static struct xlat mmap_flags[] = {
89 { MAP_SHARED, "MAP_SHARED" },
90 { MAP_PRIVATE, "MAP_PRIVATE" },
91 { MAP_FIXED, "MAP_FIXED" },
92#ifdef MAP_ANONYMOUS
93 { MAP_ANONYMOUS,"MAP_ANONYMOUS" },
94#endif
95#ifdef MAP_RENAME
96 { MAP_RENAME, "MAP_RENAME" },
97#endif
98#ifdef MAP_NORESERVE
99 { MAP_NORESERVE,"MAP_NORESERVE" },
100#endif
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000101#ifdef MAP_POPULATE
102 { MAP_POPULATE, "MAP_POPULATE" },
103#endif
104#ifdef MAP_NONBLOCK
105 { MAP_NONBLOCK, "MAP_NONBLOCK" },
106#endif
Wichert Akkerman8829a551999-06-11 13:18:40 +0000107 /*
108 * XXX - this was introduced in SunOS 4.x to distinguish between
109 * the old pre-4.x "mmap()", which:
110 *
111 * only let you map devices with an "mmap" routine (e.g.,
112 * frame buffers) in;
113 *
114 * required you to specify the mapping address;
115 *
116 * returned 0 on success and -1 on failure;
117 *
118 * memory and which, and the 4.x "mmap()" which:
119 *
120 * can map plain files;
121 *
122 * can be asked to pick where to map the file;
123 *
124 * returns the address where it mapped the file on success
125 * and -1 on failure.
126 *
127 * It's not actually used in source code that calls "mmap()"; the
128 * "mmap()" routine adds it for you.
129 *
130 * It'd be nice to come up with some way of eliminating it from
131 * the flags, e.g. reporting calls *without* it as "old_mmap()"
132 * and calls with it as "mmap()".
133 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000134#ifdef _MAP_NEW
135 { _MAP_NEW, "_MAP_NEW" },
136#endif
137#ifdef MAP_GROWSDOWN
138 { MAP_GROWSDOWN,"MAP_GROWSDOWN" },
139#endif
140#ifdef MAP_DENYWRITE
141 { MAP_DENYWRITE,"MAP_DENYWRITE" },
142#endif
143#ifdef MAP_EXECUTABLE
144 { MAP_EXECUTABLE,"MAP_EXECUTABLE"},
145#endif
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000146#ifdef MAP_INHERIT
147 { MAP_INHERIT,"MAP_INHERIT" },
148#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000149#ifdef MAP_FILE
150 { MAP_FILE,"MAP_FILE"},
151#endif
152#ifdef MAP_LOCKED
153 { MAP_LOCKED,"MAP_LOCKED"},
154#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000155 /* FreeBSD ones */
156#ifdef MAP_ANON
157 { MAP_ANON, "MAP_ANON" },
158#endif
159#ifdef MAP_HASSEMAPHORE
160 { MAP_HASSEMAPHORE, "MAP_HASSEMAPHORE" },
161#endif
162#ifdef MAP_STACK
163 { MAP_STACK, "MAP_STACK" },
164#endif
165#ifdef MAP_NOSYNC
166 { MAP_NOSYNC, "MAP_NOSYNC" },
167#endif
168#ifdef MAP_NOCORE
169 { MAP_NOCORE, "MAP_NOCORE" },
170#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000171 { 0, NULL },
172};
173
John Hughes70623be2001-03-08 13:59:00 +0000174#if !HAVE_LONG_LONG_OFF_T
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000175static
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000176int
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000177print_mmap(tcp,u_arg)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000178struct tcb *tcp;
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000179long *u_arg;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000180{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000181 if (entering(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000182 /* addr */
Wichert Akkerman8829a551999-06-11 13:18:40 +0000183 if (!u_arg[0])
184 tprintf("NULL, ");
185 else
186 tprintf("%#lx, ", u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000187 /* len */
188 tprintf("%lu, ", u_arg[1]);
189 /* prot */
190 printflags(mmap_prot, u_arg[2]);
191 tprintf(", ");
192 /* flags */
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000193#ifdef MAP_TYPE
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000194 printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???");
195 addflags(mmap_flags, u_arg[3] & ~MAP_TYPE);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000196#else
197 printflags(mmap_flags, u_arg[3]);
198#endif
Michal Ludvig0e035502002-09-23 15:41:01 +0000199 /* fd (is always int, not long) */
200 tprintf(", %d, ", (int)u_arg[4]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000201 /* offset */
202 tprintf("%#lx", u_arg[5]);
203 }
204 return RVAL_HEX;
205}
206
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000207#ifdef LINUX
208int sys_old_mmap(tcp)
209struct tcb *tcp;
210{
211 long u_arg[6];
212
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000213#if defined(IA64)
Wichert Akkerman12f75d12000-02-14 16:23:40 +0000214 int i, v;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000215 /*
216 * IA64 processes never call this routine, they only use the
217 * new `sys_mmap' interface. This code converts the integer
218 * arguments that the IA32 process pushed onto the stack into
219 * longs.
220 *
221 * Note that addresses with bit 31 set will be sign extended.
222 * Fortunately, those addresses are not currently being generated
223 * for IA32 processes so it's not a problem.
224 */
225 for (i = 0; i < 6; i++)
226 if (umove(tcp, tcp->u_arg[0] + (i * sizeof(int)), &v) == -1)
227 return 0;
228 else
229 u_arg[i] = v;
Roland McGrathe1e584b2003-06-02 19:18:58 +0000230#elif defined(SH) || defined(SHMEDIA)
Roland McGrath6b1d43e2003-03-31 01:05:01 +0000231 /* SH has always passed the args in registers */
232 int i;
233 for (i=0; i<6; i++)
234 u_arg[i] = tcp->u_arg[i];
235#else
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000236 if (umoven(tcp, tcp->u_arg[0], sizeof u_arg, (char *) u_arg) == -1)
237 return 0;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000238#endif // defined(IA64)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000239 return print_mmap(tcp, u_arg);
Roland McGrath909875b2002-12-22 03:34:36 +0000240
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000241}
242#endif
243
244int
245sys_mmap(tcp)
246struct tcb *tcp;
247{
Roland McGrathe1e584b2003-06-02 19:18:58 +0000248#if defined(LINUX) && defined(SHMEDIA)
249 /*
250 * Old mmap differs from new mmap in specifying the
251 * offset in units of bytes rather than pages. We
252 * pretend it's in byte units so the user only ever
253 * sees bytes in the printout.
254 */
255 tcp->u_arg[5] <<= PAGE_SHIFT;
256#endif
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000257 return print_mmap(tcp, tcp->u_arg);
258}
John Hughes70623be2001-03-08 13:59:00 +0000259#endif /* !HAVE_LONG_LONG_OFF_T */
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000260
John Hughes70623be2001-03-08 13:59:00 +0000261#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
John Hughesbdf48f52001-03-06 15:08:09 +0000262int
263sys_mmap64(tcp)
264struct tcb *tcp;
265{
266#ifdef linux
267#ifdef ALPHA
268 long *u_arg = tcp->u_arg;
269#else /* !ALPHA */
270 long u_arg[7];
271#endif /* !ALPHA */
272#else /* !linux */
273 long *u_arg = tcp->u_arg;
274#endif /* !linux */
275
276 if (entering(tcp)) {
277#ifdef linux
278#ifndef ALPHA
279 if (umoven(tcp, tcp->u_arg[0], sizeof u_arg,
280 (char *) u_arg) == -1)
281 return 0;
282#endif /* ALPHA */
283#endif /* linux */
John Hughes5a826b82001-03-07 13:21:24 +0000284 ALIGN64 (tcp, 5); /* FreeBSD wierdies */
John Hughesbdf48f52001-03-06 15:08:09 +0000285
286 /* addr */
287 tprintf("%#lx, ", u_arg[0]);
288 /* len */
289 tprintf("%lu, ", u_arg[1]);
290 /* prot */
291 printflags(mmap_prot, u_arg[2]);
292 tprintf(", ");
293 /* flags */
John Hughes5a826b82001-03-07 13:21:24 +0000294#ifdef MAP_TYPE
John Hughesbdf48f52001-03-06 15:08:09 +0000295 printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???");
296 addflags(mmap_flags, u_arg[3] & ~MAP_TYPE);
John Hughes5a826b82001-03-07 13:21:24 +0000297#else
298 printflags(mmap_flags, u_arg[3]);
299#endif
John Hughesbdf48f52001-03-06 15:08:09 +0000300 /* fd */
301 tprintf(", %ld, ", u_arg[4]);
302 /* offset */
John Hughes0c79e012001-03-08 14:40:06 +0000303 tprintf("%#llx", LONG_LONG(u_arg[5], u_arg[6]));
John Hughesbdf48f52001-03-06 15:08:09 +0000304 }
305 return RVAL_HEX;
306}
307#endif
308
Roland McGrath909875b2002-12-22 03:34:36 +0000309
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000310int
311sys_munmap(tcp)
312struct tcb *tcp;
313{
314 if (entering(tcp)) {
315 tprintf("%#lx, %lu",
316 tcp->u_arg[0], tcp->u_arg[1]);
317 }
318 return 0;
319}
320
321int
322sys_mprotect(tcp)
323struct tcb *tcp;
324{
325 if (entering(tcp)) {
326 tprintf("%#lx, %lu, ",
327 tcp->u_arg[0], tcp->u_arg[1]);
328 if (!printflags(mmap_prot, tcp->u_arg[2]))
329 tprintf("PROT_???");
330 }
331 return 0;
332}
333
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000334#ifdef LINUX
335
336static struct xlat mremap_flags[] = {
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000337 { MREMAP_MAYMOVE, "MREMAP_MAYMOVE" },
338 { 0, NULL }
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000339};
340
341int
342sys_mremap(tcp)
343struct tcb *tcp;
344{
345 if (entering(tcp)) {
346 tprintf("%#lx, %lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1],
347 tcp->u_arg[2]);
348 printflags(mremap_flags, tcp->u_arg[3]);
349 }
350 return RVAL_HEX;
351}
352
Wichert Akkermanc7926982000-04-10 22:22:31 +0000353static struct xlat madvise_flags[] = {
354#ifdef MADV_NORMAL
355 { MADV_NORMAL, "MADV_NORMAL" },
356#endif
357#ifdef MADZV_RANDOM
358 { MADV_RANDOM, "MADV_RANDOM" },
359#endif
360#ifdef MADV_SEQUENTIAL
361 { MADV_SEQUENTIAL, "MADV_SEQUENTIAL" },
362#endif
363#ifdef MADV_WILLNEED
364 { MADV_WILLNEED, "MADV_WILLNEED" },
365#endif
366#ifdef MADV_DONTNED
367 { MADV_DONTNEED, "MADV_DONTNEED" },
368#endif
369 { 0, NULL },
370};
371
372
373int
374sys_madvise(tcp)
375struct tcb *tcp;
376{
377 if (entering(tcp)) {
378 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
379 printflags(madvise_flags, tcp->u_arg[2]);
380 }
381 return 0;
382}
383
384
385static struct xlat mlockall_flags[] = {
386#ifdef MCL_CURRENT
387 { MCL_CURRENT, "MCL_CURRENT" },
388#endif
389#ifdef MCL_FUTURE
390 { MCL_FUTURE, "MCL_FUTURE" },
391#endif
392 { 0, NULL}
393};
394
395int
396sys_mlockall(tcp)
397struct tcb *tcp;
398{
399 if (entering(tcp)) {
400 printflags(mlockall_flags, tcp->u_arg[0]);
401 }
402 return 0;
403}
404
405
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000406#endif /* LINUX */
407
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000408#ifdef MS_ASYNC
409
410static struct xlat mctl_sync[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000411#ifdef MS_SYNC
412 { MS_SYNC, "MS_SYNC" },
413#endif
John Hughesaca07f32001-10-16 18:12:27 +0000414 { MS_ASYNC, "MS_ASYNC" },
415 { MS_INVALIDATE,"MS_INVALIDATE" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000416 { 0, NULL },
417};
418
419int
420sys_msync(tcp)
421struct tcb *tcp;
422{
423 if (entering(tcp)) {
424 /* addr */
425 tprintf("%#lx", tcp->u_arg[0]);
426 /* len */
427 tprintf(", %lu, ", tcp->u_arg[1]);
428 /* flags */
429 if (!printflags(mctl_sync, tcp->u_arg[2]))
430 tprintf("MS_???");
431 }
432 return 0;
433}
434
435#endif /* MS_ASYNC */
436
437#ifdef MC_SYNC
438
439static struct xlat mctl_funcs[] = {
440 { MC_LOCK, "MC_LOCK" },
441 { MC_LOCKAS, "MC_LOCKAS" },
442 { MC_SYNC, "MC_SYNC" },
443 { MC_UNLOCK, "MC_UNLOCK" },
444 { MC_UNLOCKAS, "MC_UNLOCKAS" },
445 { 0, NULL },
446};
447
448static struct xlat mctl_lockas[] = {
449 { MCL_CURRENT, "MCL_CURRENT" },
450 { MCL_FUTURE, "MCL_FUTURE" },
451 { 0, NULL },
452};
453
454int
455sys_mctl(tcp)
456struct tcb *tcp;
457{
458 int arg, function;
459
460 if (entering(tcp)) {
461 /* addr */
462 tprintf("%#lx", tcp->u_arg[0]);
463 /* len */
464 tprintf(", %lu, ", tcp->u_arg[1]);
465 /* function */
466 function = tcp->u_arg[2];
467 if (!printflags(mctl_funcs, function))
468 tprintf("MC_???");
469 /* arg */
470 arg = tcp->u_arg[3];
471 tprintf(", ");
472 switch (function) {
473 case MC_SYNC:
474 if (!printflags(mctl_sync, arg))
475 tprintf("MS_???");
476 break;
477 case MC_LOCKAS:
478 if (!printflags(mctl_lockas, arg))
479 tprintf("MCL_???");
480 break;
481 default:
482 tprintf("%#x", arg);
483 break;
484 }
485 }
486 return 0;
487}
488
489#endif /* MC_SYNC */
490
491int
492sys_mincore(tcp)
493struct tcb *tcp;
494{
495 int i, len;
496 char *vec = NULL;
497
498 if (entering(tcp)) {
499 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
500 } else {
501 len = tcp->u_arg[1];
502 if (syserror(tcp) || tcp->u_arg[2] == 0 ||
503 (vec = malloc((u_int)len)) == NULL ||
504 umoven(tcp, tcp->u_arg[2], len, vec) < 0)
505 tprintf("%#lx", tcp->u_arg[2]);
506 else {
507 tprintf("[");
508 for (i = 0; i < len; i++) {
509 if (abbrev(tcp) && i >= max_strlen) {
510 tprintf("...");
511 break;
512 }
513 tprintf((vec[i] & 1) ? "1" : "0");
514 }
515 tprintf("]");
516 }
517 if (vec)
518 free(vec);
519 }
520 return 0;
521}
522
523int
524sys_getpagesize(tcp)
525struct tcb *tcp;
526{
527 if (exiting(tcp))
528 return RVAL_HEX;
529 return 0;
530}
531
532#if defined(LINUX) && defined(__i386__)
Roland McGrath909875b2002-12-22 03:34:36 +0000533void
Roland McGrath34e4a692002-12-15 23:58:17 +0000534print_ldt_entry (ldt_entry)
535struct modify_ldt_ldt_s *ldt_entry;
536{
537 tprintf("base_addr:%#08lx, "
538 "limit:%d, "
539 "seg_32bit:%d, "
540 "contents:%d, "
541 "read_exec_only:%d, "
542 "limit_in_pages:%d, "
543 "seg_not_present:%d, "
544 "useable:%d}",
545 ldt_entry->base_addr,
546 ldt_entry->limit,
547 ldt_entry->seg_32bit,
548 ldt_entry->contents,
549 ldt_entry->read_exec_only,
550 ldt_entry->limit_in_pages,
551 ldt_entry->seg_not_present,
552 ldt_entry->useable);
553}
554
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000555int
556sys_modify_ldt(tcp)
557struct tcb *tcp;
558{
559 if (entering(tcp)) {
560 struct modify_ldt_ldt_s copy;
561 tprintf("%ld", tcp->u_arg[0]);
562 if (tcp->u_arg[1] == 0
563 || tcp->u_arg[2] != sizeof (struct modify_ldt_ldt_s)
564 || umove(tcp, tcp->u_arg[1], &copy) == -1)
565 tprintf(", %lx", tcp->u_arg[1]);
566 else {
567 tprintf(", {entry_number:%d, ", copy.entry_number);
568 if (!verbose(tcp))
569 tprintf("...}");
570 else {
Roland McGrath34e4a692002-12-15 23:58:17 +0000571 print_ldt_entry(&copy);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000572 }
573 }
574 tprintf(", %lu", tcp->u_arg[2]);
575 }
576 return 0;
577}
Roland McGrath34e4a692002-12-15 23:58:17 +0000578
579int
580sys_set_thread_area(tcp)
581struct tcb *tcp;
582{
583 struct modify_ldt_ldt_s copy;
584 if (entering(tcp)) {
585 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
586 if (copy.entry_number == -1)
587 tprintf("{entry_number:%d -> ",
588 copy.entry_number);
589 else
590 tprintf("{entry_number:");
591 }
592 } else {
593 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
594 tprintf("%d, ", copy.entry_number);
595 if (!verbose(tcp))
596 tprintf("...}");
597 else {
598 print_ldt_entry(&copy);
599 }
600 } else {
601 tprintf("%lx", tcp->u_arg[0]);
602 }
603 }
604 return 0;
Roland McGrath909875b2002-12-22 03:34:36 +0000605
Roland McGrath34e4a692002-12-15 23:58:17 +0000606}
607
608int
609sys_get_thread_area(tcp)
610struct tcb *tcp;
611{
612 struct modify_ldt_ldt_s copy;
613 if (exiting(tcp)) {
614 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
615 tprintf("{entry_number:%d, ", copy.entry_number);
616 if (!verbose(tcp))
617 tprintf("...}");
618 else {
619 print_ldt_entry(&copy);
620 }
621 } else {
622 tprintf("%lx", tcp->u_arg[0]);
623 }
624 }
625 return 0;
Roland McGrath909875b2002-12-22 03:34:36 +0000626
Roland McGrath34e4a692002-12-15 23:58:17 +0000627}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000628#endif /* LINUX && __i386__ */
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000629
630#if defined(LINUX)
631int
632sys_remap_file_pages(tcp)
633struct tcb *tcp;
634{
635 if (entering(tcp)) {
636 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
637 printflags(mmap_prot, tcp->u_arg[2]);
638 tprintf(", %lu, ", tcp->u_arg[3]);
639#ifdef MAP_TYPE
640 printxval(mmap_flags, tcp->u_arg[4] & MAP_TYPE, "MAP_???");
641 addflags(mmap_flags, tcp->u_arg[4] & ~MAP_TYPE);
642#else
643 printflags(mmap_flags, tcp->u_arg[4]);
644#endif
645 }
646 return 0;
647}
648#endif