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