Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1 | /* |
| 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 Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 5 | * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl> |
Roland McGrath | e1e584b | 2003-06-02 19:18:58 +0000 | [diff] [blame] | 6 | * Copyright (c) 2000 PocketPenguins Inc. Linux for Hitachi SuperH |
| 7 | * port by Greg Banks <gbanks@pocketpenguins.com> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 8 | * 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 Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 37 | #ifdef LINUX |
Roland McGrath | 05cdd3c | 2004-03-02 06:16:59 +0000 | [diff] [blame] | 38 | #include <asm/mman.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 39 | #endif |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 40 | #include <sys/mman.h> |
Wichert Akkerman | 5daa028 | 1999-03-15 19:49:42 +0000 | [diff] [blame] | 41 | |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 42 | #if defined(LINUX) && defined(I386) |
Wichert Akkerman | 8bc6cfd | 1999-04-21 15:57:38 +0000 | [diff] [blame] | 43 | #include <asm/ldt.h> |
Roland McGrath | 7decfb2 | 2004-03-01 22:10:52 +0000 | [diff] [blame] | 44 | # ifdef HAVE_STRUCT_USER_DESC |
| 45 | # define modify_ldt_ldt_s user_desc |
| 46 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 47 | #endif |
Roland McGrath | f5a4777 | 2003-06-26 22:40:42 +0000 | [diff] [blame] | 48 | #if defined(LINUX) && defined(SH64) |
Roland McGrath | e1e584b | 2003-06-02 19:18:58 +0000 | [diff] [blame] | 49 | #include <asm/page.h> /* for PAGE_SHIFT */ |
| 50 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 51 | |
John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 52 | #ifdef HAVE_LONG_LONG_OFF_T |
| 53 | /* |
| 54 | * Ugly hacks for systems that have a long long off_t |
| 55 | */ |
| 56 | #define sys_mmap64 sys_mmap |
| 57 | #endif |
| 58 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 59 | int |
| 60 | sys_brk(tcp) |
| 61 | struct tcb *tcp; |
| 62 | { |
| 63 | if (entering(tcp)) { |
| 64 | tprintf("%#lx", tcp->u_arg[0]); |
| 65 | } |
Wichert Akkerman | 5daa028 | 1999-03-15 19:49:42 +0000 | [diff] [blame] | 66 | #ifdef LINUX |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 67 | return RVAL_HEX; |
| 68 | #else |
| 69 | return 0; |
| 70 | #endif |
| 71 | } |
| 72 | |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 73 | #if defined(FREEBSD) || defined(SUNOS4) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 74 | int |
| 75 | sys_sbrk(tcp) |
| 76 | struct tcb *tcp; |
| 77 | { |
| 78 | if (entering(tcp)) { |
| 79 | tprintf("%lu", tcp->u_arg[0]); |
| 80 | } |
| 81 | return RVAL_HEX; |
| 82 | } |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 83 | #endif /* FREEBSD || SUNOS4 */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 84 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 85 | static const struct xlat mmap_prot[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 86 | { PROT_NONE, "PROT_NONE", }, |
| 87 | { PROT_READ, "PROT_READ" }, |
| 88 | { PROT_WRITE, "PROT_WRITE" }, |
| 89 | { PROT_EXEC, "PROT_EXEC" }, |
Roland McGrath | 47eb0e2 | 2003-09-25 23:06:04 +0000 | [diff] [blame] | 90 | #ifdef PROT_SEM |
| 91 | { PROT_SEM, "PROT_SEM" }, |
| 92 | #endif |
| 93 | #ifdef PROT_GROWSDOWN |
| 94 | { PROT_GROWSDOWN,"PROT_GROWSDOWN"}, |
| 95 | #endif |
| 96 | #ifdef PROT_GROWSUP |
| 97 | { PROT_GROWSUP, "PROT_GROWSUP" }, |
| 98 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 99 | { 0, NULL }, |
| 100 | }; |
| 101 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 102 | static const struct xlat mmap_flags[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 103 | { MAP_SHARED, "MAP_SHARED" }, |
| 104 | { MAP_PRIVATE, "MAP_PRIVATE" }, |
| 105 | { MAP_FIXED, "MAP_FIXED" }, |
| 106 | #ifdef MAP_ANONYMOUS |
| 107 | { MAP_ANONYMOUS,"MAP_ANONYMOUS" }, |
| 108 | #endif |
Dmitry V. Levin | 71f1a13 | 2007-03-29 23:30:09 +0000 | [diff] [blame] | 109 | #ifdef MAP_32BIT |
| 110 | { MAP_32BIT, "MAP_32BIT" }, |
| 111 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 112 | #ifdef MAP_RENAME |
| 113 | { MAP_RENAME, "MAP_RENAME" }, |
| 114 | #endif |
| 115 | #ifdef MAP_NORESERVE |
| 116 | { MAP_NORESERVE,"MAP_NORESERVE" }, |
| 117 | #endif |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 118 | #ifdef MAP_POPULATE |
| 119 | { MAP_POPULATE, "MAP_POPULATE" }, |
| 120 | #endif |
| 121 | #ifdef MAP_NONBLOCK |
| 122 | { MAP_NONBLOCK, "MAP_NONBLOCK" }, |
| 123 | #endif |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 124 | /* |
| 125 | * XXX - this was introduced in SunOS 4.x to distinguish between |
| 126 | * the old pre-4.x "mmap()", which: |
| 127 | * |
| 128 | * only let you map devices with an "mmap" routine (e.g., |
| 129 | * frame buffers) in; |
| 130 | * |
| 131 | * required you to specify the mapping address; |
| 132 | * |
| 133 | * returned 0 on success and -1 on failure; |
| 134 | * |
| 135 | * memory and which, and the 4.x "mmap()" which: |
| 136 | * |
| 137 | * can map plain files; |
| 138 | * |
| 139 | * can be asked to pick where to map the file; |
| 140 | * |
| 141 | * returns the address where it mapped the file on success |
| 142 | * and -1 on failure. |
| 143 | * |
| 144 | * It's not actually used in source code that calls "mmap()"; the |
| 145 | * "mmap()" routine adds it for you. |
| 146 | * |
| 147 | * It'd be nice to come up with some way of eliminating it from |
| 148 | * the flags, e.g. reporting calls *without* it as "old_mmap()" |
| 149 | * and calls with it as "mmap()". |
| 150 | */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 151 | #ifdef _MAP_NEW |
| 152 | { _MAP_NEW, "_MAP_NEW" }, |
| 153 | #endif |
| 154 | #ifdef MAP_GROWSDOWN |
| 155 | { MAP_GROWSDOWN,"MAP_GROWSDOWN" }, |
| 156 | #endif |
| 157 | #ifdef MAP_DENYWRITE |
| 158 | { MAP_DENYWRITE,"MAP_DENYWRITE" }, |
| 159 | #endif |
| 160 | #ifdef MAP_EXECUTABLE |
| 161 | { MAP_EXECUTABLE,"MAP_EXECUTABLE"}, |
| 162 | #endif |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 163 | #ifdef MAP_INHERIT |
| 164 | { MAP_INHERIT,"MAP_INHERIT" }, |
| 165 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 166 | #ifdef MAP_FILE |
| 167 | { MAP_FILE,"MAP_FILE"}, |
| 168 | #endif |
| 169 | #ifdef MAP_LOCKED |
| 170 | { MAP_LOCKED,"MAP_LOCKED"}, |
| 171 | #endif |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 172 | /* FreeBSD ones */ |
| 173 | #ifdef MAP_ANON |
| 174 | { MAP_ANON, "MAP_ANON" }, |
| 175 | #endif |
| 176 | #ifdef MAP_HASSEMAPHORE |
| 177 | { MAP_HASSEMAPHORE, "MAP_HASSEMAPHORE" }, |
| 178 | #endif |
| 179 | #ifdef MAP_STACK |
| 180 | { MAP_STACK, "MAP_STACK" }, |
| 181 | #endif |
| 182 | #ifdef MAP_NOSYNC |
| 183 | { MAP_NOSYNC, "MAP_NOSYNC" }, |
| 184 | #endif |
| 185 | #ifdef MAP_NOCORE |
| 186 | { MAP_NOCORE, "MAP_NOCORE" }, |
| 187 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 188 | { 0, NULL }, |
| 189 | }; |
| 190 | |
John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 191 | #if !HAVE_LONG_LONG_OFF_T |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 192 | static |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 193 | int |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 194 | print_mmap(tcp,u_arg) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 195 | struct tcb *tcp; |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 196 | long *u_arg; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 197 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 198 | if (entering(tcp)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 199 | /* addr */ |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 200 | if (!u_arg[0]) |
| 201 | tprintf("NULL, "); |
| 202 | else |
| 203 | tprintf("%#lx, ", u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 204 | /* len */ |
| 205 | tprintf("%lu, ", u_arg[1]); |
| 206 | /* prot */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 207 | printflags(mmap_prot, u_arg[2], "PROT_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 208 | tprintf(", "); |
| 209 | /* flags */ |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 210 | #ifdef MAP_TYPE |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 211 | printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???"); |
| 212 | addflags(mmap_flags, u_arg[3] & ~MAP_TYPE); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 213 | #else |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 214 | printflags(mmap_flags, u_arg[3], "MAP_???"); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 215 | #endif |
Michal Ludvig | 0e03550 | 2002-09-23 15:41:01 +0000 | [diff] [blame] | 216 | /* fd (is always int, not long) */ |
| 217 | tprintf(", %d, ", (int)u_arg[4]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 218 | /* offset */ |
| 219 | tprintf("%#lx", u_arg[5]); |
| 220 | } |
| 221 | return RVAL_HEX; |
| 222 | } |
| 223 | |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 224 | #ifdef LINUX |
| 225 | int sys_old_mmap(tcp) |
| 226 | struct tcb *tcp; |
| 227 | { |
| 228 | long u_arg[6]; |
| 229 | |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 230 | #if defined(IA64) |
Wichert Akkerman | 12f75d1 | 2000-02-14 16:23:40 +0000 | [diff] [blame] | 231 | int i, v; |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 232 | /* |
| 233 | * IA64 processes never call this routine, they only use the |
| 234 | * new `sys_mmap' interface. This code converts the integer |
| 235 | * arguments that the IA32 process pushed onto the stack into |
| 236 | * longs. |
| 237 | * |
| 238 | * Note that addresses with bit 31 set will be sign extended. |
| 239 | * Fortunately, those addresses are not currently being generated |
| 240 | * for IA32 processes so it's not a problem. |
| 241 | */ |
| 242 | for (i = 0; i < 6; i++) |
| 243 | if (umove(tcp, tcp->u_arg[0] + (i * sizeof(int)), &v) == -1) |
| 244 | return 0; |
| 245 | else |
| 246 | u_arg[i] = v; |
Roland McGrath | f5a4777 | 2003-06-26 22:40:42 +0000 | [diff] [blame] | 247 | #elif defined(SH) || defined(SH64) |
Roland McGrath | 6b1d43e | 2003-03-31 01:05:01 +0000 | [diff] [blame] | 248 | /* SH has always passed the args in registers */ |
| 249 | int i; |
| 250 | for (i=0; i<6; i++) |
| 251 | u_arg[i] = tcp->u_arg[i]; |
| 252 | #else |
Roland McGrath | 520e21f | 2005-07-05 09:50:18 +0000 | [diff] [blame] | 253 | # if defined(X86_64) |
| 254 | if (current_personality == 1) { |
| 255 | int i; |
| 256 | for (i = 0; i < 6; ++i) { |
| 257 | unsigned int val; |
| 258 | if (umove(tcp, tcp->u_arg[0] + i * 4, &val) == -1) |
| 259 | return 0; |
| 260 | u_arg[i] = val; |
| 261 | } |
| 262 | } |
| 263 | else |
| 264 | # endif |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 265 | if (umoven(tcp, tcp->u_arg[0], sizeof u_arg, (char *) u_arg) == -1) |
| 266 | return 0; |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 267 | #endif // defined(IA64) |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 268 | return print_mmap(tcp, u_arg); |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 269 | |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 270 | } |
| 271 | #endif |
| 272 | |
| 273 | int |
| 274 | sys_mmap(tcp) |
| 275 | struct tcb *tcp; |
| 276 | { |
Roland McGrath | f5a4777 | 2003-06-26 22:40:42 +0000 | [diff] [blame] | 277 | #if defined(LINUX) && defined(SH64) |
Roland McGrath | e1e584b | 2003-06-02 19:18:58 +0000 | [diff] [blame] | 278 | /* |
| 279 | * Old mmap differs from new mmap in specifying the |
| 280 | * offset in units of bytes rather than pages. We |
| 281 | * pretend it's in byte units so the user only ever |
| 282 | * sees bytes in the printout. |
| 283 | */ |
| 284 | tcp->u_arg[5] <<= PAGE_SHIFT; |
| 285 | #endif |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 286 | return print_mmap(tcp, tcp->u_arg); |
| 287 | } |
John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 288 | #endif /* !HAVE_LONG_LONG_OFF_T */ |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 289 | |
John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 290 | #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 291 | int |
| 292 | sys_mmap64(tcp) |
| 293 | struct tcb *tcp; |
| 294 | { |
| 295 | #ifdef linux |
| 296 | #ifdef ALPHA |
| 297 | long *u_arg = tcp->u_arg; |
| 298 | #else /* !ALPHA */ |
| 299 | long u_arg[7]; |
| 300 | #endif /* !ALPHA */ |
| 301 | #else /* !linux */ |
| 302 | long *u_arg = tcp->u_arg; |
| 303 | #endif /* !linux */ |
| 304 | |
| 305 | if (entering(tcp)) { |
| 306 | #ifdef linux |
| 307 | #ifndef ALPHA |
| 308 | if (umoven(tcp, tcp->u_arg[0], sizeof u_arg, |
| 309 | (char *) u_arg) == -1) |
| 310 | return 0; |
| 311 | #endif /* ALPHA */ |
| 312 | #endif /* linux */ |
John Hughes | 5a826b8 | 2001-03-07 13:21:24 +0000 | [diff] [blame] | 313 | ALIGN64 (tcp, 5); /* FreeBSD wierdies */ |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 314 | |
| 315 | /* addr */ |
| 316 | tprintf("%#lx, ", u_arg[0]); |
| 317 | /* len */ |
| 318 | tprintf("%lu, ", u_arg[1]); |
| 319 | /* prot */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 320 | printflags(mmap_prot, u_arg[2], "PROT_???"); |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 321 | tprintf(", "); |
| 322 | /* flags */ |
John Hughes | 5a826b8 | 2001-03-07 13:21:24 +0000 | [diff] [blame] | 323 | #ifdef MAP_TYPE |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 324 | printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???"); |
| 325 | addflags(mmap_flags, u_arg[3] & ~MAP_TYPE); |
John Hughes | 5a826b8 | 2001-03-07 13:21:24 +0000 | [diff] [blame] | 326 | #else |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 327 | printflags(mmap_flags, u_arg[3], "MAP_???"); |
John Hughes | 5a826b8 | 2001-03-07 13:21:24 +0000 | [diff] [blame] | 328 | #endif |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 329 | /* fd */ |
| 330 | tprintf(", %ld, ", u_arg[4]); |
| 331 | /* offset */ |
John Hughes | 0c79e01 | 2001-03-08 14:40:06 +0000 | [diff] [blame] | 332 | tprintf("%#llx", LONG_LONG(u_arg[5], u_arg[6])); |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 333 | } |
| 334 | return RVAL_HEX; |
| 335 | } |
| 336 | #endif |
| 337 | |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 338 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 339 | int |
| 340 | sys_munmap(tcp) |
| 341 | struct tcb *tcp; |
| 342 | { |
| 343 | if (entering(tcp)) { |
| 344 | tprintf("%#lx, %lu", |
| 345 | tcp->u_arg[0], tcp->u_arg[1]); |
| 346 | } |
| 347 | return 0; |
| 348 | } |
| 349 | |
| 350 | int |
| 351 | sys_mprotect(tcp) |
| 352 | struct tcb *tcp; |
| 353 | { |
| 354 | if (entering(tcp)) { |
| 355 | tprintf("%#lx, %lu, ", |
| 356 | tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 357 | printflags(mmap_prot, tcp->u_arg[2], "PROT_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 358 | } |
| 359 | return 0; |
| 360 | } |
| 361 | |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 362 | #ifdef LINUX |
| 363 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 364 | static const struct xlat mremap_flags[] = { |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 365 | { MREMAP_MAYMOVE, "MREMAP_MAYMOVE" }, |
| 366 | { 0, NULL } |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 367 | }; |
| 368 | |
| 369 | int |
| 370 | sys_mremap(tcp) |
| 371 | struct tcb *tcp; |
| 372 | { |
| 373 | if (entering(tcp)) { |
| 374 | tprintf("%#lx, %lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1], |
| 375 | tcp->u_arg[2]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 376 | printflags(mremap_flags, tcp->u_arg[3], "MREMAP_???"); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 377 | } |
| 378 | return RVAL_HEX; |
| 379 | } |
| 380 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 381 | static const struct xlat madvise_flags[] = { |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 382 | #ifdef MADV_NORMAL |
| 383 | { MADV_NORMAL, "MADV_NORMAL" }, |
| 384 | #endif |
| 385 | #ifdef MADZV_RANDOM |
| 386 | { MADV_RANDOM, "MADV_RANDOM" }, |
| 387 | #endif |
| 388 | #ifdef MADV_SEQUENTIAL |
| 389 | { MADV_SEQUENTIAL, "MADV_SEQUENTIAL" }, |
| 390 | #endif |
| 391 | #ifdef MADV_WILLNEED |
| 392 | { MADV_WILLNEED, "MADV_WILLNEED" }, |
| 393 | #endif |
| 394 | #ifdef MADV_DONTNED |
| 395 | { MADV_DONTNEED, "MADV_DONTNEED" }, |
| 396 | #endif |
| 397 | { 0, NULL }, |
| 398 | }; |
| 399 | |
| 400 | |
| 401 | int |
| 402 | sys_madvise(tcp) |
| 403 | struct tcb *tcp; |
| 404 | { |
| 405 | if (entering(tcp)) { |
| 406 | tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 407 | printflags(madvise_flags, tcp->u_arg[2], "MADV_???"); |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 408 | } |
| 409 | return 0; |
| 410 | } |
| 411 | |
| 412 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 413 | static const struct xlat mlockall_flags[] = { |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 414 | #ifdef MCL_CURRENT |
| 415 | { MCL_CURRENT, "MCL_CURRENT" }, |
| 416 | #endif |
| 417 | #ifdef MCL_FUTURE |
| 418 | { MCL_FUTURE, "MCL_FUTURE" }, |
| 419 | #endif |
| 420 | { 0, NULL} |
| 421 | }; |
| 422 | |
| 423 | int |
| 424 | sys_mlockall(tcp) |
| 425 | struct tcb *tcp; |
| 426 | { |
| 427 | if (entering(tcp)) { |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 428 | printflags(mlockall_flags, tcp->u_arg[0], "MCL_???"); |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 429 | } |
| 430 | return 0; |
| 431 | } |
| 432 | |
| 433 | |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 434 | #endif /* LINUX */ |
| 435 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 436 | #ifdef MS_ASYNC |
| 437 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 438 | static const struct xlat mctl_sync[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 439 | #ifdef MS_SYNC |
| 440 | { MS_SYNC, "MS_SYNC" }, |
| 441 | #endif |
John Hughes | aca07f3 | 2001-10-16 18:12:27 +0000 | [diff] [blame] | 442 | { MS_ASYNC, "MS_ASYNC" }, |
| 443 | { MS_INVALIDATE,"MS_INVALIDATE" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 444 | { 0, NULL }, |
| 445 | }; |
| 446 | |
| 447 | int |
| 448 | sys_msync(tcp) |
| 449 | struct tcb *tcp; |
| 450 | { |
| 451 | if (entering(tcp)) { |
| 452 | /* addr */ |
| 453 | tprintf("%#lx", tcp->u_arg[0]); |
| 454 | /* len */ |
| 455 | tprintf(", %lu, ", tcp->u_arg[1]); |
| 456 | /* flags */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 457 | printflags(mctl_sync, tcp->u_arg[2], "MS_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 458 | } |
| 459 | return 0; |
| 460 | } |
| 461 | |
| 462 | #endif /* MS_ASYNC */ |
| 463 | |
| 464 | #ifdef MC_SYNC |
| 465 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 466 | static const struct xlat mctl_funcs[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 467 | { MC_LOCK, "MC_LOCK" }, |
| 468 | { MC_LOCKAS, "MC_LOCKAS" }, |
| 469 | { MC_SYNC, "MC_SYNC" }, |
| 470 | { MC_UNLOCK, "MC_UNLOCK" }, |
| 471 | { MC_UNLOCKAS, "MC_UNLOCKAS" }, |
| 472 | { 0, NULL }, |
| 473 | }; |
| 474 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 475 | static const struct xlat mctl_lockas[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 476 | { MCL_CURRENT, "MCL_CURRENT" }, |
| 477 | { MCL_FUTURE, "MCL_FUTURE" }, |
| 478 | { 0, NULL }, |
| 479 | }; |
| 480 | |
| 481 | int |
| 482 | sys_mctl(tcp) |
| 483 | struct tcb *tcp; |
| 484 | { |
| 485 | int arg, function; |
| 486 | |
| 487 | if (entering(tcp)) { |
| 488 | /* addr */ |
| 489 | tprintf("%#lx", tcp->u_arg[0]); |
| 490 | /* len */ |
| 491 | tprintf(", %lu, ", tcp->u_arg[1]); |
| 492 | /* function */ |
| 493 | function = tcp->u_arg[2]; |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 494 | printflags(mctl_funcs, function, "MC_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 495 | /* arg */ |
| 496 | arg = tcp->u_arg[3]; |
| 497 | tprintf(", "); |
| 498 | switch (function) { |
| 499 | case MC_SYNC: |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 500 | printflags(mctl_sync, arg, "MS_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 501 | break; |
| 502 | case MC_LOCKAS: |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 503 | printflags(mctl_lockas, arg, "MCL_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 504 | break; |
| 505 | default: |
| 506 | tprintf("%#x", arg); |
| 507 | break; |
| 508 | } |
| 509 | } |
| 510 | return 0; |
| 511 | } |
| 512 | |
| 513 | #endif /* MC_SYNC */ |
| 514 | |
| 515 | int |
| 516 | sys_mincore(tcp) |
| 517 | struct tcb *tcp; |
| 518 | { |
Roland McGrath | 46100d0 | 2005-06-01 18:55:42 +0000 | [diff] [blame] | 519 | unsigned long i, len; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 520 | char *vec = NULL; |
| 521 | |
| 522 | if (entering(tcp)) { |
| 523 | tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 524 | } else { |
| 525 | len = tcp->u_arg[1]; |
| 526 | if (syserror(tcp) || tcp->u_arg[2] == 0 || |
Roland McGrath | 46100d0 | 2005-06-01 18:55:42 +0000 | [diff] [blame] | 527 | (vec = malloc(len)) == NULL || |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 528 | umoven(tcp, tcp->u_arg[2], len, vec) < 0) |
| 529 | tprintf("%#lx", tcp->u_arg[2]); |
| 530 | else { |
| 531 | tprintf("["); |
| 532 | for (i = 0; i < len; i++) { |
| 533 | if (abbrev(tcp) && i >= max_strlen) { |
| 534 | tprintf("..."); |
| 535 | break; |
| 536 | } |
| 537 | tprintf((vec[i] & 1) ? "1" : "0"); |
| 538 | } |
| 539 | tprintf("]"); |
| 540 | } |
| 541 | if (vec) |
| 542 | free(vec); |
| 543 | } |
| 544 | return 0; |
| 545 | } |
| 546 | |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 547 | #if defined(ALPHA) || defined(FREEBSD) || defined(IA64) || defined(SUNOS4) || defined(SVR4) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 548 | int |
| 549 | sys_getpagesize(tcp) |
| 550 | struct tcb *tcp; |
| 551 | { |
| 552 | if (exiting(tcp)) |
| 553 | return RVAL_HEX; |
| 554 | return 0; |
| 555 | } |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 556 | #endif /* ALPHA || FREEBSD || IA64 || SUNOS4 || SVR4 */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 557 | |
| 558 | #if defined(LINUX) && defined(__i386__) |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 559 | void |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 560 | print_ldt_entry (ldt_entry) |
| 561 | struct modify_ldt_ldt_s *ldt_entry; |
| 562 | { |
| 563 | tprintf("base_addr:%#08lx, " |
| 564 | "limit:%d, " |
| 565 | "seg_32bit:%d, " |
| 566 | "contents:%d, " |
| 567 | "read_exec_only:%d, " |
| 568 | "limit_in_pages:%d, " |
| 569 | "seg_not_present:%d, " |
| 570 | "useable:%d}", |
| 571 | ldt_entry->base_addr, |
| 572 | ldt_entry->limit, |
| 573 | ldt_entry->seg_32bit, |
| 574 | ldt_entry->contents, |
| 575 | ldt_entry->read_exec_only, |
| 576 | ldt_entry->limit_in_pages, |
| 577 | ldt_entry->seg_not_present, |
| 578 | ldt_entry->useable); |
| 579 | } |
| 580 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 581 | int |
| 582 | sys_modify_ldt(tcp) |
| 583 | struct tcb *tcp; |
| 584 | { |
| 585 | if (entering(tcp)) { |
| 586 | struct modify_ldt_ldt_s copy; |
| 587 | tprintf("%ld", tcp->u_arg[0]); |
| 588 | if (tcp->u_arg[1] == 0 |
| 589 | || tcp->u_arg[2] != sizeof (struct modify_ldt_ldt_s) |
| 590 | || umove(tcp, tcp->u_arg[1], ©) == -1) |
| 591 | tprintf(", %lx", tcp->u_arg[1]); |
| 592 | else { |
| 593 | tprintf(", {entry_number:%d, ", copy.entry_number); |
| 594 | if (!verbose(tcp)) |
| 595 | tprintf("...}"); |
| 596 | else { |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 597 | print_ldt_entry(©); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 598 | } |
| 599 | } |
| 600 | tprintf(", %lu", tcp->u_arg[2]); |
| 601 | } |
| 602 | return 0; |
| 603 | } |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 604 | |
| 605 | int |
| 606 | sys_set_thread_area(tcp) |
| 607 | struct tcb *tcp; |
| 608 | { |
| 609 | struct modify_ldt_ldt_s copy; |
| 610 | if (entering(tcp)) { |
| 611 | if (umove(tcp, tcp->u_arg[0], ©) != -1) { |
| 612 | if (copy.entry_number == -1) |
| 613 | tprintf("{entry_number:%d -> ", |
| 614 | copy.entry_number); |
| 615 | else |
| 616 | tprintf("{entry_number:"); |
| 617 | } |
| 618 | } else { |
| 619 | if (umove(tcp, tcp->u_arg[0], ©) != -1) { |
| 620 | tprintf("%d, ", copy.entry_number); |
| 621 | if (!verbose(tcp)) |
| 622 | tprintf("...}"); |
| 623 | else { |
| 624 | print_ldt_entry(©); |
| 625 | } |
| 626 | } else { |
| 627 | tprintf("%lx", tcp->u_arg[0]); |
| 628 | } |
| 629 | } |
| 630 | return 0; |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 631 | |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 632 | } |
| 633 | |
| 634 | int |
| 635 | sys_get_thread_area(tcp) |
| 636 | struct tcb *tcp; |
| 637 | { |
| 638 | struct modify_ldt_ldt_s copy; |
| 639 | if (exiting(tcp)) { |
| 640 | if (umove(tcp, tcp->u_arg[0], ©) != -1) { |
| 641 | tprintf("{entry_number:%d, ", copy.entry_number); |
| 642 | if (!verbose(tcp)) |
| 643 | tprintf("...}"); |
| 644 | else { |
| 645 | print_ldt_entry(©); |
| 646 | } |
| 647 | } else { |
| 648 | tprintf("%lx", tcp->u_arg[0]); |
| 649 | } |
| 650 | } |
| 651 | return 0; |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 652 | |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 653 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 654 | #endif /* LINUX && __i386__ */ |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 655 | |
| 656 | #if defined(LINUX) |
| 657 | int |
| 658 | sys_remap_file_pages(tcp) |
| 659 | struct tcb *tcp; |
| 660 | { |
| 661 | if (entering(tcp)) { |
| 662 | tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 663 | printflags(mmap_prot, tcp->u_arg[2], "PROT_???"); |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 664 | tprintf(", %lu, ", tcp->u_arg[3]); |
| 665 | #ifdef MAP_TYPE |
| 666 | printxval(mmap_flags, tcp->u_arg[4] & MAP_TYPE, "MAP_???"); |
| 667 | addflags(mmap_flags, tcp->u_arg[4] & ~MAP_TYPE); |
| 668 | #else |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 669 | printflags(mmap_flags, tcp->u_arg[4], "MAP_???"); |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 670 | #endif |
| 671 | } |
| 672 | return 0; |
| 673 | } |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 674 | |
| 675 | |
| 676 | #define MPOL_DEFAULT 0 |
| 677 | #define MPOL_PREFERRED 1 |
| 678 | #define MPOL_BIND 2 |
| 679 | #define MPOL_INTERLEAVE 3 |
| 680 | |
| 681 | #define MPOL_F_NODE (1<<0) |
| 682 | #define MPOL_F_ADDR (1<<1) |
| 683 | |
| 684 | #define MPOL_MF_STRICT (1<<0) |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 685 | #define MPOL_MF_MOVE (1<<1) |
| 686 | #define MPOL_MF_MOVE_ALL (1<<2) |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 687 | |
| 688 | |
| 689 | static const struct xlat policies[] = { |
| 690 | { MPOL_DEFAULT, "MPOL_DEFAULT" }, |
| 691 | { MPOL_PREFERRED, "MPOL_PREFERRED" }, |
| 692 | { MPOL_BIND, "MPOL_BIND" }, |
| 693 | { MPOL_INTERLEAVE, "MPOL_INTERLEAVE" }, |
| 694 | { 0, NULL } |
| 695 | }; |
| 696 | |
| 697 | static const struct xlat mbindflags[] = { |
| 698 | { MPOL_MF_STRICT, "MPOL_MF_STRICT" }, |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 699 | { MPOL_MF_MOVE, "MPOL_MF_MOVE" }, |
| 700 | { MPOL_MF_MOVE_ALL, "MPOL_MF_MOVE_ALL" }, |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 701 | { 0, NULL } |
| 702 | }; |
| 703 | |
| 704 | static const struct xlat mempolicyflags[] = { |
| 705 | { MPOL_F_NODE, "MPOL_F_NODE" }, |
| 706 | { MPOL_F_ADDR, "MPOL_F_ADDR" }, |
| 707 | { 0, NULL } |
| 708 | }; |
| 709 | |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 710 | static const struct xlat move_pages_flags[] = { |
| 711 | { MPOL_MF_MOVE, "MPOL_MF_MOVE" }, |
| 712 | { MPOL_MF_MOVE_ALL, "MPOL_MF_MOVE_ALL" }, |
| 713 | { 0, NULL } |
| 714 | }; |
| 715 | |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 716 | |
| 717 | static void |
| 718 | get_nodes(tcp, ptr, maxnodes, err) |
| 719 | struct tcb *tcp; |
| 720 | unsigned long ptr; |
| 721 | unsigned long maxnodes; |
| 722 | int err; |
| 723 | { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 724 | unsigned long nlongs, size, end; |
| 725 | |
| 726 | nlongs = (maxnodes + 8 * sizeof(long) - 1) / (8 * sizeof(long)); |
| 727 | size = nlongs * sizeof(long); |
| 728 | end = ptr + size; |
| 729 | if (nlongs == 0 || ((err || verbose(tcp)) && (size * 8 == maxnodes) |
| 730 | && (end > ptr))) { |
| 731 | unsigned long n, cur, abbrev_end; |
| 732 | int failed = 0; |
| 733 | |
| 734 | if (abbrev(tcp)) { |
| 735 | abbrev_end = ptr + max_strlen * sizeof(long); |
| 736 | if (abbrev_end < ptr) |
| 737 | abbrev_end = end; |
| 738 | } else { |
| 739 | abbrev_end = end; |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 740 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 741 | tprintf(", {"); |
| 742 | for (cur = ptr; cur < end; cur += sizeof(long)) { |
| 743 | if (cur > ptr) |
| 744 | tprintf(", "); |
| 745 | if (cur >= abbrev_end) { |
| 746 | tprintf("..."); |
| 747 | break; |
| 748 | } |
| 749 | if (umoven(tcp, cur, sizeof(n), (char *) &n) < 0) { |
| 750 | tprintf("?"); |
| 751 | failed = 1; |
| 752 | break; |
| 753 | } |
| 754 | tprintf("%#0*lx", (int) sizeof(long) * 2 + 2, n); |
| 755 | } |
| 756 | tprintf("}"); |
| 757 | if (failed) |
| 758 | tprintf(" %#lx", ptr); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 759 | } else |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 760 | tprintf(", %#lx", ptr); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 761 | tprintf(", %lu", maxnodes); |
| 762 | } |
| 763 | |
| 764 | int |
| 765 | sys_mbind(tcp) |
| 766 | struct tcb *tcp; |
| 767 | { |
| 768 | if (entering(tcp)) { |
| 769 | tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 770 | printxval(policies, tcp->u_arg[2], "MPOL_???"); |
| 771 | get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[4], 0); |
| 772 | tprintf(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 773 | printflags(mbindflags, tcp->u_arg[5], "MPOL_???"); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 774 | } |
| 775 | return 0; |
| 776 | } |
| 777 | |
| 778 | int |
| 779 | sys_set_mempolicy(tcp) |
| 780 | struct tcb *tcp; |
| 781 | { |
| 782 | if (entering(tcp)) { |
| 783 | printxval(policies, tcp->u_arg[0], "MPOL_???"); |
| 784 | get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], 0); |
| 785 | } |
| 786 | return 0; |
| 787 | } |
| 788 | |
| 789 | int |
| 790 | sys_get_mempolicy(tcp) |
| 791 | struct tcb *tcp; |
| 792 | { |
| 793 | if (exiting(tcp)) { |
| 794 | int pol; |
| 795 | if (tcp->u_arg[0] == 0) |
| 796 | tprintf("NULL"); |
| 797 | else if (syserror(tcp) || umove(tcp, tcp->u_arg[0], &pol) < 0) |
| 798 | tprintf("%#lx", tcp->u_arg[0]); |
| 799 | else |
| 800 | printxval(policies, pol, "MPOL_???"); |
| 801 | get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], syserror(tcp)); |
| 802 | tprintf(", %#lx, ", tcp->u_arg[3]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 803 | printflags(mempolicyflags, tcp->u_arg[4], "MPOL_???"); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 804 | } |
| 805 | return 0; |
| 806 | } |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 807 | |
| 808 | int |
| 809 | sys_move_pages(tcp) |
| 810 | struct tcb *tcp; |
| 811 | { |
| 812 | if (entering(tcp)) { |
| 813 | unsigned long npages = tcp->u_arg[1]; |
| 814 | tprintf("%ld, %lu, ", tcp->u_arg[0], npages); |
| 815 | if (tcp->u_arg[2] == 0) |
| 816 | tprintf("NULL, "); |
| 817 | else { |
| 818 | int i; |
| 819 | long puser = tcp->u_arg[2]; |
| 820 | tprintf("{"); |
| 821 | for (i = 0; i < npages; ++i) { |
| 822 | void *p; |
| 823 | if (i > 0) |
| 824 | tprintf(", "); |
| 825 | if (umove(tcp, puser, &p) < 0) { |
| 826 | tprintf("???"); |
| 827 | break; |
| 828 | } |
| 829 | tprintf("%p", p); |
| 830 | puser += sizeof (void *); |
| 831 | } |
| 832 | tprintf("}, "); |
| 833 | } |
| 834 | if (tcp->u_arg[3] == 0) |
| 835 | tprintf("NULL, "); |
| 836 | else { |
| 837 | int i; |
| 838 | long nodeuser = tcp->u_arg[3]; |
| 839 | tprintf("{"); |
| 840 | for (i = 0; i < npages; ++i) { |
| 841 | int node; |
| 842 | if (i > 0) |
| 843 | tprintf(", "); |
| 844 | if (umove(tcp, nodeuser, &node) < 0) { |
| 845 | tprintf("???"); |
| 846 | break; |
| 847 | } |
| 848 | tprintf("%#x", node); |
| 849 | nodeuser += sizeof (int); |
| 850 | } |
| 851 | tprintf("}, "); |
| 852 | } |
| 853 | } |
| 854 | if (exiting(tcp)) { |
| 855 | unsigned long npages = tcp->u_arg[1]; |
| 856 | if (tcp->u_arg[4] == 0) |
| 857 | tprintf("NULL, "); |
| 858 | else { |
| 859 | int i; |
| 860 | long statususer = tcp->u_arg[4]; |
| 861 | tprintf("{"); |
| 862 | for (i = 0; i < npages; ++i) { |
| 863 | int status; |
| 864 | if (i > 0) |
| 865 | tprintf(", "); |
| 866 | if (umove(tcp, statususer, &status) < 0) { |
| 867 | tprintf("???"); |
| 868 | break; |
| 869 | } |
| 870 | tprintf("%#x", status); |
| 871 | statususer += sizeof (int); |
| 872 | } |
| 873 | tprintf("}, "); |
| 874 | } |
| 875 | printflags(move_pages_flags, tcp->u_arg[5], "MPOL_???"); |
| 876 | } |
| 877 | return 0; |
| 878 | } |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 879 | #endif |