blob: 35b3ecc6d75962a547b7cb42ca23d2591f1641df [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
2 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00003 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00004 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * $Id$
29 */
30
31#include "defs.h"
32
Wichert Akkermand4d8e921999-04-18 23:30:29 +000033#if defined(HAVE_SYS_STREAM_H) || defined(linux)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000034
Wichert Akkermand4d8e921999-04-18 23:30:29 +000035#if defined(linux)
Pavel Machek245a6ac2000-02-01 16:12:33 +000036#ifdef HAVE_SYS_POLL_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000037#include <sys/poll.h>
Pavel Machek245a6ac2000-02-01 16:12:33 +000038#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000039
40#define RS_HIPRI 1
41struct strbuf {
42 int maxlen; /* no. of bytes in buffer */
43 int len; /* no. of bytes returned */
44 char *buf; /* pointer to data */
45};
46#define MORECTL 1
47#define MOREDATA 2
48
Wichert Akkermand4d8e921999-04-18 23:30:29 +000049#else /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000050
51#include <stropts.h>
52#include <poll.h>
53#include <sys/conf.h>
54#include <sys/stream.h>
55#include <sys/tihdr.h>
56
Wichert Akkermand4d8e921999-04-18 23:30:29 +000057#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000058
59#ifdef HAVE_SYS_TIUSER_H
60#include <sys/tiuser.h>
61#include <sys/sockmod.h>
62#include <sys/timod.h>
63#endif /* HAVE_SYS_TIUSER_H */
64
65static struct xlat msgflags[] = {
66 { RS_HIPRI, "RS_HIPRI" },
67 { 0, NULL },
68};
69
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000070
71static void
72printstrbuf(tcp, sbp, getting)
73struct tcb *tcp;
74struct strbuf *sbp;
75int getting;
76{
77 if (sbp->maxlen == -1 && getting)
78 tprintf("{maxlen=-1}");
79 else {
80 tprintf("{");
81 if (getting)
82 tprintf("maxlen=%d, ", sbp->maxlen);
83 tprintf("len=%d, buf=", sbp->len);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +000084 printstr(tcp, (unsigned long) sbp->buf, sbp->len);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000085 tprintf("}");
86 }
87}
88
89static void
90printstrbufarg(tcp, arg, getting)
91struct tcb *tcp;
92int arg;
93int getting;
94{
95 struct strbuf buf;
96
97 if (arg == 0)
98 tprintf("NULL");
99 else if (umove(tcp, arg, &buf) < 0)
100 tprintf("{...}");
101 else
102 printstrbuf(tcp, &buf, getting);
103 tprintf(", ");
104}
105
106int
107sys_putmsg(tcp)
108struct tcb *tcp;
109{
110 int i;
111
112 if (entering(tcp)) {
113 /* fd */
114 tprintf("%ld, ", tcp->u_arg[0]);
115 /* control and data */
116 for (i = 1; i < 3; i++)
117 printstrbufarg(tcp, tcp->u_arg[i], 0);
118 /* flags */
119 if (!printflags(msgflags, tcp->u_arg[3]))
120 tprintf("0");
121 }
122 return 0;
123}
124
125int
126sys_getmsg(tcp)
127struct tcb *tcp;
128{
129 int i, flags;
130
131 if (entering(tcp)) {
132 /* fd */
133 tprintf("%lu, ", tcp->u_arg[0]);
134 } else {
135 if (syserror(tcp)) {
136 tprintf("%#lx, %#lx, %#lx",
137 tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
138 return 0;
139 }
140 /* control and data */
141 for (i = 1; i < 3; i++)
142 printstrbufarg(tcp, tcp->u_arg[i], 1);
143 /* pointer to flags */
144 if (tcp->u_arg[3] == 0)
145 tprintf("NULL");
146 else if (umove(tcp, tcp->u_arg[3], &flags) < 0)
147 tprintf("[?]");
148 else {
149 tprintf("[");
150 if (!printflags(msgflags, flags))
151 tprintf("0");
152 tprintf("]");
153 }
154 /* decode return value */
155 switch (tcp->u_rval) {
156 case MORECTL:
157 tcp->auxstr = "MORECTL";
158 break;
159 case MORECTL|MOREDATA:
160 tcp->auxstr = "MORECTL|MOREDATA";
161 break;
162 case MOREDATA:
163 tcp->auxstr = "MORECTL";
164 break;
165 default:
166 tcp->auxstr = NULL;
167 break;
168 }
169 }
170 return RVAL_HEX | RVAL_STR;
171}
172
173#ifdef HAVE_PUTPMSG
174
175static struct xlat pmsgflags[] = {
176 { MSG_HIPRI, "MSG_HIPRI" },
177 { MSG_ANY, "MSG_ANY" },
178 { MSG_BAND, "MSG_BAND" },
179 { 0, NULL },
180};
181
182int
183sys_putpmsg(tcp)
184struct tcb *tcp;
185{
186 int i;
187
188 if (entering(tcp)) {
189 /* fd */
190 tprintf("%ld, ", tcp->u_arg[0]);
191 /* control and data */
192 for (i = 1; i < 3; i++)
193 printstrbufarg(tcp, tcp->u_arg[i], 0);
194 /* band */
195 tprintf("%ld, ", tcp->u_arg[3]);
196 /* flags */
197 if (!printflags(pmsgflags, tcp->u_arg[4]))
198 tprintf("0");
199 }
200 return 0;
201}
202
203int
204sys_getpmsg(tcp)
205struct tcb *tcp;
206{
207 int i, flags;
208
209 if (entering(tcp)) {
210 /* fd */
211 tprintf("%lu, ", tcp->u_arg[0]);
212 } else {
213 if (syserror(tcp)) {
214 tprintf("%#lx, %#lx, %#lx, %#lx", tcp->u_arg[1],
215 tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[4]);
216 return 0;
217 }
218 /* control and data */
219 for (i = 1; i < 3; i++)
220 printstrbufarg(tcp, tcp->u_arg[i], 1);
221 /* pointer to band */
222 printnum(tcp, tcp->u_arg[3], "%d");
Wichert Akkerman906dade1999-11-26 09:18:37 +0000223 tprintf(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000224 /* pointer to flags */
225 if (tcp->u_arg[4] == 0)
226 tprintf("NULL");
227 else if (umove(tcp, tcp->u_arg[4], &flags) < 0)
228 tprintf("[?]");
229 else {
230 tprintf("[");
231 if (!printflags(pmsgflags, flags))
232 tprintf("0");
233 tprintf("]");
234 }
235 /* decode return value */
236 switch (tcp->u_rval) {
237 case MORECTL:
238 tcp->auxstr = "MORECTL";
239 break;
240 case MORECTL|MOREDATA:
241 tcp->auxstr = "MORECTL|MOREDATA";
242 break;
243 case MOREDATA:
244 tcp->auxstr = "MORECTL";
245 break;
246 default:
247 tcp->auxstr = NULL;
248 break;
249 }
250 }
251 return RVAL_HEX | RVAL_STR;
252}
253
254#endif /* HAVE_PUTPMSG */
255
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000256
257static struct xlat pollflags[] = {
Pavel Machek245a6ac2000-02-01 16:12:33 +0000258#ifdef POLLIN
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000259 { POLLIN, "POLLIN" },
260 { POLLPRI, "POLLPRI" },
261 { POLLOUT, "POLLOUT" },
262#ifdef POLLRDNORM
263 { POLLRDNORM, "POLLRDNORM" },
264#endif
265#ifdef POLLWRNORM
266 { POLLWRNORM, "POLLWRNORM" },
267#endif
268#ifdef POLLRDBAND
269 { POLLRDBAND, "POLLRDBAND" },
270#endif
271#ifdef POLLWRBAND
272 { POLLWRBAND, "POLLWRBAND" },
273#endif
274 { POLLERR, "POLLERR" },
275 { POLLHUP, "POLLHUP" },
276 { POLLNVAL, "POLLNVAL" },
Pavel Machek245a6ac2000-02-01 16:12:33 +0000277#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000278 { 0, NULL },
279};
280
281int
282sys_poll(tcp)
283struct tcb *tcp;
284{
285 struct pollfd *pollp;
286
Pavel Machek245a6ac2000-02-01 16:12:33 +0000287#ifdef HAVE_SYS_POLL_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000288 if (exiting(tcp)) {
289 int i;
290 int nfds = tcp->u_arg[1];
291
292 if (nfds <= 0) {
293 tprintf("%#lx, %d, %ld\n",
294 tcp->u_arg[0], nfds, tcp->u_arg[2]);
295 return 0;
296 }
297 pollp = (struct pollfd *) malloc(nfds * sizeof(*pollp));
298 if (pollp == NULL) {
299 fprintf(stderr, "sys_poll: no memory\n");
300 tprintf("%#lx, %d, %ld",
301 tcp->u_arg[0], nfds, tcp->u_arg[2]);
302 return 0;
303 }
304 if (umoven(tcp, tcp->u_arg[0],
305 (nfds * sizeof(*pollp)), (char *) pollp) < 0) {
306 tprintf("%#lx", tcp->u_arg[0]);
307 }
308 else {
309 tprintf("[");
310 for (i = 0; i < nfds; i++) {
311 if (i)
312 tprintf(", ");
313 if (pollp[i].fd < 0) {
314 tprintf("{fd=%d}", pollp[i].fd);
315 continue;
316 }
317 tprintf("{fd=%d, events=", pollp[i].fd);
318 if (!printflags(pollflags, pollp[i].events))
319 tprintf("0");
320 if (!syserror(tcp) && pollp[i].revents) {
321 tprintf(", revents=");
322 if (!printflags(pollflags,
323 pollp[i].revents))
324 tprintf("0");
325 }
326 tprintf("}");
327 }
328 tprintf("]");
329 }
330 tprintf(", %d, ", nfds);
331#ifdef INFTIM
332 if (tcp->u_arg[2] == INFTIM)
333 tprintf("INFTIM");
334 else
335#endif
336 tprintf("%ld", tcp->u_arg[2]);
337 free(pollp);
338 }
Pavel Machek245a6ac2000-02-01 16:12:33 +0000339#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000340 return 0;
341}
342
343#ifndef linux
344
345static struct xlat stream_flush_options[] = {
346 { FLUSHR, "FLUSHR" },
347 { FLUSHW, "FLUSHW" },
348 { FLUSHRW, "FLUSHRW" },
349#ifdef FLUSHBAND
350 { FLUSHBAND, "FLUSHBAND" },
351#endif
352 { 0, NULL },
353};
354
355static struct xlat stream_setsig_flags[] = {
356 { S_INPUT, "S_INPUT" },
357 { S_HIPRI, "S_HIPRI" },
358 { S_OUTPUT, "S_OUTPUT" },
359 { S_MSG, "S_MSG" },
360#ifdef S_ERROR
361 { S_ERROR, "S_ERROR" },
362#endif
363#ifdef S_HANGUP
364 { S_HANGUP, "S_HANGUP" },
365#endif
366#ifdef S_RDNORM
367 { S_RDNORM, "S_RDNORM" },
368#endif
369#ifdef S_WRNORM
370 { S_WRNORM, "S_WRNORM" },
371#endif
372#ifdef S_RDBAND
373 { S_RDBAND, "S_RDBAND" },
374#endif
375#ifdef S_WRBAND
376 { S_WRBAND, "S_WRBAND" },
377#endif
378#ifdef S_BANDURG
379 { S_BANDURG, "S_BANDURG" },
380#endif
381 { 0, NULL },
382};
383
384static struct xlat stream_read_options[] = {
385 { RNORM, "RNORM" },
386 { RMSGD, "RMSGD" },
387 { RMSGN, "RMSGN" },
388 { 0, NULL },
389};
390
391static struct xlat stream_read_flags[] = {
392#ifdef RPROTDAT
393 { RPROTDAT, "RPROTDAT" },
394#endif
395#ifdef RPROTDIS
396 { RPROTDIS, "RPROTDIS" },
397#endif
398#ifdef RPROTNORM
399 { RPROTNORM, "RPROTNORM" },
400#endif
401 { 0, NULL },
402};
403
404#ifndef RMODEMASK
405#define RMODEMASK (~0)
406#endif
407
408#ifdef I_SWROPT
409static struct xlat stream_write_flags[] = {
410 { SNDZERO, "SNDZERO" },
411 { SNDPIPE, "SNDPIPE" },
412 { 0, NULL },
413};
414#endif /* I_SWROPT */
415
416#ifdef I_ATMARK
417static struct xlat stream_atmark_options[] = {
418 { ANYMARK, "ANYMARK" },
419 { LASTMARK, "LASTMARK" },
420 { 0, NULL },
421};
422#endif /* I_ATMARK */
423
424#ifdef TI_BIND
425static struct xlat transport_user_options[] = {
426 { T_CONN_REQ, "T_CONN_REQ" },
427 { T_CONN_RES, "T_CONN_RES" },
428 { T_DISCON_REQ, "T_DISCON_REQ" },
429 { T_DATA_REQ, "T_DATA_REQ" },
430 { T_EXDATA_REQ, "T_EXDATA_REQ" },
431 { T_INFO_REQ, "T_INFO_REQ" },
432 { T_BIND_REQ, "T_BIND_REQ" },
433 { T_UNBIND_REQ, "T_UNBIND_REQ" },
434 { T_UNITDATA_REQ,"T_UNITDATA_REQ"},
435 { T_OPTMGMT_REQ,"T_OPTMGMT_REQ" },
436 { T_ORDREL_REQ, "T_ORDREL_REQ" },
437 { 0, NULL },
438};
439
440static struct xlat transport_provider_options[] = {
441 { T_CONN_IND, "T_CONN_IND" },
442 { T_CONN_CON, "T_CONN_CON" },
443 { T_DISCON_IND, "T_DISCON_IND" },
444 { T_DATA_IND, "T_DATA_IND" },
445 { T_EXDATA_IND, "T_EXDATA_IND" },
446 { T_INFO_ACK, "T_INFO_ACK" },
447 { T_BIND_ACK, "T_BIND_ACK" },
448 { T_ERROR_ACK, "T_ERROR_ACK" },
449 { T_OK_ACK, "T_OK_ACK" },
450 { T_UNITDATA_IND,"T_UNITDATA_IND"},
451 { T_UDERROR_IND,"T_UDERROR_IND" },
452 { T_OPTMGMT_ACK,"T_OPTMGMT_ACK" },
453 { T_ORDREL_IND, "T_ORDREL_IND" },
454 { 0, NULL },
455};
456#endif /* TI_BIND */
457
458static int
459internal_stream_ioctl(tcp, arg)
460struct tcb *tcp;
461int arg;
462{
463 struct strioctl si;
464 char *name;
465 int in_and_out;
466#ifdef SI_GETUDATA
467 struct si_udata udata;
468#endif /* SI_GETUDATA */
469
470 if (!arg)
471 return 0;
472 if (umove(tcp, arg, &si) < 0) {
473 if (entering(tcp))
474 tprintf(", {...}");
475 return 1;
476 }
477 if (entering(tcp)) {
478 name = ioctl_lookup(si.ic_cmd);
479 if (name)
480 tprintf(", {ic_cmd=%s", name);
481 else
482 tprintf(", {ic_cmd=%#x", si.ic_cmd);
483 if (si.ic_timout == INFTIM)
484 tprintf(", ic_timout=INFTIM, ");
485 else
486 tprintf(" ic_timout=%d, ", si.ic_timout);
487 }
488 in_and_out = 1;
489 switch (si.ic_cmd) {
490#ifdef SI_GETUDATA
491 case SI_GETUDATA:
492 in_and_out = 0;
493 break;
494#endif /* SI_GETUDATA */
495 }
496 if (in_and_out) {
497 if (entering(tcp))
498 tprintf("/* in */ ");
499 else
500 tprintf(", /* out */ ");
501 }
502 if (in_and_out || entering(tcp))
503 tprintf("ic_len=%d, ic_dp=", si.ic_len);
504 switch (si.ic_cmd) {
505#ifdef TI_BIND
506 case TI_BIND:
507 /* in T_BIND_REQ, out T_BIND_ACK */
508 if (entering(tcp)) {
509 struct T_bind_req data;
510
511#if 0
512 tprintf("struct T_bind_req ");
513#endif
514 if (umove(tcp, (int) si.ic_dp, &data) < 0)
515 tprintf("{...}");
516 else {
517 tprintf("{PRIM_type=");
518 printxval(transport_user_options,
519 data.PRIM_type, "T_???");
520 tprintf(", ADDR_length=%ld, ADDR_offset=%ld",
521 data.ADDR_length, data.ADDR_offset);
522 tprintf(", CONIND_number=%ld}",
523 data.CONIND_number);
524 }
525 }
526 else {
527 struct T_bind_ack data;
528
529#if 0
530 tprintf("struct T_bind_ack ");
531#endif
532 if (umove(tcp, (int) si.ic_dp, &data) < 0)
533 tprintf("{...}");
534 else {
535 tprintf("[");
536 tprintf("{PRIM_type=");
537 printxval(transport_provider_options,
538 data.PRIM_type, "T_???");
539 tprintf(", ADDR_length=%ld, ADDR_offset=%ld",
540 data.ADDR_length, data.ADDR_offset);
541 tprintf(", CONIND_number=%ld}",
542 data.CONIND_number);
543 tprintf(", ");
544 printstr(tcp,
545 (int) si.ic_dp + data.ADDR_offset,
546 data.ADDR_length);
547 tprintf("]");
548 }
549 }
550 break;
551#endif /* TI_BIND */
552#if 0
553#ifdef TI_UNBIND
554 case TI_UNBIND:
555 /* in T_UNBIND_REQ, out T_OK_ACK */
556 break;
557#endif /* TI_UNBIND */
558#ifdef TI_GETINFO
559 case TI_GETINFO:
560 /* in T_INFO_REQ, out T_INFO_ACK */
561 break;
562#endif /* TI_GETINFO */
563#ifdef TI_OPTMGMT
564 case TI_OPTMGMT:
565 /* in T_OPTMGMT_REQ, out T_OPTMGMT_ACK */
566 break;
567#endif /* TI_OPTMGMT */
568#endif
569#ifdef SI_GETUDATA
570 case SI_GETUDATA:
571 if (entering(tcp))
572 break;
573#if 0
574 tprintf("struct si_udata ");
575#endif
576 if (umove(tcp, (int) si.ic_dp, &udata) < 0)
577 tprintf("{...}");
578 else {
579 tprintf("{tidusize=%d, addrsize=%d, ",
580 udata.tidusize, udata.addrsize);
581 tprintf("optsize=%d, etsdusize=%d, ",
582 udata.optsize, udata.etsdusize);
583 tprintf("servtype=%d, so_state=%d, ",
584 udata.servtype, udata.so_state);
585 tprintf("so_options=%d", udata.so_options);
586#if 0
587 tprintf(", tsdusize=%d", udata.tsdusize);
588#endif
589 tprintf("}");
590 }
591 break;
592#endif /* SI_GETUDATA */
593 default:
594 printstr(tcp, (int) si.ic_dp, si.ic_len);
595 break;
596 }
597 if (exiting(tcp))
598 tprintf("}");
599 return 1;
600}
601
602int
603stream_ioctl(tcp, code, arg)
604struct tcb *tcp;
605int code, arg;
606{
607#ifdef I_LIST
608 int i;
609#endif
610 int val;
611#ifdef I_FLUSHBAND
612 struct bandinfo bi;
613#endif
614 struct strpeek sp;
615 struct strfdinsert sfi;
616 struct strrecvfd srf;
617#ifdef I_LIST
618 struct str_list sl;
619#endif
620
621 /* I_STR is a special case because the data is read & written. */
622 if (code == I_STR)
623 return internal_stream_ioctl(tcp, arg);
624 if (entering(tcp))
625 return 0;
626
627 switch (code) {
628 case I_PUSH:
629 case I_LOOK:
630 case I_FIND:
631 /* arg is a string */
632 tprintf(", ");
633 printpath(tcp, arg);
634 return 1;
635 case I_POP:
636 /* doesn't take an argument */
637 return 1;
638 case I_FLUSH:
639 /* argument is an option */
640 tprintf(", ");
641 printxval(stream_flush_options, arg, "FLUSH???");
642 return 1;
643#ifdef I_FLUSHBAND
644 case I_FLUSHBAND:
645 /* argument is a pointer to a bandinfo struct */
646 if (umove(tcp, arg, &bi) < 0)
647 tprintf(", {...}");
648 else {
649 tprintf(", {bi_pri=%d, bi_flag=", bi.bi_pri);
650 if (!printflags(stream_flush_options, bi.bi_flag))
651 tprintf("0");
652 tprintf("}");
653 }
654 return 1;
655#endif /* I_FLUSHBAND */
656 case I_SETSIG:
657 /* argument is a set of flags */
658 tprintf(", ");
659 if (!printflags(stream_setsig_flags, arg))
660 tprintf("0");
661 return 1;
662 case I_GETSIG:
663 /* argument is a pointer to a set of flags */
664 if (syserror(tcp))
665 return 0;
666 tprintf(", [");
667 if (umove(tcp, arg, &val) < 0)
668 tprintf("?");
669 else if (!printflags(stream_setsig_flags, val))
670 tprintf("0");
671 tprintf("]");
672 return 1;
673 case I_PEEK:
674 /* argument is a pointer to a strpeek structure */
675 if (syserror(tcp) || !arg)
676 return 0;
677 if (umove(tcp, arg, &sp) < 0) {
678 tprintf(", {...}");
679 return 1;
680 }
681 tprintf(", {ctlbuf=");
682 printstrbuf(tcp, &sp.ctlbuf, 1);
683 tprintf(", databuf=");
684 printstrbuf(tcp, &sp.databuf, 1);
685 if (!printflags(msgflags, sp.flags))
686 tprintf("0");
687 return 1;
688 case I_SRDOPT:
689 /* argument is an option with flags */
690 tprintf(", ");
691 printxval(stream_read_options, arg & RMODEMASK, "R???");
692 addflags(stream_read_flags, arg & ~RMODEMASK);
693 return 1;
694 case I_GRDOPT:
695 /* argument is an pointer to an option with flags */
696 if (syserror(tcp))
697 return 0;
698 tprintf(", [");
699 if (umove(tcp, arg, &val) < 0)
700 tprintf("?");
701 else {
702 printxval(stream_read_options,
703 arg & RMODEMASK, "R???");
704 addflags(stream_read_flags, arg & ~RMODEMASK);
705 }
706 tprintf("]");
707 return 1;
708 case I_NREAD:
709#ifdef I_GETBAND
710 case I_GETBAND:
711#endif
712#ifdef I_SETCLTIME
713 case I_SETCLTIME:
714#endif
715#ifdef I_GETCLTIME
716 case I_GETCLTIME:
717#endif
718 /* argument is a pointer to a decimal integer */
719 if (syserror(tcp))
720 return 0;
721 tprintf(", ");
722 printnum(tcp, arg, "%d");
723 return 1;
724 case I_FDINSERT:
725 /* argument is a pointer to a strfdinsert structure */
726 if (syserror(tcp) || !arg)
727 return 0;
728 if (umove(tcp, arg, &sfi) < 0) {
729 tprintf(", {...}");
730 return 1;
731 }
732 tprintf(", {ctlbuf=");
733 printstrbuf(tcp, &sfi.ctlbuf, 1);
734 tprintf(", databuf=");
735 printstrbuf(tcp, &sfi.databuf, 1);
736 if (!printflags(msgflags, sfi.flags))
737 tprintf("0");
738 tprintf(", filedes=%d, offset=%d}", sfi.fildes, sfi.offset);
739 return 1;
740#ifdef I_SWROPT
741 case I_SWROPT:
742 /* argument is a set of flags */
743 tprintf(", ");
744 if (!printflags(stream_write_flags, arg))
745 tprintf("0");
746 return 1;
747#endif /* I_SWROPT */
748#ifdef I_GWROPT
749 case I_GWROPT:
750 /* argument is an pointer to an option with flags */
751 if (syserror(tcp))
752 return 0;
753 tprintf(", [");
754 if (umove(tcp, arg, &val) < 0)
755 tprintf("?");
756 else if (!printflags(stream_write_flags, arg))
757 tprintf("0");
758 tprintf("]");
759 return 1;
760#endif /* I_GWROPT */
761 case I_SENDFD:
762#ifdef I_CKBAND
763 case I_CKBAND:
764#endif
765#ifdef I_CANPUT
766 case I_CANPUT:
767#endif
768 case I_LINK:
769 case I_UNLINK:
770 case I_PLINK:
771 case I_PUNLINK:
772 /* argument is a decimal integer */
773 tprintf(", %d", arg);
774 return 1;
775 case I_RECVFD:
776 /* argument is a pointer to a strrecvfd structure */
777 if (syserror(tcp) || !arg)
778 return 0;
779 if (umove(tcp, arg, &srf) < 0) {
780 tprintf(", {...}");
781 return 1;
782 }
783 tprintf(", {fd=%d, uid=%lu, gid=%lu}", srf.fd,
784 (unsigned long) srf.uid, (unsigned long) srf.gid);
785 return 1;
786#ifdef I_LIST
787 case I_LIST:
788 if (syserror(tcp))
789 return 0;
790 if (arg == 0) {
791 tprintf(", NULL");
792 return 1;
793 }
794 if (umove(tcp, arg, &sl) < 0) {
795 tprintf(", {...}");
796 return 1;
797 }
798 tprintf(", {sl_nmods=%d, sl_modlist=[", sl.sl_nmods);
799 for (i = 0; i < tcp->u_rval; i++) {
800 if (i)
801 tprintf(", ");
802 printpath(tcp, (int) sl.sl_modlist[i].l_name);
803 }
804 tprintf("]}");
805 return 1;
806#endif /* I_LIST */
807#ifdef I_ATMARK
808 case I_ATMARK:
809 tprintf(", ");
810 printxval(stream_atmark_options, arg, "???MARK");
811 return 1;
812#endif /* I_ATMARK */
813 default:
814 return 0;
815 }
816}
817
818#endif /* linux */
819
820#endif /* LINUXSPARC && linux */
821