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.
36 /* Not defined in libaio.h */
38 # define IOCB_RESFD (1 << 0)
44 tprintf("%ld, ", tcp->u_arg[0]);
47 tprintf("0x%0lx", tcp->u_arg[1]);
49 unsigned long user_id;
50 if (umove(tcp, tcp->u_arg[1], &user_id) == 0)
51 tprintf("{%lu}", user_id);
62 tprintf("%lu", tcp->u_arg[0]);
69 SUB_NONE, SUB_COMMON, SUB_POLL, SUB_VECTOR
73 tprint_lio_opcode(unsigned cmd)
79 { "pread", SUB_COMMON },
80 { "pwrite", SUB_COMMON },
81 { "fsync", SUB_NONE },
82 { "fdsync", SUB_NONE },
86 { "preadv", SUB_VECTOR },
87 { "pwritev", SUB_VECTOR },
90 if (cmd < ARRAY_SIZE(cmds)) {
91 tprints(cmds[cmd].name);
94 tprintf("%u /* SUB_??? */", cmd);
99 print_common_flags(struct iocb *iocb)
101 #if HAVE_STRUCT_IOCB_U_C_FLAGS
102 if (iocb->u.c.flags & IOCB_RESFD)
103 tprintf(", resfd=%d", iocb->u.c.resfd);
104 if (iocb->u.c.flags & ~IOCB_RESFD)
105 tprintf(", flags=%x", iocb->u.c.flags);
107 # warning "libaio.h is too old => limited io_submit decoding"
111 #endif /* HAVE_LIBAIO_H */
117 long nr = tcp->u_arg[1];
118 /* if nr <= 0, we end up printing just "{}" */
119 tprintf("%lu, %ld, {", tcp->u_arg[0], tcp->u_arg[1]);
122 struct iocb **iocbs = (void *)tcp->u_arg[2];
123 //FIXME: decoding of 32-bit call by 64-bit strace
125 for (i = 0; i < nr; i++, iocbs++) {
132 if (umove(tcp, (unsigned long)iocbs, &iocbp)) {
133 tprintf("%#lx", (unsigned long)iocbs);
134 /* No point in trying to read iocbs+1 etc */
135 /* (nr can be ridiculously large): */
138 if (umove(tcp, (unsigned long)iocbp, &iocb)) {
139 tprintf("{%#lx}", (unsigned long)iocbp);
144 tprintf("data:%p, ", iocb.data);
146 tprintf("key:%u, ", iocb.key);
147 sub = tprint_lio_opcode(iocb.aio_lio_opcode);
148 if (iocb.aio_reqprio)
149 tprintf(", reqprio:%d", iocb.aio_reqprio);
150 tprintf(", filedes:%d", iocb.aio_fildes);
153 #if HAVE_DECL_IO_CMD_PWRITE
154 if (iocb.aio_lio_opcode == IO_CMD_PWRITE) {
156 printstr(tcp, (unsigned long)iocb.u.c.buf,
160 tprintf(", buf:%p", iocb.u.c.buf);
161 tprintf(", nbytes:%lu, offset:%lld",
164 print_common_flags(&iocb);
167 tprintf(", %lld", iocb.u.v.offset);
168 print_common_flags(&iocb);
170 tprint_iov(tcp, iocb.u.v.nr,
171 (unsigned long)iocb.u.v.vec,
172 #if HAVE_DECL_IO_CMD_PWRITEV
173 iocb.aio_lio_opcode == IO_CMD_PWRITEV
180 tprintf(", %x", iocb.u.poll.events);
190 # warning "libaio.h is not available => no io_submit decoding"
191 tprintf("%lu, %ld, %#lx", tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
203 tprintf("%lu, ", tcp->u_arg[0]);
205 if (umove(tcp, tcp->u_arg[1], &iocb) == 0) {
206 tprintf("{%p, %u, %u, %u, %d}, ",
208 (unsigned)iocb.aio_lio_opcode,
209 (unsigned)iocb.aio_reqprio, iocb.aio_fildes);
218 struct io_event event;
219 if (umove(tcp, tcp->u_arg[2], &event) == 0)
220 tprintf("{%p, %p, %ld, %ld}",
221 event.data, event.obj,
222 event.res, event.res2);
231 SYS_FUNC(io_getevents)
234 tprintf("%ld, %ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1],
237 if (tcp->u_rval == 0) {
241 struct io_event *events = (void *)tcp->u_arg[3];
242 long i, nr = tcp->u_rval;
244 for (i = 0; i < nr; i++, events++) {
245 struct io_event event;
252 if (umove(tcp, (unsigned long)events, &event) != 0) {
256 tprintf("{%p, %p, %ld, %ld}", event.data,
257 event.obj, event.res, event.res2);
265 print_timespec(tcp, tcp->u_arg[4]);