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