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> |
Elliott Hughes | 03a418e | 2018-06-15 13:11:40 -0700 | [diff] [blame] | 6 | * Copyright (c) 1999-2018 The strace developers. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 7 | * All rights reserved. |
| 8 | * |
| 9 | * Redistribution and use in source and binary forms, with or without |
| 10 | * modification, are permitted provided that the following conditions |
| 11 | * are met: |
| 12 | * 1. Redistributions of source code must retain the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer. |
| 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| 15 | * notice, this list of conditions and the following disclaimer in the |
| 16 | * documentation and/or other materials provided with the distribution. |
| 17 | * 3. The name of the author may not be used to endorse or promote products |
| 18 | * derived from this software without specific prior written permission. |
| 19 | * |
| 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 30 | */ |
| 31 | |
| 32 | #include "defs.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 33 | #include <fcntl.h> |
Dmitry V. Levin | b2fa2be | 2014-11-21 20:46:16 +0000 | [diff] [blame] | 34 | #include <sys/uio.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 35 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 36 | SYS_FUNC(read) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 37 | { |
| 38 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 39 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 40 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 41 | } else { |
| 42 | if (syserror(tcp)) |
Dmitry V. Levin | 43b5a1f | 2015-07-20 11:06:54 +0000 | [diff] [blame] | 43 | printaddr(tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 44 | else |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 45 | printstrn(tcp, tcp->u_arg[1], tcp->u_rval); |
| 46 | tprintf(", %" PRI_klu, tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 47 | } |
| 48 | return 0; |
| 49 | } |
| 50 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 51 | SYS_FUNC(write) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 52 | { |
Dmitry V. Levin | 1f255fd | 2015-07-20 11:19:30 +0000 | [diff] [blame] | 53 | printfd(tcp, tcp->u_arg[0]); |
| 54 | tprints(", "); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 55 | printstrn(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 56 | tprintf(", %" PRI_klu, tcp->u_arg[2]); |
Dmitry V. Levin | 1f255fd | 2015-07-20 11:19:30 +0000 | [diff] [blame] | 57 | |
| 58 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 59 | } |
| 60 | |
Dmitry V. Levin | 4ce3054 | 2016-05-07 22:54:04 +0000 | [diff] [blame] | 61 | struct print_iovec_config { |
Fabien Siron | 2a54d8b | 2016-06-22 13:27:03 +0000 | [diff] [blame] | 62 | enum iov_decode decode_iov; |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 63 | kernel_ulong_t data_size; |
Dmitry V. Levin | 4ce3054 | 2016-05-07 22:54:04 +0000 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | static bool |
| 67 | print_iovec(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data) |
| 68 | { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 69 | const kernel_ulong_t *iov; |
| 70 | kernel_ulong_t iov_buf[2], len; |
Dmitry V. Levin | 4ce3054 | 2016-05-07 22:54:04 +0000 | [diff] [blame] | 71 | struct print_iovec_config *c = data; |
| 72 | |
Elliott Hughes | dc75b01 | 2017-07-05 13:54:44 -0700 | [diff] [blame] | 73 | if (elem_size < sizeof(iov_buf)) { |
Dmitry V. Levin | 4ce3054 | 2016-05-07 22:54:04 +0000 | [diff] [blame] | 74 | iov_buf[0] = ((unsigned int *) elem_buf)[0]; |
| 75 | iov_buf[1] = ((unsigned int *) elem_buf)[1]; |
| 76 | iov = iov_buf; |
| 77 | } else { |
| 78 | iov = elem_buf; |
| 79 | } |
| 80 | |
Dmitry V. Levin | 4ddbfcf | 2016-07-13 22:54:55 +0000 | [diff] [blame] | 81 | tprints("{iov_base="); |
Dmitry V. Levin | 4ce3054 | 2016-05-07 22:54:04 +0000 | [diff] [blame] | 82 | |
Fabien Siron | 2a54d8b | 2016-06-22 13:27:03 +0000 | [diff] [blame] | 83 | len = iov[1]; |
| 84 | |
| 85 | switch (c->decode_iov) { |
| 86 | case IOV_DECODE_STR: |
| 87 | if (len > c->data_size) |
| 88 | len = c->data_size; |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 89 | if (c->data_size != (kernel_ulong_t) -1) |
Eugene Syromyatnikov | f3228d3 | 2016-09-29 15:57:55 +0300 | [diff] [blame] | 90 | c->data_size -= len; |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 91 | printstrn(tcp, iov[0], len); |
Fabien Siron | 2a54d8b | 2016-06-22 13:27:03 +0000 | [diff] [blame] | 92 | break; |
Fabien Siron | 2850f74 | 2016-07-06 15:49:22 +0000 | [diff] [blame] | 93 | case IOV_DECODE_NETLINK: |
| 94 | if (len > c->data_size) |
| 95 | len = c->data_size; |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 96 | if (c->data_size != (kernel_ulong_t) -1) |
Eugene Syromyatnikov | f3228d3 | 2016-09-29 15:57:55 +0300 | [diff] [blame] | 97 | c->data_size -= len; |
Elliott Hughes | dc75b01 | 2017-07-05 13:54:44 -0700 | [diff] [blame] | 98 | /* assume that the descriptor is 1st syscall argument */ |
| 99 | decode_netlink(tcp, tcp->u_arg[0], iov[0], len); |
Fabien Siron | 2850f74 | 2016-07-06 15:49:22 +0000 | [diff] [blame] | 100 | break; |
Fabien Siron | 2a54d8b | 2016-06-22 13:27:03 +0000 | [diff] [blame] | 101 | default: |
| 102 | printaddr(iov[0]); |
| 103 | break; |
Dmitry V. Levin | 4ce3054 | 2016-05-07 22:54:04 +0000 | [diff] [blame] | 104 | } |
| 105 | |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 106 | tprintf(", iov_len=%" PRI_klu "}", iov[1]); |
Dmitry V. Levin | 4ce3054 | 2016-05-07 22:54:04 +0000 | [diff] [blame] | 107 | |
| 108 | return true; |
| 109 | } |
| 110 | |
Denys Vlasenko | e0bc222 | 2012-04-28 14:26:18 +0200 | [diff] [blame] | 111 | /* |
| 112 | * data_size limits the cumulative size of printed data. |
| 113 | * Example: recvmsg returing a short read. |
| 114 | */ |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 115 | void |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 116 | tprint_iov_upto(struct tcb *const tcp, const kernel_ulong_t len, |
| 117 | const kernel_ulong_t addr, const enum iov_decode decode_iov, |
| 118 | const kernel_ulong_t data_size) |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 119 | { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 120 | kernel_ulong_t iov[2]; |
Elliott Hughes | dc75b01 | 2017-07-05 13:54:44 -0700 | [diff] [blame] | 121 | struct print_iovec_config config = { |
| 122 | .decode_iov = decode_iov, .data_size = data_size |
| 123 | }; |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 124 | |
Dmitry V. Levin | 4ce3054 | 2016-05-07 22:54:04 +0000 | [diff] [blame] | 125 | print_array(tcp, addr, len, iov, current_wordsize * 2, |
Elliott Hughes | 03a418e | 2018-06-15 13:11:40 -0700 | [diff] [blame] | 126 | tfetch_mem_ignore_syserror, print_iovec, &config); |
Denys Vlasenko | e0bc222 | 2012-04-28 14:26:18 +0200 | [diff] [blame] | 127 | } |
| 128 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 129 | SYS_FUNC(readv) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 130 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 131 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 132 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 133 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 134 | } else { |
Fabien Siron | 2a54d8b | 2016-06-22 13:27:03 +0000 | [diff] [blame] | 135 | tprint_iov_upto(tcp, tcp->u_arg[2], tcp->u_arg[1], |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 136 | syserror(tcp) ? IOV_DECODE_ADDR : |
Fabien Siron | 2a54d8b | 2016-06-22 13:27:03 +0000 | [diff] [blame] | 137 | IOV_DECODE_STR, tcp->u_rval); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 138 | tprintf(", %" PRI_klu, tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 139 | } |
| 140 | return 0; |
| 141 | } |
| 142 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 143 | SYS_FUNC(writev) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 144 | { |
Dmitry V. Levin | 1f255fd | 2015-07-20 11:19:30 +0000 | [diff] [blame] | 145 | printfd(tcp, tcp->u_arg[0]); |
| 146 | tprints(", "); |
Fabien Siron | 2a54d8b | 2016-06-22 13:27:03 +0000 | [diff] [blame] | 147 | tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], IOV_DECODE_STR); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 148 | tprintf(", %" PRI_klu, tcp->u_arg[2]); |
Dmitry V. Levin | 1f255fd | 2015-07-20 11:19:30 +0000 | [diff] [blame] | 149 | |
| 150 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 151 | } |
| 152 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 153 | SYS_FUNC(pread) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 154 | { |
| 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(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 158 | } else { |
| 159 | if (syserror(tcp)) |
Dmitry V. Levin | 43b5a1f | 2015-07-20 11:06:54 +0000 | [diff] [blame] | 160 | printaddr(tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 161 | else |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 162 | printstrn(tcp, tcp->u_arg[1], tcp->u_rval); |
| 163 | tprintf(", %" PRI_klu ", ", tcp->u_arg[2]); |
Eugene Syromyatnikov | 714a162 | 2016-08-20 17:02:55 +0300 | [diff] [blame] | 164 | printllval(tcp, "%lld", 3); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 165 | } |
| 166 | return 0; |
| 167 | } |
| 168 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 169 | SYS_FUNC(pwrite) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 170 | { |
Dmitry V. Levin | 1f255fd | 2015-07-20 11:19:30 +0000 | [diff] [blame] | 171 | printfd(tcp, tcp->u_arg[0]); |
| 172 | tprints(", "); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 173 | printstrn(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 174 | tprintf(", %" PRI_klu ", ", tcp->u_arg[2]); |
Eugene Syromyatnikov | 714a162 | 2016-08-20 17:02:55 +0300 | [diff] [blame] | 175 | printllval(tcp, "%lld", 3); |
Dmitry V. Levin | 1f255fd | 2015-07-20 11:19:30 +0000 | [diff] [blame] | 176 | |
| 177 | return RVAL_DECODED; |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 178 | } |
| 179 | |
Dmitry V. Levin | 3c49b02 | 2014-08-07 00:07:28 +0000 | [diff] [blame] | 180 | static void |
Dmitry V. Levin | d461151 | 2016-03-30 03:54:21 +0000 | [diff] [blame] | 181 | print_lld_from_low_high_val(struct tcb *tcp, int arg) |
Dmitry V. Levin | 3c49b02 | 2014-08-07 00:07:28 +0000 | [diff] [blame] | 182 | { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 183 | #if SIZEOF_KERNEL_LONG_T > 4 |
| 184 | # ifndef current_klongsize |
| 185 | if (current_klongsize < SIZEOF_KERNEL_LONG_T) { |
| 186 | tprintf("%" PRI_kld, (tcp->u_arg[arg + 1] << 32) |
| 187 | | tcp->u_arg[arg]); |
Dmitry V. Levin | b0c5113 | 2016-06-17 16:12:13 +0000 | [diff] [blame] | 188 | } else |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 189 | # endif /* !current_klongsize */ |
Dmitry V. Levin | b0c5113 | 2016-06-17 16:12:13 +0000 | [diff] [blame] | 190 | { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 191 | tprintf("%" PRI_kld, tcp->u_arg[arg]); |
Dmitry V. Levin | b0c5113 | 2016-06-17 16:12:13 +0000 | [diff] [blame] | 192 | } |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 193 | #else /* SIZEOF_KERNEL_LONG_T == 4 */ |
Dmitry V. Levin | d461151 | 2016-03-30 03:54:21 +0000 | [diff] [blame] | 194 | tprintf("%lld", |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 195 | ((long long) tcp->u_arg[arg + 1] << 32) |
| 196 | | ((long long) tcp->u_arg[arg])); |
Dmitry V. Levin | 3c49b02 | 2014-08-07 00:07:28 +0000 | [diff] [blame] | 197 | #endif |
| 198 | } |
| 199 | |
Dmitry V. Levin | a6dd094 | 2016-05-11 00:42:10 +0000 | [diff] [blame] | 200 | #include "xlat/rwf_flags.h" |
| 201 | |
| 202 | static int |
| 203 | do_preadv(struct tcb *tcp, const int flags_arg) |
Damir Shayhutdinov | 3087dd6 | 2011-05-12 16:57:40 +0400 | [diff] [blame] | 204 | { |
| 205 | if (entering(tcp)) { |
| 206 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 207 | tprints(", "); |
Damir Shayhutdinov | 3087dd6 | 2011-05-12 16:57:40 +0400 | [diff] [blame] | 208 | } else { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 209 | kernel_ulong_t len = |
| 210 | truncate_kulong_to_current_wordsize(tcp->u_arg[2]); |
| 211 | |
| 212 | tprint_iov_upto(tcp, len, tcp->u_arg[1], |
| 213 | syserror(tcp) ? IOV_DECODE_ADDR : |
| 214 | IOV_DECODE_STR, tcp->u_rval); |
| 215 | tprintf(", %" PRI_klu ", ", len); |
Dmitry V. Levin | d461151 | 2016-03-30 03:54:21 +0000 | [diff] [blame] | 216 | print_lld_from_low_high_val(tcp, 3); |
Dmitry V. Levin | a6dd094 | 2016-05-11 00:42:10 +0000 | [diff] [blame] | 217 | if (flags_arg >= 0) { |
| 218 | tprints(", "); |
| 219 | printflags(rwf_flags, tcp->u_arg[flags_arg], "RWF_???"); |
| 220 | } |
Damir Shayhutdinov | 3087dd6 | 2011-05-12 16:57:40 +0400 | [diff] [blame] | 221 | } |
| 222 | return 0; |
| 223 | } |
| 224 | |
Dmitry V. Levin | a6dd094 | 2016-05-11 00:42:10 +0000 | [diff] [blame] | 225 | SYS_FUNC(preadv) |
| 226 | { |
| 227 | return do_preadv(tcp, -1); |
| 228 | } |
| 229 | |
Dmitry V. Levin | a6dd094 | 2016-05-11 00:42:10 +0000 | [diff] [blame] | 230 | static int |
| 231 | do_pwritev(struct tcb *tcp, const int flags_arg) |
Damir Shayhutdinov | 3087dd6 | 2011-05-12 16:57:40 +0400 | [diff] [blame] | 232 | { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 233 | kernel_ulong_t len = |
| 234 | truncate_kulong_to_current_wordsize(tcp->u_arg[2]); |
| 235 | |
Dmitry V. Levin | 1f255fd | 2015-07-20 11:19:30 +0000 | [diff] [blame] | 236 | printfd(tcp, tcp->u_arg[0]); |
| 237 | tprints(", "); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 238 | tprint_iov(tcp, len, tcp->u_arg[1], IOV_DECODE_STR); |
| 239 | tprintf(", %" PRI_klu ", ", len); |
Dmitry V. Levin | d461151 | 2016-03-30 03:54:21 +0000 | [diff] [blame] | 240 | print_lld_from_low_high_val(tcp, 3); |
Dmitry V. Levin | a6dd094 | 2016-05-11 00:42:10 +0000 | [diff] [blame] | 241 | if (flags_arg >= 0) { |
| 242 | tprints(", "); |
| 243 | printflags(rwf_flags, tcp->u_arg[flags_arg], "RWF_???"); |
| 244 | } |
Dmitry V. Levin | 1f255fd | 2015-07-20 11:19:30 +0000 | [diff] [blame] | 245 | |
| 246 | return RVAL_DECODED; |
Damir Shayhutdinov | 3087dd6 | 2011-05-12 16:57:40 +0400 | [diff] [blame] | 247 | } |
Damir Shayhutdinov | 3087dd6 | 2011-05-12 16:57:40 +0400 | [diff] [blame] | 248 | |
Dmitry V. Levin | a6dd094 | 2016-05-11 00:42:10 +0000 | [diff] [blame] | 249 | SYS_FUNC(pwritev) |
| 250 | { |
| 251 | return do_pwritev(tcp, -1); |
| 252 | } |
| 253 | |
Elliott Hughes | 39bac05 | 2017-05-25 16:56:11 -0700 | [diff] [blame] | 254 | /* |
| 255 | * x32 is the only architecture where preadv2 takes 5 arguments |
| 256 | * instead of 6, see preadv64v2 in kernel sources. |
| 257 | * Likewise, x32 is the only architecture where pwritev2 takes 5 arguments |
| 258 | * instead of 6, see pwritev64v2 in kernel sources. |
| 259 | */ |
| 260 | |
| 261 | #if defined X86_64 |
| 262 | # define PREADV2_PWRITEV2_FLAGS_ARG_NO (current_personality == 2 ? 4 : 5) |
| 263 | #elif defined X32 |
| 264 | # define PREADV2_PWRITEV2_FLAGS_ARG_NO (current_personality == 0 ? 4 : 5) |
| 265 | #else |
| 266 | # define PREADV2_PWRITEV2_FLAGS_ARG_NO 5 |
| 267 | #endif |
| 268 | |
| 269 | SYS_FUNC(preadv2) |
| 270 | { |
| 271 | return do_preadv(tcp, PREADV2_PWRITEV2_FLAGS_ARG_NO); |
| 272 | } |
| 273 | |
Dmitry V. Levin | a6dd094 | 2016-05-11 00:42:10 +0000 | [diff] [blame] | 274 | SYS_FUNC(pwritev2) |
| 275 | { |
Elliott Hughes | 39bac05 | 2017-05-25 16:56:11 -0700 | [diff] [blame] | 276 | return do_pwritev(tcp, PREADV2_PWRITEV2_FLAGS_ARG_NO); |
Dmitry V. Levin | a6dd094 | 2016-05-11 00:42:10 +0000 | [diff] [blame] | 277 | } |
| 278 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 279 | #include "xlat/splice_flags.h" |
Dmitry V. Levin | d99e48c | 2011-10-11 17:07:05 +0000 | [diff] [blame] | 280 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 281 | SYS_FUNC(tee) |
Dmitry V. Levin | d99e48c | 2011-10-11 17:07:05 +0000 | [diff] [blame] | 282 | { |
Dmitry V. Levin | 1f255fd | 2015-07-20 11:19:30 +0000 | [diff] [blame] | 283 | /* int fd_in */ |
| 284 | printfd(tcp, tcp->u_arg[0]); |
| 285 | tprints(", "); |
| 286 | /* int fd_out */ |
| 287 | printfd(tcp, tcp->u_arg[1]); |
| 288 | tprints(", "); |
| 289 | /* size_t len */ |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 290 | tprintf("%" PRI_klu ", ", tcp->u_arg[2]); |
Dmitry V. Levin | 1f255fd | 2015-07-20 11:19:30 +0000 | [diff] [blame] | 291 | /* unsigned int flags */ |
| 292 | printflags(splice_flags, tcp->u_arg[3], "SPLICE_F_???"); |
| 293 | |
| 294 | return RVAL_DECODED; |
Dmitry V. Levin | d99e48c | 2011-10-11 17:07:05 +0000 | [diff] [blame] | 295 | } |
| 296 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 297 | SYS_FUNC(splice) |
Dmitry V. Levin | d99e48c | 2011-10-11 17:07:05 +0000 | [diff] [blame] | 298 | { |
Dmitry V. Levin | 1f255fd | 2015-07-20 11:19:30 +0000 | [diff] [blame] | 299 | /* int fd_in */ |
| 300 | printfd(tcp, tcp->u_arg[0]); |
| 301 | tprints(", "); |
| 302 | /* loff_t *off_in */ |
Dmitry V. Levin | 16a52b4 | 2016-02-13 22:31:30 +0000 | [diff] [blame] | 303 | printnum_int64(tcp, tcp->u_arg[1], "%" PRId64); |
Dmitry V. Levin | 1f255fd | 2015-07-20 11:19:30 +0000 | [diff] [blame] | 304 | tprints(", "); |
| 305 | /* int fd_out */ |
| 306 | printfd(tcp, tcp->u_arg[2]); |
| 307 | tprints(", "); |
| 308 | /* loff_t *off_out */ |
Dmitry V. Levin | 16a52b4 | 2016-02-13 22:31:30 +0000 | [diff] [blame] | 309 | printnum_int64(tcp, tcp->u_arg[3], "%" PRId64); |
Dmitry V. Levin | 1f255fd | 2015-07-20 11:19:30 +0000 | [diff] [blame] | 310 | tprints(", "); |
| 311 | /* size_t len */ |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 312 | tprintf("%" PRI_klu ", ", tcp->u_arg[4]); |
Dmitry V. Levin | 1f255fd | 2015-07-20 11:19:30 +0000 | [diff] [blame] | 313 | /* unsigned int flags */ |
| 314 | printflags(splice_flags, tcp->u_arg[5], "SPLICE_F_???"); |
| 315 | |
| 316 | return RVAL_DECODED; |
Dmitry V. Levin | d99e48c | 2011-10-11 17:07:05 +0000 | [diff] [blame] | 317 | } |
| 318 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 319 | SYS_FUNC(vmsplice) |
Dmitry V. Levin | d99e48c | 2011-10-11 17:07:05 +0000 | [diff] [blame] | 320 | { |
Dmitry V. Levin | 1f255fd | 2015-07-20 11:19:30 +0000 | [diff] [blame] | 321 | /* int fd */ |
| 322 | printfd(tcp, tcp->u_arg[0]); |
| 323 | tprints(", "); |
| 324 | /* const struct iovec *iov, unsigned long nr_segs */ |
Fabien Siron | 2a54d8b | 2016-06-22 13:27:03 +0000 | [diff] [blame] | 325 | tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], IOV_DECODE_STR); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 326 | tprintf(", %" PRI_klu ", ", tcp->u_arg[2]); |
Dmitry V. Levin | 1f255fd | 2015-07-20 11:19:30 +0000 | [diff] [blame] | 327 | /* unsigned int flags */ |
| 328 | printflags(splice_flags, tcp->u_arg[3], "SPLICE_F_???"); |
| 329 | |
| 330 | return RVAL_DECODED; |
Dmitry V. Levin | d99e48c | 2011-10-11 17:07:05 +0000 | [diff] [blame] | 331 | } |