blob: 6bb986cbd2702ede0027e2459bb5a3fdea634240 [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
John Hughes5a826b82001-03-07 13:21:24 +0000133#if defined(SVR4)
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 Akkerman76baf7c1999-02-19 00:21:36 +0000150 tprintf(", %lu, %llu", tcp->u_arg[2],
151 (((unsigned long long) tcp->u_arg[4]) << 32
152 | tcp->u_arg[3]));
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000153#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000154 }
155 return 0;
156}
157
158int
159sys_pwrite(tcp)
160struct tcb *tcp;
161{
162 if (entering(tcp)) {
163 tprintf("%ld, ", tcp->u_arg[0]);
164 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000165#if UNIXWARE
166 /* off_t is signed int */
167 tprintf(", %lu, %ld", tcp->u_arg[2], tcp->u_arg[3]);
168#else
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000169 tprintf(", %lu, %llu", tcp->u_arg[2],
170 (((unsigned long long) tcp->u_arg[4]) << 32
171 | tcp->u_arg[3]));
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000172#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000173 }
174 return 0;
175}
John Hughes5a826b82001-03-07 13:21:24 +0000176#endif /* SVR4 */
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000177
178#ifdef FREEBSD
179#include <sys/types.h>
180#include <sys/socket.h>
181
182int
183sys_sendfile(tcp)
184struct tcb *tcp;
185{
186 if (entering(tcp)) {
187 tprintf("%ld, %ld, %llu, %lu", tcp->u_arg[0], tcp->u_arg[1],
188 (((unsigned long long) tcp->u_arg[3]) << 32 |
189 tcp->u_arg[2]), tcp->u_arg[4]);
190 } else {
191 off_t offset;
192
193 if (!tcp->u_arg[5])
194 tprintf(", NULL");
195 else {
196 struct sf_hdtr hdtr;
197
198 if (umove(tcp, tcp->u_arg[5], &hdtr) < 0)
199 tprintf(", %#lx", tcp->u_arg[5]);
200 else {
201 tprintf(", { ");
202 tprint_iov(tcp, hdtr.hdr_cnt, hdtr.headers);
203 tprintf(", %u, ", hdtr.hdr_cnt);
204 tprint_iov(tcp, hdtr.trl_cnt, hdtr.trailers);
205 tprintf(", %u }", hdtr.hdr_cnt);
206 }
207 }
208 if (!tcp->u_arg[6])
209 tprintf(", NULL");
210 else if (umove(tcp, tcp->u_arg[6], &offset) < 0)
211 tprintf(", %#lx", tcp->u_arg[6]);
212 else
213 tprintf(", [%llu]", offset);
214 tprintf(", %lu", tcp->u_arg[7]);
215 }
216 return 0;
217}
218#endif /* FREEBSD */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000219
220#ifdef LINUX
221int
222sys_pread(tcp)
223struct tcb *tcp;
224{
225 if (entering(tcp)) {
226 tprintf("%ld, ", tcp->u_arg[0]);
227 } else {
228 if (syserror(tcp))
229 tprintf("%#lx", tcp->u_arg[1]);
230 else
231 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000232 tprintf(", %lu, %llu", tcp->u_arg[2],
233 *(unsigned long long *)&tcp->u_arg[3]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000234 }
235 return 0;
236}
237
238int
239sys_pwrite(tcp)
240struct tcb *tcp;
241{
242 if (entering(tcp)) {
243 tprintf("%ld, ", tcp->u_arg[0]);
244 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000245 tprintf(", %lu, %llu", tcp->u_arg[2],
246 *(unsigned long long *)&tcp->u_arg[3]);
247 }
248 return 0;
249}
250
251int
252sys_sendfile(tcp)
253struct tcb *tcp;
254{
255 if (entering(tcp)) {
256 off_t offset;
257
258 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
259 if (!tcp->u_arg[2])
260 tprintf("NULL");
261 else if (umove(tcp, tcp->u_arg[2], &offset) < 0)
262 tprintf("%#lx", tcp->u_arg[2]);
263 else
264 tprintf("[%lu]", offset);
265 tprintf(", %lu", tcp->u_arg[3]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000266 }
267 return 0;
268}
269
270#endif /* LINUX */
271
John Hughes5a826b82001-03-07 13:21:24 +0000272#if _LFS64_LARGEFILE || FREEBSD
John Hughesbdf48f52001-03-06 15:08:09 +0000273int
274sys_pread64(tcp)
275struct tcb *tcp;
276{
277 if (entering(tcp)) {
278 tprintf("%ld, ", tcp->u_arg[0]);
279 } else {
John Hughes5a826b82001-03-07 13:21:24 +0000280 ALIGN64 (tcp, 3);
John Hughesbdf48f52001-03-06 15:08:09 +0000281 if (syserror(tcp))
282 tprintf("%#lx", tcp->u_arg[1]);
283 else
284 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
John Hughes5a826b82001-03-07 13:21:24 +0000285 tprintf(", %lu, %#llx", tcp->u_arg[2],
286 get64(tcp->u_arg[3], tcp->u_arg[4]));
John Hughesbdf48f52001-03-06 15:08:09 +0000287 }
288 return 0;
289}
290
291int
292sys_pwrite64(tcp)
293struct tcb *tcp;
294{
295 if (entering(tcp)) {
John Hughes5a826b82001-03-07 13:21:24 +0000296 ALIGN64 (tcp, 3);
John Hughesbdf48f52001-03-06 15:08:09 +0000297 tprintf("%ld, ", tcp->u_arg[0]);
298 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
John Hughes5a826b82001-03-07 13:21:24 +0000299 tprintf(", %lu, %#llx", tcp->u_arg[2],
300 get64(tcp->u_arg[3], tcp->u_arg[4]));
John Hughesbdf48f52001-03-06 15:08:09 +0000301 }
302 return 0;
303}
304#endif
305
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000306int
307sys_ioctl(tcp)
308struct tcb *tcp;
309{
310 char *symbol;
311
312 if (entering(tcp)) {
313 tprintf("%ld, ", tcp->u_arg[0]);
314 symbol = ioctl_lookup(tcp->u_arg[1]);
315 if (symbol)
316 tprintf("%s", symbol);
317 else
318 tprintf("%#lx", tcp->u_arg[1]);
319 ioctl_decode(tcp, tcp->u_arg[1], tcp->u_arg[2]);
320 }
321 else {
322 if (ioctl_decode(tcp, tcp->u_arg[1], tcp->u_arg[2]) == 0)
323 tprintf(", %#lx", tcp->u_arg[2]);
324 }
325 return 0;
326}