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)
42 sys_io_setup(struct tcb *tcp)
45 tprintf("%ld, ", tcp->u_arg[0]);
48 tprintf("0x%0lx", tcp->u_arg[1]);
50 unsigned long user_id;
51 if (umove(tcp, tcp->u_arg[1], &user_id) == 0)
52 tprintf("{%lu}", user_id);
61 sys_io_destroy(struct tcb *tcp)
64 tprintf("%lu", tcp->u_arg[0]);
71 SUB_NONE, SUB_COMMON, SUB_POLL, SUB_VECTOR
75 tprint_lio_opcode(unsigned cmd)
81 { "pread", SUB_COMMON },
82 { "pwrite", SUB_COMMON },
83 { "fsync", SUB_NONE },
84 { "fdsync", SUB_NONE },
88 { "preadv", SUB_VECTOR },
89 { "pwritev", SUB_VECTOR },
92 if (cmd < ARRAY_SIZE(cmds)) {
93 tprints(cmds[cmd].name);
96 tprintf("%u /* SUB_??? */", cmd);
101 print_common_flags(struct iocb *iocb)
103 #if HAVE_STRUCT_IOCB_U_C_FLAGS
104 if (iocb->u.c.flags & IOCB_RESFD)
105 tprintf(", resfd=%d", iocb->u.c.resfd);
106 if (iocb->u.c.flags & ~IOCB_RESFD)
107 tprintf(", flags=%x", iocb->u.c.flags);
109 # warning "libaio.h is too old => limited io_submit decoding"
113 #endif /* HAVE_LIBAIO_H */
116 sys_io_submit(struct tcb *tcp)
120 long nr = tcp->u_arg[1];
121 /* if nr <= 0, we end up printing just "{}" */
122 tprintf("%lu, %ld, {", tcp->u_arg[0], tcp->u_arg[1]);
125 struct iocb **iocbs = (void *)tcp->u_arg[2];
126 //FIXME: decoding of 32-bit call by 64-bit strace
128 for (i = 0; i < nr; i++, iocbs++) {
135 if (umove(tcp, (unsigned long)iocbs, &iocbp)) {
136 tprintf("%#lx", (unsigned long)iocbs);
137 /* No point in trying to read iocbs+1 etc */
138 /* (nr can be ridiculously large): */
141 if (umove(tcp, (unsigned long)iocbp, &iocb)) {
142 tprintf("{%#lx}", (unsigned long)iocbp);
147 tprintf("data:%p, ", iocb.data);
149 tprintf("key:%u, ", iocb.key);
150 sub = tprint_lio_opcode(iocb.aio_lio_opcode);
151 if (iocb.aio_reqprio)
152 tprintf(", reqprio:%d", iocb.aio_reqprio);
153 tprintf(", filedes:%d", iocb.aio_fildes);
156 #if HAVE_DECL_IO_CMD_PWRITE
157 if (iocb.aio_lio_opcode == IO_CMD_PWRITE) {
159 printstr(tcp, (unsigned long)iocb.u.c.buf,
163 tprintf(", buf:%p", iocb.u.c.buf);
164 tprintf(", nbytes:%lu, offset:%lld",
167 print_common_flags(&iocb);
170 tprintf(", %lld", iocb.u.v.offset);
171 print_common_flags(&iocb);
173 tprint_iov(tcp, iocb.u.v.nr,
174 (unsigned long)iocb.u.v.vec,
175 #if HAVE_DECL_IO_CMD_PWRITEV
176 iocb.aio_lio_opcode == IO_CMD_PWRITEV
183 tprintf(", %x", iocb.u.poll.events);
193 # warning "libaio.h is not available => no io_submit decoding"
194 tprintf("%lu, %ld, %#lx", tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
201 sys_io_cancel(struct tcb *tcp)
207 tprintf("%lu, ", tcp->u_arg[0]);
209 if (umove(tcp, tcp->u_arg[1], &iocb) == 0) {
210 tprintf("{%p, %u, %u, %u, %d}, ",
212 (unsigned)iocb.aio_lio_opcode,
213 (unsigned)iocb.aio_reqprio, iocb.aio_fildes);
222 struct io_event event;
223 if (umove(tcp, tcp->u_arg[2], &event) == 0)
224 tprintf("{%p, %p, %ld, %ld}",
225 event.data, event.obj,
226 event.res, event.res2);
236 sys_io_getevents(struct tcb *tcp)
239 tprintf("%ld, %ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1],
242 if (tcp->u_rval == 0) {
246 struct io_event *events = (void *)tcp->u_arg[3];
247 long i, nr = tcp->u_rval;
249 for (i = 0; i < nr; i++, events++) {
250 struct io_event event;
257 if (umove(tcp, (unsigned long)events, &event) != 0) {
261 tprintf("{%p, %p, %ld, %ld}", event.data,
262 event.obj, event.res, event.res2);
270 print_timespec(tcp, tcp->u_arg[4]);