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 | 39bac05 | 2017-05-25 16:56:11 -0700 | [diff] [blame] | 6 | * Copyright (c) 1999-2017 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 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 34 | SYS_FUNC(close) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 35 | { |
Dmitry V. Levin | df0c18c | 2015-07-20 16:59:50 +0000 | [diff] [blame] | 36 | printfd(tcp, tcp->u_arg[0]); |
| 37 | |
| 38 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 39 | } |
| 40 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 41 | SYS_FUNC(dup) |
Zubin Mithra | 64aa1b1 | 2014-06-04 08:30:41 +0530 | [diff] [blame] | 42 | { |
Dmitry V. Levin | df0c18c | 2015-07-20 16:59:50 +0000 | [diff] [blame] | 43 | printfd(tcp, tcp->u_arg[0]); |
| 44 | |
| 45 | return RVAL_DECODED | RVAL_FD; |
Zubin Mithra | 64aa1b1 | 2014-06-04 08:30:41 +0530 | [diff] [blame] | 46 | } |
| 47 | |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 48 | static int |
| 49 | do_dup2(struct tcb *tcp, int flags_arg) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 50 | { |
Dmitry V. Levin | df0c18c | 2015-07-20 16:59:50 +0000 | [diff] [blame] | 51 | printfd(tcp, tcp->u_arg[0]); |
| 52 | tprints(", "); |
| 53 | printfd(tcp, tcp->u_arg[1]); |
| 54 | if (flags_arg >= 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 55 | tprints(", "); |
Dmitry V. Levin | df0c18c | 2015-07-20 16:59:50 +0000 | [diff] [blame] | 56 | printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 57 | } |
Dmitry V. Levin | df0c18c | 2015-07-20 16:59:50 +0000 | [diff] [blame] | 58 | |
| 59 | return RVAL_DECODED | RVAL_FD; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 60 | } |
| 61 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 62 | SYS_FUNC(dup2) |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 63 | { |
| 64 | return do_dup2(tcp, -1); |
| 65 | } |
| 66 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 67 | SYS_FUNC(dup3) |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 68 | { |
| 69 | return do_dup2(tcp, 2); |
| 70 | } |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 71 | |
Dmitry V. Levin | c2982b5 | 2013-11-05 23:00:22 +0000 | [diff] [blame] | 72 | static int |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 73 | decode_select(struct tcb *const tcp, const kernel_ulong_t *const args, |
| 74 | void (*const print_tv_ts) (struct tcb *, kernel_ulong_t), |
| 75 | const char * (*const sprint_tv_ts) (struct tcb *, kernel_ulong_t)) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 76 | { |
Denys Vlasenko | ad5155a | 2011-09-01 18:18:04 +0200 | [diff] [blame] | 77 | int i, j; |
Denys Vlasenko | 1f65c3c | 2013-11-05 16:20:16 +0100 | [diff] [blame] | 78 | int nfds, fdsize; |
Dmitry V. Levin | 6522f13 | 2014-09-09 22:42:12 +0000 | [diff] [blame] | 79 | fd_set *fds = NULL; |
Dmitry V. Levin | 30145dd | 2010-09-06 22:08:24 +0000 | [diff] [blame] | 80 | const char *sep; |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 81 | kernel_ulong_t addr; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 82 | |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 83 | /* Kernel truncates args[0] to int, we do the same. */ |
Dmitry V. Levin | f3696b3 | 2013-11-05 22:46:43 +0000 | [diff] [blame] | 84 | nfds = (int) args[0]; |
| 85 | |
| 86 | /* Kernel rejects negative nfds, so we don't parse it either. */ |
Dmitry V. Levin | 6522f13 | 2014-09-09 22:42:12 +0000 | [diff] [blame] | 87 | if (nfds < 0) |
Dmitry V. Levin | f3696b3 | 2013-11-05 22:46:43 +0000 | [diff] [blame] | 88 | nfds = 0; |
Dmitry V. Levin | 6522f13 | 2014-09-09 22:42:12 +0000 | [diff] [blame] | 89 | |
Denys Vlasenko | 79a79ea | 2011-09-01 16:35:44 +0200 | [diff] [blame] | 90 | /* Beware of select(2^31-1, NULL, NULL, NULL) and similar... */ |
Dmitry V. Levin | f3696b3 | 2013-11-05 22:46:43 +0000 | [diff] [blame] | 91 | if (nfds > 1024*1024) |
| 92 | nfds = 1024*1024; |
| 93 | |
| 94 | /* |
| 95 | * We had bugs a-la "while (j < args[0])" and "umoven(args[0])" below. |
Dr. David Alan Gilbert | 025f108 | 2013-11-05 11:54:51 +0100 | [diff] [blame] | 96 | * Instead of args[0], use nfds for fd count, fdsize for array lengths. |
| 97 | */ |
Denys Vlasenko | b338f2d | 2013-11-09 20:40:31 +0100 | [diff] [blame] | 98 | fdsize = (((nfds + 7) / 8) + current_wordsize-1) & -current_wordsize; |
Denys Vlasenko | 79a79ea | 2011-09-01 16:35:44 +0200 | [diff] [blame] | 99 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 100 | if (entering(tcp)) { |
Dmitry V. Levin | f3696b3 | 2013-11-05 22:46:43 +0000 | [diff] [blame] | 101 | tprintf("%d", (int) args[0]); |
| 102 | |
Dmitry V. Levin | 3e9d71f | 2015-05-25 20:41:02 +0000 | [diff] [blame] | 103 | if (verbose(tcp) && fdsize > 0) |
Dmitry V. Levin | e6019fd | 2015-07-20 16:44:51 +0000 | [diff] [blame] | 104 | fds = malloc(fdsize); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 105 | for (i = 0; i < 3; i++) { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 106 | addr = args[i+1]; |
Dmitry V. Levin | e6019fd | 2015-07-20 16:44:51 +0000 | [diff] [blame] | 107 | tprints(", "); |
Dmitry V. Levin | 2fc5d80 | 2015-01-28 01:26:04 +0000 | [diff] [blame] | 108 | if (!fds) { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 109 | printaddr(addr); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 110 | continue; |
| 111 | } |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 112 | if (umoven_or_printaddr(tcp, addr, fdsize, fds)) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 113 | continue; |
Dmitry V. Levin | e6019fd | 2015-07-20 16:44:51 +0000 | [diff] [blame] | 114 | tprints("["); |
Denys Vlasenko | b338f2d | 2013-11-09 20:40:31 +0100 | [diff] [blame] | 115 | for (j = 0, sep = "";; j++) { |
| 116 | j = next_set_bit(fds, j, nfds); |
| 117 | if (j < 0) |
| 118 | break; |
| 119 | tprints(sep); |
| 120 | printfd(tcp, j); |
| 121 | sep = " "; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 122 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 123 | tprints("]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 124 | } |
Roland McGrath | e85aaa4 | 2005-02-06 01:55:12 +0000 | [diff] [blame] | 125 | free(fds); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 126 | tprints(", "); |
Dmitry V. Levin | 4cb5ccc | 2015-09-18 18:02:50 +0000 | [diff] [blame] | 127 | print_tv_ts(tcp, args[4]); |
Dmitry V. Levin | df0c18c | 2015-07-20 16:59:50 +0000 | [diff] [blame] | 128 | } else { |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 129 | static char outstr[1024]; |
| 130 | char *outptr; |
| 131 | #define end_outstr (outstr + sizeof(outstr)) |
Dmitry V. Levin | f3696b3 | 2013-11-05 22:46:43 +0000 | [diff] [blame] | 132 | int ready_fds; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 133 | |
| 134 | if (syserror(tcp)) |
| 135 | return 0; |
| 136 | |
Dr. David Alan Gilbert | 025f108 | 2013-11-05 11:54:51 +0100 | [diff] [blame] | 137 | ready_fds = tcp->u_rval; |
| 138 | if (ready_fds == 0) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 139 | tcp->auxstr = "Timeout"; |
| 140 | return RVAL_STR; |
| 141 | } |
Roland McGrath | e85aaa4 | 2005-02-06 01:55:12 +0000 | [diff] [blame] | 142 | |
Dmitry V. Levin | e6019fd | 2015-07-20 16:44:51 +0000 | [diff] [blame] | 143 | fds = malloc(fdsize); |
Roland McGrath | e85aaa4 | 2005-02-06 01:55:12 +0000 | [diff] [blame] | 144 | |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 145 | outptr = outstr; |
| 146 | sep = ""; |
Dmitry V. Levin | f3696b3 | 2013-11-05 22:46:43 +0000 | [diff] [blame] | 147 | for (i = 0; i < 3 && ready_fds > 0; i++) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 148 | int first = 1; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 149 | |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 150 | addr = args[i+1]; |
| 151 | if (!addr || !fds || umoven(tcp, addr, fdsize, fds) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 152 | continue; |
Denys Vlasenko | b338f2d | 2013-11-09 20:40:31 +0100 | [diff] [blame] | 153 | for (j = 0;; j++) { |
| 154 | j = next_set_bit(fds, j, nfds); |
| 155 | if (j < 0) |
| 156 | break; |
| 157 | /* +2 chars needed at the end: ']',NUL */ |
| 158 | if (outptr < end_outstr - (sizeof(", except [") + sizeof(int)*3 + 2)) { |
| 159 | if (first) { |
| 160 | outptr += sprintf(outptr, "%s%s [%u", |
| 161 | sep, |
| 162 | i == 0 ? "in" : i == 1 ? "out" : "except", |
| 163 | j |
| 164 | ); |
| 165 | first = 0; |
| 166 | sep = ", "; |
Elliott Hughes | dc75b01 | 2017-07-05 13:54:44 -0700 | [diff] [blame^] | 167 | } else { |
Denys Vlasenko | b338f2d | 2013-11-09 20:40:31 +0100 | [diff] [blame] | 168 | outptr += sprintf(outptr, " %u", j); |
| 169 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 170 | } |
Denys Vlasenko | b338f2d | 2013-11-09 20:40:31 +0100 | [diff] [blame] | 171 | if (--ready_fds == 0) |
| 172 | break; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 173 | } |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 174 | if (outptr != outstr) |
| 175 | *outptr++ = ']'; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 176 | } |
Roland McGrath | e85aaa4 | 2005-02-06 01:55:12 +0000 | [diff] [blame] | 177 | free(fds); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 178 | /* This contains no useful information on SunOS. */ |
| 179 | if (args[4]) { |
Dmitry V. Levin | 4cb5ccc | 2015-09-18 18:02:50 +0000 | [diff] [blame] | 180 | const char *str = sprint_tv_ts(tcp, args[4]); |
| 181 | if (outptr + sizeof("left ") + strlen(sep) + strlen(str) < end_outstr) { |
| 182 | outptr += sprintf(outptr, "%sleft %s", sep, str); |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 183 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 184 | } |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 185 | *outptr = '\0'; |
Denys Vlasenko | 1161725 | 2011-09-01 11:27:37 +0200 | [diff] [blame] | 186 | tcp->auxstr = outstr; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 187 | return RVAL_STR; |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 188 | #undef end_outstr |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 189 | } |
| 190 | return 0; |
| 191 | } |
| 192 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 193 | SYS_FUNC(oldselect) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 194 | { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 195 | kernel_ulong_t select_args[5]; |
Elvira Khabirova | c44df3e | 2015-07-29 21:38:54 +0300 | [diff] [blame] | 196 | unsigned int oldselect_args[5]; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 197 | |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 198 | if (sizeof(*select_args) == sizeof(*oldselect_args)) { |
| 199 | if (umove_or_printaddr(tcp, tcp->u_arg[0], &select_args)) { |
| 200 | return 0; |
| 201 | } |
| 202 | } else { |
| 203 | unsigned int i; |
| 204 | |
| 205 | if (umove_or_printaddr(tcp, tcp->u_arg[0], &oldselect_args)) { |
| 206 | return 0; |
| 207 | } |
| 208 | |
| 209 | for (i = 0; i < 5; ++i) { |
| 210 | select_args[i] = oldselect_args[i]; |
| 211 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 212 | } |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 213 | |
| 214 | return decode_select(tcp, select_args, print_timeval, sprint_timeval); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 215 | } |
| 216 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 217 | #ifdef ALPHA |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 218 | SYS_FUNC(osf_select) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 219 | { |
Dmitry V. Levin | 4cb5ccc | 2015-09-18 18:02:50 +0000 | [diff] [blame] | 220 | return decode_select(tcp, tcp->u_arg, print_timeval32, sprint_timeval32); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 221 | } |
| 222 | #endif |
| 223 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 224 | SYS_FUNC(select) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 225 | { |
Dmitry V. Levin | 4cb5ccc | 2015-09-18 18:02:50 +0000 | [diff] [blame] | 226 | return decode_select(tcp, tcp->u_arg, print_timeval, sprint_timeval); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 227 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 228 | |
Dmitry V. Levin | 4408e85 | 2015-11-27 04:37:46 +0000 | [diff] [blame] | 229 | static int |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 230 | umove_kulong_array_or_printaddr(struct tcb *const tcp, const kernel_ulong_t addr, |
| 231 | kernel_ulong_t *const ptr, const size_t n) |
Dmitry V. Levin | 4408e85 | 2015-11-27 04:37:46 +0000 | [diff] [blame] | 232 | { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 233 | #ifndef current_klongsize |
| 234 | if (current_klongsize < sizeof(*ptr)) { |
Dmitry V. Levin | 4408e85 | 2015-11-27 04:37:46 +0000 | [diff] [blame] | 235 | uint32_t ptr32[n]; |
| 236 | int r = umove_or_printaddr(tcp, addr, &ptr32); |
| 237 | if (!r) { |
| 238 | size_t i; |
| 239 | |
| 240 | for (i = 0; i < n; ++i) |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 241 | ptr[i] = ptr32[i]; |
Dmitry V. Levin | 4408e85 | 2015-11-27 04:37:46 +0000 | [diff] [blame] | 242 | } |
| 243 | return r; |
| 244 | } |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 245 | #endif /* !current_klongsize */ |
Dmitry V. Levin | 4408e85 | 2015-11-27 04:37:46 +0000 | [diff] [blame] | 246 | return umoven_or_printaddr(tcp, addr, n * sizeof(*ptr), ptr); |
| 247 | } |
| 248 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 249 | SYS_FUNC(pselect6) |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 250 | { |
Dmitry V. Levin | 4cb5ccc | 2015-09-18 18:02:50 +0000 | [diff] [blame] | 251 | int rc = decode_select(tcp, tcp->u_arg, print_timespec, sprint_timespec); |
Roland McGrath | fe10aa7 | 2007-11-01 21:52:20 +0000 | [diff] [blame] | 252 | if (entering(tcp)) { |
Dmitry V. Levin | 4408e85 | 2015-11-27 04:37:46 +0000 | [diff] [blame] | 253 | kernel_ulong_t data[2]; |
Dmitry V. Levin | e6019fd | 2015-07-20 16:44:51 +0000 | [diff] [blame] | 254 | |
| 255 | tprints(", "); |
Dmitry V. Levin | 4408e85 | 2015-11-27 04:37:46 +0000 | [diff] [blame] | 256 | if (!umove_kulong_array_or_printaddr(tcp, tcp->u_arg[5], |
| 257 | data, ARRAY_SIZE(data))) { |
Dmitry V. Levin | e6019fd | 2015-07-20 16:44:51 +0000 | [diff] [blame] | 258 | tprints("{"); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 259 | /* NB: kernel requires data[1] == NSIG_BYTES */ |
| 260 | print_sigset_addr_len(tcp, data[0], data[1]); |
| 261 | tprintf(", %" PRI_klu "}", data[1]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 262 | } |
| 263 | } |
Dmitry V. Levin | 4408e85 | 2015-11-27 04:37:46 +0000 | [diff] [blame] | 264 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 265 | return rc; |
| 266 | } |