blob: 0fe8c3d5f1f82146c0ae4da3fdf158be0dbd182c [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
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 Akkerman4dc8a2a1999-12-23 14:20:14 +00005 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00006 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
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.
18 *
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.
29 *
30 * $Id$
31 */
32
33#include "defs.h"
34
35#include <fcntl.h>
36#include <sys/uio.h>
37
38int
39sys_read(tcp)
40struct tcb *tcp;
41{
42 if (entering(tcp)) {
43 tprintf("%ld, ", tcp->u_arg[0]);
44 } else {
45 if (syserror(tcp))
46 tprintf("%#lx", tcp->u_arg[1]);
47 else
48 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
49 tprintf(", %lu", tcp->u_arg[2]);
50 }
51 return 0;
52}
53
54int
55sys_write(tcp)
56struct tcb *tcp;
57{
58 if (entering(tcp)) {
59 tprintf("%ld, ", tcp->u_arg[0]);
60 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
61 tprintf(", %lu", tcp->u_arg[2]);
62 }
63 return 0;
64}
65
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +000066void
67tprint_iov(tcp, len, addr)
68struct tcb * tcp;
69int len;
70char * addr;
71{
72 struct iovec *iov;
73 int i;
74
75
76 if (!len) {
77 tprintf("[]");
78 return;
79 }
80
81 if ((iov = (struct iovec *) malloc(len * sizeof *iov)) == NULL) {
82 fprintf(stderr, "No memory");
83 return;
84 }
85 if (umoven(tcp, (int) addr,
86 len * sizeof *iov, (char *) iov) < 0) {
87 tprintf("%#lx", tcp->u_arg[1]);
88 } else {
89 tprintf("[");
90 for (i = 0; i < len; i++) {
91 if (i)
92 tprintf(", ");
93 tprintf("{");
94 printstr(tcp, (long) iov[i].iov_base,
95 iov[i].iov_len);
96 tprintf(", %lu}", (unsigned long)iov[i].iov_len);
97 }
98 tprintf("]");
99 }
100 free((char *) iov);
101}
102
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000103int
104sys_readv(tcp)
105struct tcb *tcp;
106{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000107 if (entering(tcp)) {
108 tprintf("%ld, ", tcp->u_arg[0]);
109 } else {
110 if (syserror(tcp)) {
111 tprintf("%#lx, %lu",
112 tcp->u_arg[1], tcp->u_arg[2]);
113 return 0;
114 }
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000115 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000116 tprintf(", %lu", tcp->u_arg[2]);
117 }
118 return 0;
119}
120
121int
122sys_writev(tcp)
123struct tcb *tcp;
124{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000125 if (entering(tcp)) {
126 tprintf("%ld, ", tcp->u_arg[0]);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000127 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000128 tprintf(", %lu", tcp->u_arg[2]);
129 }
130 return 0;
131}
132
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000133#if defined(SVR4) || defined(FREEBSD)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000134
135int
136sys_pread(tcp)
137struct tcb *tcp;
138{
139 if (entering(tcp)) {
140 tprintf("%ld, ", tcp->u_arg[0]);
141 } else {
142 if (syserror(tcp))
143 tprintf("%#lx", tcp->u_arg[1]);
144 else
145 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000146#if UNIXWARE
147 /* off_t is signed int */
148 tprintf(", %lu, %ld", tcp->u_arg[2], tcp->u_arg[3]);
149#else
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000150#ifndef FREEBSD
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000151 tprintf(", %lu, %llu", tcp->u_arg[2],
152 (((unsigned long long) tcp->u_arg[4]) << 32
153 | tcp->u_arg[3]));
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000154#else
155 tprintf(", %lu, %llu", tcp->u_arg[2],
156 (((off_t) tcp->u_arg[3]) << 32) + tcp->u_arg[4]);
157#endif
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000158#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000159 }
160 return 0;
161}
162
163int
164sys_pwrite(tcp)
165struct tcb *tcp;
166{
167 if (entering(tcp)) {
168 tprintf("%ld, ", tcp->u_arg[0]);
169 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000170#if UNIXWARE
171 /* off_t is signed int */
172 tprintf(", %lu, %ld", tcp->u_arg[2], tcp->u_arg[3]);
173#else
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000174#ifndef FREEBSD
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000175 tprintf(", %lu, %llu", tcp->u_arg[2],
176 (((unsigned long long) tcp->u_arg[4]) << 32
177 | tcp->u_arg[3]));
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000178#else
179 tprintf(", %lu, %llu", tcp->u_arg[2],
180 (((off_t) tcp->u_arg[3]) << 32) + tcp->u_arg[4]);
181#endif
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000182#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000183 }
184 return 0;
185}
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000186#endif /* SVR4 || FREEBSD */
187
188#ifdef FREEBSD
189#include <sys/types.h>
190#include <sys/socket.h>
191
192int
193sys_sendfile(tcp)
194struct tcb *tcp;
195{
196 if (entering(tcp)) {
197 tprintf("%ld, %ld, %llu, %lu", tcp->u_arg[0], tcp->u_arg[1],
198 (((unsigned long long) tcp->u_arg[3]) << 32 |
199 tcp->u_arg[2]), tcp->u_arg[4]);
200 } else {
201 off_t offset;
202
203 if (!tcp->u_arg[5])
204 tprintf(", NULL");
205 else {
206 struct sf_hdtr hdtr;
207
208 if (umove(tcp, tcp->u_arg[5], &hdtr) < 0)
209 tprintf(", %#lx", tcp->u_arg[5]);
210 else {
211 tprintf(", { ");
212 tprint_iov(tcp, hdtr.hdr_cnt, hdtr.headers);
213 tprintf(", %u, ", hdtr.hdr_cnt);
214 tprint_iov(tcp, hdtr.trl_cnt, hdtr.trailers);
215 tprintf(", %u }", hdtr.hdr_cnt);
216 }
217 }
218 if (!tcp->u_arg[6])
219 tprintf(", NULL");
220 else if (umove(tcp, tcp->u_arg[6], &offset) < 0)
221 tprintf(", %#lx", tcp->u_arg[6]);
222 else
223 tprintf(", [%llu]", offset);
224 tprintf(", %lu", tcp->u_arg[7]);
225 }
226 return 0;
227}
228#endif /* FREEBSD */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000229
230#ifdef LINUX
231int
232sys_pread(tcp)
233struct tcb *tcp;
234{
235 if (entering(tcp)) {
236 tprintf("%ld, ", tcp->u_arg[0]);
237 } else {
238 if (syserror(tcp))
239 tprintf("%#lx", tcp->u_arg[1]);
240 else
241 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000242 tprintf(", %lu, %llu", tcp->u_arg[2],
243 *(unsigned long long *)&tcp->u_arg[3]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000244 }
245 return 0;
246}
247
248int
249sys_pwrite(tcp)
250struct tcb *tcp;
251{
252 if (entering(tcp)) {
253 tprintf("%ld, ", tcp->u_arg[0]);
254 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000255 tprintf(", %lu, %llu", tcp->u_arg[2],
256 *(unsigned long long *)&tcp->u_arg[3]);
257 }
258 return 0;
259}
260
261int
262sys_sendfile(tcp)
263struct tcb *tcp;
264{
265 if (entering(tcp)) {
266 off_t offset;
267
268 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
269 if (!tcp->u_arg[2])
270 tprintf("NULL");
271 else if (umove(tcp, tcp->u_arg[2], &offset) < 0)
272 tprintf("%#lx", tcp->u_arg[2]);
273 else
274 tprintf("[%lu]", offset);
275 tprintf(", %lu", tcp->u_arg[3]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000276 }
277 return 0;
278}
279
280#endif /* LINUX */
281
John Hughesbdf48f52001-03-06 15:08:09 +0000282#if _LFS64_LARGEFILE
283int
284sys_pread64(tcp)
285struct tcb *tcp;
286{
287 if (entering(tcp)) {
288 tprintf("%ld, ", tcp->u_arg[0]);
289 } else {
290 if (syserror(tcp))
291 tprintf("%#lx", tcp->u_arg[1]);
292 else
293 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
294 tprintf(", %lu, %#llx", tcp->u_arg[2], get64(tcp->u_arg[3], tcp->u_arg[4]));
295 }
296 return 0;
297}
298
299int
300sys_pwrite64(tcp)
301struct tcb *tcp;
302{
303 if (entering(tcp)) {
304 tprintf("%ld, ", tcp->u_arg[0]);
305 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
306 tprintf(", %lu, %#llx", tcp->u_arg[2], get64(tcp->u_arg[3], tcp->u_arg[4]));
307 }
308 return 0;
309}
310#endif
311
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000312int
313sys_ioctl(tcp)
314struct tcb *tcp;
315{
316 char *symbol;
317
318 if (entering(tcp)) {
319 tprintf("%ld, ", tcp->u_arg[0]);
320 symbol = ioctl_lookup(tcp->u_arg[1]);
321 if (symbol)
322 tprintf("%s", symbol);
323 else
324 tprintf("%#lx", tcp->u_arg[1]);
325 ioctl_decode(tcp, tcp->u_arg[1], tcp->u_arg[2]);
326 }
327 else {
328 if (ioctl_decode(tcp, tcp->u_arg[1], tcp->u_arg[2]) == 0)
329 tprintf(", %#lx", tcp->u_arg[2]);
330 }
331 return 0;
332}