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. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 29 | */ |
| 30 | |
| 31 | #include "defs.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 32 | #include <fcntl.h> |
John Hughes | 1d08dcf | 2001-07-10 13:48:44 +0000 | [diff] [blame] | 33 | #if HAVE_SYS_UIO_H |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 34 | # include <sys/uio.h> |
John Hughes | 1d08dcf | 2001-07-10 13:48:44 +0000 | [diff] [blame] | 35 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 36 | |
| 37 | int |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 38 | sys_read(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 39 | { |
| 40 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 41 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 42 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 43 | } else { |
| 44 | if (syserror(tcp)) |
| 45 | tprintf("%#lx", tcp->u_arg[1]); |
| 46 | else |
| 47 | printstr(tcp, tcp->u_arg[1], tcp->u_rval); |
| 48 | tprintf(", %lu", tcp->u_arg[2]); |
| 49 | } |
| 50 | return 0; |
| 51 | } |
| 52 | |
| 53 | int |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 54 | sys_write(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 55 | { |
| 56 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 57 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 58 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 59 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 60 | tprintf(", %lu", tcp->u_arg[2]); |
| 61 | } |
| 62 | return 0; |
| 63 | } |
| 64 | |
John Hughes | 1d08dcf | 2001-07-10 13:48:44 +0000 | [diff] [blame] | 65 | #if HAVE_SYS_UIO_H |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 66 | void |
Dmitry V. Levin | 8884968 | 2011-06-13 22:58:44 +0000 | [diff] [blame] | 67 | 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] | 68 | { |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 69 | #if SUPPORTED_PERSONALITIES > 1 |
Dmitry V. Levin | 4ebb4e3 | 2006-12-13 17:08:08 +0000 | [diff] [blame] | 70 | union { |
| 71 | struct { u_int32_t base; u_int32_t len; } iov32; |
| 72 | struct { u_int64_t base; u_int64_t len; } iov64; |
| 73 | } iov; |
| 74 | #define sizeof_iov \ |
Denys Vlasenko | 9fd4f96 | 2012-03-19 09:36:42 +0100 | [diff] [blame] | 75 | (current_wordsize == 4 ? sizeof(iov.iov32) : sizeof(iov.iov64)) |
Dmitry V. Levin | 4ebb4e3 | 2006-12-13 17:08:08 +0000 | [diff] [blame] | 76 | #define iov_iov_base \ |
Denys Vlasenko | 9fd4f96 | 2012-03-19 09:36:42 +0100 | [diff] [blame] | 77 | (current_wordsize == 4 ? (uint64_t) iov.iov32.base : iov.iov64.base) |
Dmitry V. Levin | 4ebb4e3 | 2006-12-13 17:08:08 +0000 | [diff] [blame] | 78 | #define iov_iov_len \ |
Denys Vlasenko | 9fd4f96 | 2012-03-19 09:36:42 +0100 | [diff] [blame] | 79 | (current_wordsize == 4 ? (uint64_t) iov.iov32.len : iov.iov64.len) |
Dmitry V. Levin | 4ebb4e3 | 2006-12-13 17:08:08 +0000 | [diff] [blame] | 80 | #else |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 81 | struct iovec iov; |
Dmitry V. Levin | 4ebb4e3 | 2006-12-13 17:08:08 +0000 | [diff] [blame] | 82 | #define sizeof_iov sizeof(iov) |
| 83 | #define iov_iov_base iov.iov_base |
| 84 | #define iov_iov_len iov.iov_len |
| 85 | #endif |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 86 | unsigned long size, cur, end, abbrev_end; |
| 87 | int failed = 0; |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 88 | |
| 89 | if (!len) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 90 | tprints("[]"); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 91 | return; |
| 92 | } |
Dmitry V. Levin | 4ebb4e3 | 2006-12-13 17:08:08 +0000 | [diff] [blame] | 93 | size = len * sizeof_iov; |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 94 | end = addr + size; |
Dmitry V. Levin | 4ebb4e3 | 2006-12-13 17:08:08 +0000 | [diff] [blame] | 95 | if (!verbose(tcp) || size / sizeof_iov != len || end < addr) { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 96 | tprintf("%#lx", addr); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 97 | return; |
| 98 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 99 | if (abbrev(tcp)) { |
Dmitry V. Levin | 4ebb4e3 | 2006-12-13 17:08:08 +0000 | [diff] [blame] | 100 | abbrev_end = addr + max_strlen * sizeof_iov; |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 101 | if (abbrev_end < addr) |
| 102 | abbrev_end = end; |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 103 | } else { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 104 | abbrev_end = end; |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 105 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 106 | tprints("["); |
Dmitry V. Levin | 4ebb4e3 | 2006-12-13 17:08:08 +0000 | [diff] [blame] | 107 | for (cur = addr; cur < end; cur += sizeof_iov) { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 108 | if (cur > addr) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 109 | tprints(", "); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 110 | if (cur >= abbrev_end) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 111 | tprints("..."); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 112 | break; |
| 113 | } |
Dmitry V. Levin | 4ebb4e3 | 2006-12-13 17:08:08 +0000 | [diff] [blame] | 114 | if (umoven(tcp, cur, sizeof_iov, (char *) &iov) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 115 | tprints("?"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 116 | failed = 1; |
| 117 | break; |
| 118 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 119 | tprints("{"); |
Dmitry V. Levin | 8884968 | 2011-06-13 22:58:44 +0000 | [diff] [blame] | 120 | if (decode_iov) |
| 121 | printstr(tcp, (long) iov_iov_base, iov_iov_len); |
| 122 | else |
| 123 | tprintf("%#lx", (long) iov_iov_base); |
Dmitry V. Levin | 4ebb4e3 | 2006-12-13 17:08:08 +0000 | [diff] [blame] | 124 | tprintf(", %lu}", (unsigned long)iov_iov_len); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 125 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 126 | tprints("]"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 127 | if (failed) |
| 128 | tprintf(" %#lx", addr); |
Dmitry V. Levin | 4ebb4e3 | 2006-12-13 17:08:08 +0000 | [diff] [blame] | 129 | #undef sizeof_iov |
| 130 | #undef iov_iov_base |
| 131 | #undef iov_iov_len |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 132 | } |
| 133 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 134 | int |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 135 | sys_readv(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 136 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 137 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 138 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 139 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 140 | } else { |
| 141 | if (syserror(tcp)) { |
| 142 | tprintf("%#lx, %lu", |
| 143 | tcp->u_arg[1], tcp->u_arg[2]); |
| 144 | return 0; |
| 145 | } |
Dmitry V. Levin | 8884968 | 2011-06-13 22:58:44 +0000 | [diff] [blame] | 146 | tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 147 | tprintf(", %lu", tcp->u_arg[2]); |
| 148 | } |
| 149 | return 0; |
| 150 | } |
| 151 | |
| 152 | int |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 153 | sys_writev(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 154 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 155 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 156 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 157 | tprints(", "); |
Dmitry V. Levin | 8884968 | 2011-06-13 22:58:44 +0000 | [diff] [blame] | 158 | tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 159 | tprintf(", %lu", tcp->u_arg[2]); |
| 160 | } |
| 161 | return 0; |
| 162 | } |
John Hughes | 1d08dcf | 2001-07-10 13:48:44 +0000 | [diff] [blame] | 163 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 164 | |
Roland McGrath | c0f8bbd | 2003-08-21 09:58:00 +0000 | [diff] [blame] | 165 | /* The SH4 ABI does allow long longs in odd-numbered registers, but |
| 166 | does not allow them to be split between registers and memory - and |
| 167 | there are only four argument registers for normal functions. As a |
| 168 | result pread takes an extra padding argument before the offset. This |
| 169 | was changed late in the 2.4 series (around 2.4.20). */ |
| 170 | #if defined(SH) |
| 171 | #define PREAD_OFFSET_ARG 4 |
| 172 | #else |
| 173 | #define PREAD_OFFSET_ARG 3 |
| 174 | #endif |
| 175 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 176 | int |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 177 | sys_pread(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 178 | { |
| 179 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 180 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 181 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 182 | } else { |
| 183 | if (syserror(tcp)) |
| 184 | tprintf("%#lx", tcp->u_arg[1]); |
| 185 | else |
| 186 | printstr(tcp, tcp->u_arg[1], tcp->u_rval); |
Andreas Schwab | b5600fc | 2009-11-04 17:08:34 +0100 | [diff] [blame] | 187 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 188 | printllval(tcp, "%llu", PREAD_OFFSET_ARG); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 189 | } |
| 190 | return 0; |
| 191 | } |
| 192 | |
| 193 | int |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 194 | sys_pwrite(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 195 | { |
| 196 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 197 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 198 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 199 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
Andreas Schwab | b5600fc | 2009-11-04 17:08:34 +0100 | [diff] [blame] | 200 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 201 | printllval(tcp, "%llu", PREAD_OFFSET_ARG); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 202 | } |
| 203 | return 0; |
| 204 | } |
| 205 | |
Damir Shayhutdinov | 3087dd6 | 2011-05-12 16:57:40 +0400 | [diff] [blame] | 206 | #if HAVE_SYS_UIO_H |
| 207 | int |
| 208 | sys_preadv(struct tcb *tcp) |
| 209 | { |
| 210 | if (entering(tcp)) { |
| 211 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 212 | tprints(", "); |
Damir Shayhutdinov | 3087dd6 | 2011-05-12 16:57:40 +0400 | [diff] [blame] | 213 | } else { |
| 214 | if (syserror(tcp)) { |
| 215 | tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]); |
| 216 | return 0; |
| 217 | } |
Dmitry V. Levin | 8884968 | 2011-06-13 22:58:44 +0000 | [diff] [blame] | 218 | tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1); |
Damir Shayhutdinov | 3087dd6 | 2011-05-12 16:57:40 +0400 | [diff] [blame] | 219 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 220 | printllval(tcp, "%llu", PREAD_OFFSET_ARG); |
| 221 | } |
| 222 | return 0; |
| 223 | } |
| 224 | |
| 225 | int |
| 226 | sys_pwritev(struct tcb *tcp) |
| 227 | { |
| 228 | if (entering(tcp)) { |
| 229 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 230 | tprints(", "); |
Dmitry V. Levin | 8884968 | 2011-06-13 22:58:44 +0000 | [diff] [blame] | 231 | tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1); |
Damir Shayhutdinov | 3087dd6 | 2011-05-12 16:57:40 +0400 | [diff] [blame] | 232 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 233 | printllval(tcp, "%llu", PREAD_OFFSET_ARG); |
| 234 | } |
| 235 | return 0; |
| 236 | } |
| 237 | #endif /* HAVE_SYS_UIO_H */ |
| 238 | |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 239 | int |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 240 | sys_sendfile(struct tcb *tcp) |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 241 | { |
| 242 | if (entering(tcp)) { |
| 243 | off_t offset; |
| 244 | |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 245 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 246 | tprints(", "); |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 247 | printfd(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 248 | tprints(", "); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 249 | if (!tcp->u_arg[2]) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 250 | tprints("NULL"); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 251 | else if (umove(tcp, tcp->u_arg[2], &offset) < 0) |
| 252 | tprintf("%#lx", tcp->u_arg[2]); |
| 253 | else |
H.J. Lu | 6ca2610 | 2012-02-03 10:12:10 -0800 | [diff] [blame] | 254 | #ifdef HAVE_LONG_LONG_OFF_T |
| 255 | tprintf("[%llu]", offset); |
| 256 | #else |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 257 | tprintf("[%lu]", offset); |
H.J. Lu | 6ca2610 | 2012-02-03 10:12:10 -0800 | [diff] [blame] | 258 | #endif |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 259 | tprintf(", %lu", tcp->u_arg[3]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 260 | } |
| 261 | return 0; |
| 262 | } |
| 263 | |
Dmitry V. Levin | d99e48c | 2011-10-11 17:07:05 +0000 | [diff] [blame] | 264 | static void |
| 265 | print_loff_t(struct tcb *tcp, long addr) |
| 266 | { |
| 267 | loff_t offset; |
| 268 | |
| 269 | if (!addr) |
| 270 | tprints("NULL"); |
| 271 | else if (umove(tcp, addr, &offset) < 0) |
| 272 | tprintf("%#lx", addr); |
| 273 | else |
| 274 | tprintf("[%llu]", (unsigned long long int) offset); |
| 275 | } |
| 276 | |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 277 | int |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 278 | sys_sendfile64(struct tcb *tcp) |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 279 | { |
| 280 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 281 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 282 | tprints(", "); |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 283 | printfd(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 284 | tprints(", "); |
Dmitry V. Levin | d99e48c | 2011-10-11 17:07:05 +0000 | [diff] [blame] | 285 | print_loff_t(tcp, tcp->u_arg[2]); |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 286 | tprintf(", %lu", tcp->u_arg[3]); |
| 287 | } |
| 288 | return 0; |
| 289 | } |
| 290 | |
Dmitry V. Levin | d99e48c | 2011-10-11 17:07:05 +0000 | [diff] [blame] | 291 | static const struct xlat splice_flags[] = { |
| 292 | #ifdef SPLICE_F_MOVE |
| 293 | { SPLICE_F_MOVE, "SPLICE_F_MOVE" }, |
| 294 | #endif |
| 295 | #ifdef SPLICE_F_NONBLOCK |
| 296 | { SPLICE_F_NONBLOCK, "SPLICE_F_NONBLOCK" }, |
| 297 | #endif |
| 298 | #ifdef SPLICE_F_MORE |
| 299 | { SPLICE_F_MORE, "SPLICE_F_MORE" }, |
| 300 | #endif |
| 301 | #ifdef SPLICE_F_GIFT |
| 302 | { SPLICE_F_GIFT, "SPLICE_F_GIFT" }, |
| 303 | #endif |
| 304 | { 0, NULL }, |
| 305 | }; |
| 306 | |
| 307 | int |
| 308 | sys_tee(struct tcb *tcp) |
| 309 | { |
| 310 | if (entering(tcp)) { |
| 311 | /* int fd_in */ |
| 312 | printfd(tcp, tcp->u_arg[0]); |
| 313 | tprints(", "); |
| 314 | /* int fd_out */ |
| 315 | printfd(tcp, tcp->u_arg[1]); |
| 316 | tprints(", "); |
| 317 | /* size_t len */ |
| 318 | tprintf("%lu, ", tcp->u_arg[2]); |
| 319 | /* unsigned int flags */ |
| 320 | printflags(splice_flags, tcp->u_arg[3], "SPLICE_F_???"); |
| 321 | } |
| 322 | return 0; |
| 323 | } |
| 324 | |
| 325 | int |
| 326 | sys_splice(struct tcb *tcp) |
| 327 | { |
| 328 | if (entering(tcp)) { |
| 329 | /* int fd_in */ |
| 330 | printfd(tcp, tcp->u_arg[0]); |
| 331 | tprints(", "); |
| 332 | /* loff_t *off_in */ |
| 333 | print_loff_t(tcp, tcp->u_arg[1]); |
| 334 | tprints(", "); |
| 335 | /* int fd_out */ |
| 336 | printfd(tcp, tcp->u_arg[2]); |
| 337 | tprints(", "); |
| 338 | /* loff_t *off_out */ |
| 339 | print_loff_t(tcp, tcp->u_arg[3]); |
| 340 | tprints(", "); |
| 341 | /* size_t len */ |
| 342 | tprintf("%lu, ", tcp->u_arg[4]); |
| 343 | /* unsigned int flags */ |
| 344 | printflags(splice_flags, tcp->u_arg[5], "SPLICE_F_???"); |
| 345 | } |
| 346 | return 0; |
| 347 | } |
| 348 | |
| 349 | int |
| 350 | sys_vmsplice(struct tcb *tcp) |
| 351 | { |
| 352 | if (entering(tcp)) { |
| 353 | /* int fd */ |
| 354 | printfd(tcp, tcp->u_arg[0]); |
| 355 | tprints(", "); |
| 356 | /* const struct iovec *iov, unsigned long nr_segs */ |
| 357 | tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1); |
Dmitry V. Levin | 0bfd744 | 2012-03-10 14:03:25 +0000 | [diff] [blame] | 358 | tprintf(", %lu, ", tcp->u_arg[2]); |
Dmitry V. Levin | d99e48c | 2011-10-11 17:07:05 +0000 | [diff] [blame] | 359 | /* unsigned int flags */ |
| 360 | printflags(splice_flags, tcp->u_arg[3], "SPLICE_F_???"); |
| 361 | } |
| 362 | return 0; |
| 363 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 364 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 365 | int |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 366 | sys_ioctl(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 367 | { |
Roland McGrath | ee36ce1 | 2004-09-04 03:53:10 +0000 | [diff] [blame] | 368 | const struct ioctlent *iop; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 369 | |
| 370 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 371 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 372 | tprints(", "); |
Roland McGrath | 2843a4e | 2003-11-14 02:54:03 +0000 | [diff] [blame] | 373 | iop = ioctl_lookup(tcp->u_arg[1]); |
| 374 | if (iop) { |
Denys Vlasenko | 5940e65 | 2011-09-01 09:55:05 +0200 | [diff] [blame] | 375 | tprints(iop->symbol); |
Roland McGrath | 2843a4e | 2003-11-14 02:54:03 +0000 | [diff] [blame] | 376 | while ((iop = ioctl_next_match(iop))) |
| 377 | tprintf(" or %s", iop->symbol); |
| 378 | } else |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 379 | tprintf("%#lx", tcp->u_arg[1]); |
| 380 | ioctl_decode(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 381 | } |
| 382 | else { |
Denys Vlasenko | 5d64581 | 2011-08-20 12:48:18 +0200 | [diff] [blame] | 383 | int ret = ioctl_decode(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 384 | if (!ret) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 385 | tprintf(", %#lx", tcp->u_arg[2]); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 386 | else |
| 387 | return ret - 1; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 388 | } |
| 389 | return 0; |
| 390 | } |