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>
5 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
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.
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.
32 #include <linux/aio_abi.h>
37 tprintf("%u, ", (unsigned int) tcp->u_arg[0]);
39 printnum_ulong(tcp, tcp->u_arg[1]);
45 tprintf("%lu", tcp->u_arg[0]);
51 SUB_NONE, SUB_COMMON, SUB_VECTOR
55 tprint_lio_opcode(unsigned cmd)
61 { "pread", SUB_COMMON },
62 { "pwrite", SUB_COMMON },
63 { "fsync", SUB_NONE },
64 { "fdsync", SUB_NONE },
65 { "preadx", SUB_NONE },
68 { "preadv", SUB_VECTOR },
69 { "pwritev", SUB_VECTOR },
72 if (cmd < ARRAY_SIZE(cmds)) {
73 tprints(cmds[cmd].name);
76 tprintf("%u /* SUB_??? */", cmd);
81 print_common_flags(const struct iocb *cb)
83 /* IOCB_FLAG_RESFD is available since v2.6.22-rc1~47 */
84 #ifdef IOCB_FLAG_RESFD
85 if (cb->aio_flags & IOCB_FLAG_RESFD)
86 tprintf(", resfd=%d", cb->aio_resfd);
87 if (cb->aio_flags & ~IOCB_FLAG_RESFD)
88 tprintf(", flags=%x", cb->aio_flags);
93 iocb_is_valid(const struct iocb *cb)
95 return cb->aio_buf == (unsigned long) cb->aio_buf &&
96 cb->aio_nbytes == (size_t) cb->aio_nbytes &&
97 (ssize_t) cb->aio_nbytes >= 0;
101 print_iocb_header(const struct iocb *cb)
106 tprintf("data=%#" PRIx64 ", ",
107 (uint64_t) cb->aio_data);
110 tprintf("key=%u, ", cb->aio_key);
112 sub = tprint_lio_opcode(cb->aio_lio_opcode);
114 tprintf(", reqprio=%hd", cb->aio_reqprio);
116 tprintf(", fildes=%d", cb->aio_fildes);
122 print_iocb(struct tcb *tcp, const struct iocb *cb)
124 enum iocb_sub sub = print_iocb_header(cb);
128 if (cb->aio_lio_opcode == 1 && iocb_is_valid(cb)) {
130 printstr(tcp, (unsigned long) cb->aio_buf,
131 (unsigned long) cb->aio_nbytes);
133 tprintf(", buf=%#" PRIx64, (uint64_t) cb->aio_buf);
135 tprintf(", nbytes=%" PRIu64 ", offset=%" PRId64,
136 (uint64_t) cb->aio_nbytes, (int64_t) cb->aio_offset);
137 print_common_flags(cb);
140 if (iocb_is_valid(cb)) {
142 tprint_iov(tcp, cb->aio_nbytes, cb->aio_buf,
143 cb->aio_lio_opcode == 8
147 tprintf(", buf=%#" PRIx64 ", nbytes=%" PRIu64,
148 (uint64_t) cb->aio_buf,
149 (uint64_t) cb->aio_nbytes);
151 tprintf(", offset=%" PRId64, (int64_t) cb->aio_offset);
152 print_common_flags(cb);
160 print_iocbp(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
165 if (elem_size < sizeof(long)) {
166 addr = * (unsigned int *) elem_buf;
168 addr = * (unsigned long *) elem_buf;
172 if (!umove_or_printaddr(tcp, addr, &cb))
173 print_iocb(tcp, &cb);
181 const long nr = widen_to_long(tcp->u_arg[1]);
182 const unsigned long addr = tcp->u_arg[2];
185 tprintf("%lu, %ld, ", tcp->u_arg[0], nr);
190 print_array(tcp, addr, nr, &iocbp, current_wordsize,
191 umoven_or_printaddr, print_iocbp, 0);
197 print_io_event(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
199 struct io_event *event = elem_buf;
201 tprintf("{data=%#" PRIx64 ", obj=%#" PRIx64
202 ", res=%" PRId64 ", res2=%" PRId64 "}",
203 (uint64_t) event->data, (uint64_t) event->obj,
204 (int64_t) event->res, (int64_t) event->res2);
212 tprintf("%lu, ", tcp->u_arg[0]);
215 if (!umove_or_printaddr(tcp, tcp->u_arg[1], &cb)) {
217 print_iocb_header(&cb);
222 struct io_event event;
224 if (!umove_or_printaddr(tcp, tcp->u_arg[2], &event))
225 print_io_event(tcp, &event, sizeof(event), 0);
230 SYS_FUNC(io_getevents)
233 tprintf("%lu, %ld, %ld, ",
235 widen_to_long(tcp->u_arg[1]),
236 widen_to_long(tcp->u_arg[2]));
239 print_array(tcp, tcp->u_arg[3], tcp->u_rval, &buf, sizeof(buf),
240 umoven_or_printaddr, print_io_event, 0);
243 * Since the timeout parameter is read by the kernel
244 * on entering syscall, it has to be decoded the same way
245 * whether the syscall has failed or not.
247 temporarily_clear_syserror(tcp);
248 print_timespec(tcp, tcp->u_arg[4]);
249 restore_cleared_syserror(tcp);