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> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 6 | * All rights reserved. |
| 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions |
| 10 | * are met: |
| 11 | * 1. Redistributions of source code must retain the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer. |
| 13 | * 2. Redistributions in binary form must reproduce the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer in the |
| 15 | * documentation and/or other materials provided with the distribution. |
| 16 | * 3. The name of the author may not be used to endorse or promote products |
| 17 | * derived from this software without specific prior written permission. |
| 18 | * |
| 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 | * |
| 30 | * $Id$ |
| 31 | */ |
| 32 | |
| 33 | #include "defs.h" |
| 34 | |
| 35 | #include <fcntl.h> |
John Hughes | 1d08dcf | 2001-07-10 13:48:44 +0000 | [diff] [blame] | 36 | #if HAVE_SYS_UIO_H |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 37 | #include <sys/uio.h> |
John Hughes | 1d08dcf | 2001-07-10 13:48:44 +0000 | [diff] [blame] | 38 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 39 | |
John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 40 | #ifdef HAVE_LONG_LONG_OFF_T |
| 41 | /* |
| 42 | * Hacks for systems that have a long long off_t |
| 43 | */ |
| 44 | |
| 45 | #define sys_pread64 sys_pread |
| 46 | #define sys_pwrite64 sys_pwrite |
| 47 | #endif |
| 48 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 49 | int |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 50 | sys_read(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 51 | { |
| 52 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 53 | printfd(tcp, tcp->u_arg[0]); |
| 54 | tprintf(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 55 | } else { |
| 56 | if (syserror(tcp)) |
| 57 | tprintf("%#lx", tcp->u_arg[1]); |
| 58 | else |
| 59 | printstr(tcp, tcp->u_arg[1], tcp->u_rval); |
| 60 | tprintf(", %lu", tcp->u_arg[2]); |
| 61 | } |
| 62 | return 0; |
| 63 | } |
| 64 | |
| 65 | int |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 66 | sys_write(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 67 | { |
| 68 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 69 | printfd(tcp, tcp->u_arg[0]); |
| 70 | tprintf(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 71 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 72 | tprintf(", %lu", tcp->u_arg[2]); |
| 73 | } |
| 74 | return 0; |
| 75 | } |
| 76 | |
John Hughes | 1d08dcf | 2001-07-10 13:48:44 +0000 | [diff] [blame] | 77 | #if HAVE_SYS_UIO_H |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 78 | void |
Dmitry V. Levin | 8884968 | 2011-06-13 22:58:44 +0000 | [diff] [blame] | 79 | tprint_iov(struct tcb *tcp, unsigned long len, unsigned long addr, int decode_iov) |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 80 | { |
Dmitry V. Levin | 4ebb4e3 | 2006-12-13 17:08:08 +0000 | [diff] [blame] | 81 | #if defined(LINUX) && SUPPORTED_PERSONALITIES > 1 |
| 82 | union { |
| 83 | struct { u_int32_t base; u_int32_t len; } iov32; |
| 84 | struct { u_int64_t base; u_int64_t len; } iov64; |
| 85 | } iov; |
| 86 | #define sizeof_iov \ |
| 87 | (personality_wordsize[current_personality] == 4 \ |
| 88 | ? sizeof(iov.iov32) : sizeof(iov.iov64)) |
| 89 | #define iov_iov_base \ |
| 90 | (personality_wordsize[current_personality] == 4 \ |
| 91 | ? (u_int64_t) iov.iov32.base : iov.iov64.base) |
| 92 | #define iov_iov_len \ |
| 93 | (personality_wordsize[current_personality] == 4 \ |
| 94 | ? (u_int64_t) iov.iov32.len : iov.iov64.len) |
| 95 | #else |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 96 | struct iovec iov; |
Dmitry V. Levin | 4ebb4e3 | 2006-12-13 17:08:08 +0000 | [diff] [blame] | 97 | #define sizeof_iov sizeof(iov) |
| 98 | #define iov_iov_base iov.iov_base |
| 99 | #define iov_iov_len iov.iov_len |
| 100 | #endif |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 101 | unsigned long size, cur, end, abbrev_end; |
| 102 | int failed = 0; |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 103 | |
| 104 | if (!len) { |
| 105 | tprintf("[]"); |
| 106 | return; |
| 107 | } |
Dmitry V. Levin | 4ebb4e3 | 2006-12-13 17:08:08 +0000 | [diff] [blame] | 108 | size = len * sizeof_iov; |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 109 | end = addr + size; |
Dmitry V. Levin | 4ebb4e3 | 2006-12-13 17:08:08 +0000 | [diff] [blame] | 110 | if (!verbose(tcp) || size / sizeof_iov != len || end < addr) { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 111 | tprintf("%#lx", addr); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 112 | return; |
| 113 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 114 | if (abbrev(tcp)) { |
Dmitry V. Levin | 4ebb4e3 | 2006-12-13 17:08:08 +0000 | [diff] [blame] | 115 | abbrev_end = addr + max_strlen * sizeof_iov; |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 116 | if (abbrev_end < addr) |
| 117 | abbrev_end = end; |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 118 | } else { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 119 | abbrev_end = end; |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 120 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 121 | tprintf("["); |
Dmitry V. Levin | 4ebb4e3 | 2006-12-13 17:08:08 +0000 | [diff] [blame] | 122 | for (cur = addr; cur < end; cur += sizeof_iov) { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 123 | if (cur > addr) |
| 124 | tprintf(", "); |
| 125 | if (cur >= abbrev_end) { |
| 126 | tprintf("..."); |
| 127 | break; |
| 128 | } |
Dmitry V. Levin | 4ebb4e3 | 2006-12-13 17:08:08 +0000 | [diff] [blame] | 129 | if (umoven(tcp, cur, sizeof_iov, (char *) &iov) < 0) { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 130 | tprintf("?"); |
| 131 | failed = 1; |
| 132 | break; |
| 133 | } |
| 134 | tprintf("{"); |
Dmitry V. Levin | 8884968 | 2011-06-13 22:58:44 +0000 | [diff] [blame] | 135 | if (decode_iov) |
| 136 | printstr(tcp, (long) iov_iov_base, iov_iov_len); |
| 137 | else |
| 138 | tprintf("%#lx", (long) iov_iov_base); |
Dmitry V. Levin | 4ebb4e3 | 2006-12-13 17:08:08 +0000 | [diff] [blame] | 139 | tprintf(", %lu}", (unsigned long)iov_iov_len); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 140 | } |
| 141 | tprintf("]"); |
| 142 | if (failed) |
| 143 | tprintf(" %#lx", addr); |
Dmitry V. Levin | 4ebb4e3 | 2006-12-13 17:08:08 +0000 | [diff] [blame] | 144 | #undef sizeof_iov |
| 145 | #undef iov_iov_base |
| 146 | #undef iov_iov_len |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 147 | } |
| 148 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 149 | int |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 150 | sys_readv(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 151 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 152 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 153 | printfd(tcp, tcp->u_arg[0]); |
| 154 | tprintf(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 155 | } else { |
| 156 | if (syserror(tcp)) { |
| 157 | tprintf("%#lx, %lu", |
| 158 | tcp->u_arg[1], tcp->u_arg[2]); |
| 159 | return 0; |
| 160 | } |
Dmitry V. Levin | 8884968 | 2011-06-13 22:58:44 +0000 | [diff] [blame] | 161 | tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 162 | tprintf(", %lu", tcp->u_arg[2]); |
| 163 | } |
| 164 | return 0; |
| 165 | } |
| 166 | |
| 167 | int |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 168 | sys_writev(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 169 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 170 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 171 | printfd(tcp, tcp->u_arg[0]); |
| 172 | tprintf(", "); |
Dmitry V. Levin | 8884968 | 2011-06-13 22:58:44 +0000 | [diff] [blame] | 173 | tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 174 | tprintf(", %lu", tcp->u_arg[2]); |
| 175 | } |
| 176 | return 0; |
| 177 | } |
John Hughes | 1d08dcf | 2001-07-10 13:48:44 +0000 | [diff] [blame] | 178 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 179 | |
John Hughes | 5a826b8 | 2001-03-07 13:21:24 +0000 | [diff] [blame] | 180 | #if defined(SVR4) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 181 | |
| 182 | int |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 183 | sys_pread(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 184 | { |
| 185 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 186 | printfd(tcp, tcp->u_arg[0]); |
| 187 | tprintf(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 188 | } else { |
| 189 | if (syserror(tcp)) |
| 190 | tprintf("%#lx", tcp->u_arg[1]); |
| 191 | else |
| 192 | printstr(tcp, tcp->u_arg[1], tcp->u_rval); |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 193 | #if UNIXWARE |
| 194 | /* off_t is signed int */ |
| 195 | tprintf(", %lu, %ld", tcp->u_arg[2], tcp->u_arg[3]); |
| 196 | #else |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 197 | tprintf(", %lu, %llu", tcp->u_arg[2], |
Roland McGrath | 2fe2a3e | 2004-10-07 19:09:16 +0000 | [diff] [blame] | 198 | LONG_LONG(tcp->u_arg[3], tcp->u_arg[4])); |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 199 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 200 | } |
| 201 | return 0; |
| 202 | } |
| 203 | |
| 204 | int |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 205 | sys_pwrite(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 206 | { |
| 207 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 208 | printfd(tcp, tcp->u_arg[0]); |
| 209 | tprintf(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 210 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 211 | #if UNIXWARE |
| 212 | /* off_t is signed int */ |
| 213 | tprintf(", %lu, %ld", tcp->u_arg[2], tcp->u_arg[3]); |
| 214 | #else |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 215 | tprintf(", %lu, %llu", tcp->u_arg[2], |
Roland McGrath | 2fe2a3e | 2004-10-07 19:09:16 +0000 | [diff] [blame] | 216 | LONG_LONG(tcp->u_arg[3], tcp->u_arg[4])); |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 217 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 218 | } |
| 219 | return 0; |
| 220 | } |
John Hughes | 5a826b8 | 2001-03-07 13:21:24 +0000 | [diff] [blame] | 221 | #endif /* SVR4 */ |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 222 | |
| 223 | #ifdef FREEBSD |
| 224 | #include <sys/types.h> |
| 225 | #include <sys/socket.h> |
| 226 | |
| 227 | int |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 228 | sys_sendfile(struct tcb *tcp) |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 229 | { |
| 230 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 231 | printfd(tcp, tcp->u_arg[0]); |
| 232 | tprintf(", "); |
| 233 | printfd(tcp, tcp->u_arg[1]); |
| 234 | tprintf(", %llu, %lu", |
Roland McGrath | 2fe2a3e | 2004-10-07 19:09:16 +0000 | [diff] [blame] | 235 | LONG_LONG(tcp->u_arg[2], tcp->u_arg[3]), |
| 236 | tcp->u_arg[4]); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 237 | } else { |
| 238 | off_t offset; |
| 239 | |
| 240 | if (!tcp->u_arg[5]) |
| 241 | tprintf(", NULL"); |
| 242 | else { |
| 243 | struct sf_hdtr hdtr; |
| 244 | |
| 245 | if (umove(tcp, tcp->u_arg[5], &hdtr) < 0) |
| 246 | tprintf(", %#lx", tcp->u_arg[5]); |
| 247 | else { |
| 248 | tprintf(", { "); |
Dmitry V. Levin | 8884968 | 2011-06-13 22:58:44 +0000 | [diff] [blame] | 249 | tprint_iov(tcp, hdtr.hdr_cnt, hdtr.headers, 1); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 250 | tprintf(", %u, ", hdtr.hdr_cnt); |
Dmitry V. Levin | 8884968 | 2011-06-13 22:58:44 +0000 | [diff] [blame] | 251 | tprint_iov(tcp, hdtr.trl_cnt, hdtr.trailers, 1); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 252 | tprintf(", %u }", hdtr.hdr_cnt); |
| 253 | } |
| 254 | } |
| 255 | if (!tcp->u_arg[6]) |
| 256 | tprintf(", NULL"); |
| 257 | else if (umove(tcp, tcp->u_arg[6], &offset) < 0) |
| 258 | tprintf(", %#lx", tcp->u_arg[6]); |
| 259 | else |
| 260 | tprintf(", [%llu]", offset); |
| 261 | tprintf(", %lu", tcp->u_arg[7]); |
| 262 | } |
| 263 | return 0; |
| 264 | } |
| 265 | #endif /* FREEBSD */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 266 | |
| 267 | #ifdef LINUX |
Roland McGrath | c0f8bbd | 2003-08-21 09:58:00 +0000 | [diff] [blame] | 268 | |
| 269 | /* The SH4 ABI does allow long longs in odd-numbered registers, but |
| 270 | does not allow them to be split between registers and memory - and |
| 271 | there are only four argument registers for normal functions. As a |
| 272 | result pread takes an extra padding argument before the offset. This |
| 273 | was changed late in the 2.4 series (around 2.4.20). */ |
| 274 | #if defined(SH) |
| 275 | #define PREAD_OFFSET_ARG 4 |
| 276 | #else |
| 277 | #define PREAD_OFFSET_ARG 3 |
| 278 | #endif |
| 279 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 280 | int |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 281 | sys_pread(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 282 | { |
| 283 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 284 | printfd(tcp, tcp->u_arg[0]); |
| 285 | tprintf(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 286 | } else { |
| 287 | if (syserror(tcp)) |
| 288 | tprintf("%#lx", tcp->u_arg[1]); |
| 289 | else |
| 290 | printstr(tcp, tcp->u_arg[1], tcp->u_rval); |
Andreas Schwab | b5600fc | 2009-11-04 17:08:34 +0100 | [diff] [blame] | 291 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 292 | printllval(tcp, "%llu", PREAD_OFFSET_ARG); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 293 | } |
| 294 | return 0; |
| 295 | } |
| 296 | |
| 297 | int |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 298 | sys_pwrite(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 299 | { |
| 300 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 301 | printfd(tcp, tcp->u_arg[0]); |
| 302 | tprintf(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 303 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
Andreas Schwab | b5600fc | 2009-11-04 17:08:34 +0100 | [diff] [blame] | 304 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 305 | printllval(tcp, "%llu", PREAD_OFFSET_ARG); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 306 | } |
| 307 | return 0; |
| 308 | } |
| 309 | |
Damir Shayhutdinov | 3087dd6 | 2011-05-12 16:57:40 +0400 | [diff] [blame] | 310 | #if HAVE_SYS_UIO_H |
| 311 | int |
| 312 | sys_preadv(struct tcb *tcp) |
| 313 | { |
| 314 | if (entering(tcp)) { |
| 315 | printfd(tcp, tcp->u_arg[0]); |
| 316 | tprintf(", "); |
| 317 | } else { |
| 318 | if (syserror(tcp)) { |
| 319 | tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]); |
| 320 | return 0; |
| 321 | } |
Dmitry V. Levin | 8884968 | 2011-06-13 22:58:44 +0000 | [diff] [blame] | 322 | tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1); |
Damir Shayhutdinov | 3087dd6 | 2011-05-12 16:57:40 +0400 | [diff] [blame] | 323 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 324 | printllval(tcp, "%llu", PREAD_OFFSET_ARG); |
| 325 | } |
| 326 | return 0; |
| 327 | } |
| 328 | |
| 329 | int |
| 330 | sys_pwritev(struct tcb *tcp) |
| 331 | { |
| 332 | if (entering(tcp)) { |
| 333 | printfd(tcp, tcp->u_arg[0]); |
| 334 | tprintf(", "); |
Dmitry V. Levin | 8884968 | 2011-06-13 22:58:44 +0000 | [diff] [blame] | 335 | tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1); |
Damir Shayhutdinov | 3087dd6 | 2011-05-12 16:57:40 +0400 | [diff] [blame] | 336 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 337 | printllval(tcp, "%llu", PREAD_OFFSET_ARG); |
| 338 | } |
| 339 | return 0; |
| 340 | } |
| 341 | #endif /* HAVE_SYS_UIO_H */ |
| 342 | |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 343 | int |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 344 | sys_sendfile(struct tcb *tcp) |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 345 | { |
| 346 | if (entering(tcp)) { |
| 347 | off_t offset; |
| 348 | |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 349 | printfd(tcp, tcp->u_arg[0]); |
| 350 | tprintf(", "); |
| 351 | printfd(tcp, tcp->u_arg[1]); |
| 352 | tprintf(", "); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 353 | if (!tcp->u_arg[2]) |
| 354 | tprintf("NULL"); |
| 355 | else if (umove(tcp, tcp->u_arg[2], &offset) < 0) |
| 356 | tprintf("%#lx", tcp->u_arg[2]); |
| 357 | else |
| 358 | tprintf("[%lu]", offset); |
| 359 | tprintf(", %lu", tcp->u_arg[3]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 360 | } |
| 361 | return 0; |
| 362 | } |
| 363 | |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 364 | int |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 365 | sys_sendfile64(struct tcb *tcp) |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 366 | { |
| 367 | if (entering(tcp)) { |
| 368 | loff_t offset; |
| 369 | |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 370 | printfd(tcp, tcp->u_arg[0]); |
| 371 | tprintf(", "); |
| 372 | printfd(tcp, tcp->u_arg[1]); |
| 373 | tprintf(", "); |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 374 | if (!tcp->u_arg[2]) |
| 375 | tprintf("NULL"); |
| 376 | else if (umove(tcp, tcp->u_arg[2], &offset) < 0) |
| 377 | tprintf("%#lx", tcp->u_arg[2]); |
| 378 | else |
| 379 | tprintf("[%llu]", (unsigned long long int) offset); |
| 380 | tprintf(", %lu", tcp->u_arg[3]); |
| 381 | } |
| 382 | return 0; |
| 383 | } |
| 384 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 385 | #endif /* LINUX */ |
| 386 | |
John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 387 | #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 388 | int |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 389 | sys_pread64(struct tcb *tcp) |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 390 | { |
| 391 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 392 | printfd(tcp, tcp->u_arg[0]); |
| 393 | tprintf(", "); |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 394 | } else { |
| 395 | if (syserror(tcp)) |
| 396 | tprintf("%#lx", tcp->u_arg[1]); |
| 397 | else |
| 398 | printstr(tcp, tcp->u_arg[1], tcp->u_rval); |
Andreas Schwab | b5600fc | 2009-11-04 17:08:34 +0100 | [diff] [blame] | 399 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 400 | printllval(tcp, "%#llx", 3); |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 401 | } |
| 402 | return 0; |
| 403 | } |
| 404 | |
| 405 | int |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 406 | sys_pwrite64(struct tcb *tcp) |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 407 | { |
| 408 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 409 | printfd(tcp, tcp->u_arg[0]); |
| 410 | tprintf(", "); |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 411 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
Andreas Schwab | b5600fc | 2009-11-04 17:08:34 +0100 | [diff] [blame] | 412 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 413 | printllval(tcp, "%#llx", 3); |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 414 | } |
| 415 | return 0; |
| 416 | } |
| 417 | #endif |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 418 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 419 | int |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 420 | sys_ioctl(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 421 | { |
Roland McGrath | ee36ce1 | 2004-09-04 03:53:10 +0000 | [diff] [blame] | 422 | const struct ioctlent *iop; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 423 | |
| 424 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 425 | printfd(tcp, tcp->u_arg[0]); |
| 426 | tprintf(", "); |
Roland McGrath | 2843a4e | 2003-11-14 02:54:03 +0000 | [diff] [blame] | 427 | iop = ioctl_lookup(tcp->u_arg[1]); |
| 428 | if (iop) { |
Denys Vlasenko | 5940e65 | 2011-09-01 09:55:05 +0200 | [diff] [blame^] | 429 | tprints(iop->symbol); |
Roland McGrath | 2843a4e | 2003-11-14 02:54:03 +0000 | [diff] [blame] | 430 | while ((iop = ioctl_next_match(iop))) |
| 431 | tprintf(" or %s", iop->symbol); |
| 432 | } else |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 433 | tprintf("%#lx", tcp->u_arg[1]); |
| 434 | ioctl_decode(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 435 | } |
| 436 | else { |
Denys Vlasenko | 5d64581 | 2011-08-20 12:48:18 +0200 | [diff] [blame] | 437 | int ret = ioctl_decode(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 438 | if (!ret) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 439 | tprintf(", %#lx", tcp->u_arg[2]); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 440 | else |
| 441 | return ret - 1; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 442 | } |
| 443 | return 0; |
| 444 | } |