]> granicus.if.org Git - strace/blob - stream.c
Initial revision
[strace] / stream.c
1 /*
2  * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. The name of the author may not be used to endorse or promote products
14  *    derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  *      $Id$
28  */
29
30 #include "defs.h"
31
32 #if defined(HAVE_SYS_STREAM_H) || defined(LINUXSPARC) || defined(linux)
33
34 #if defined(LINUXSPARC) || defined(linux)
35 #include <sys/poll.h>
36
37 #define RS_HIPRI 1
38 struct strbuf {
39         int     maxlen;                 /* no. of bytes in buffer */
40         int     len;                    /* no. of bytes returned */
41         char    *buf;                   /* pointer to data */
42 };
43 #define MORECTL 1
44 #define MOREDATA 2
45
46 #else /* LINUXSPARC */
47
48 #include <stropts.h>
49 #include <poll.h>
50 #include <sys/conf.h>
51 #include <sys/stream.h>
52 #include <sys/tihdr.h>
53
54 #endif /* LINUXSPARC */
55
56 #ifdef HAVE_SYS_TIUSER_H
57 #include <sys/tiuser.h>
58 #include <sys/sockmod.h>
59 #include <sys/timod.h>
60 #endif /* HAVE_SYS_TIUSER_H */
61
62 static struct xlat msgflags[] = {
63         { RS_HIPRI,     "RS_HIPRI"      },
64         { 0,            NULL            },
65 };
66
67 #if 0
68 static struct xlat getmsgflags[] = {
69         { MORECTL,      "MORECTL"       },
70         { MOREDATA,     "MOREDATA"      },
71         { 0,            NULL            },
72 };
73 #endif
74
75 static void
76 printstrbuf(tcp, sbp, getting)
77 struct tcb *tcp;
78 struct strbuf *sbp;
79 int getting;
80 {
81         if (sbp->maxlen == -1 && getting)
82                 tprintf("{maxlen=-1}");
83         else {
84                 tprintf("{");
85                 if (getting)
86                         tprintf("maxlen=%d, ", sbp->maxlen);
87                 tprintf("len=%d, buf=", sbp->len);
88                 printstr(tcp, (int) sbp->buf, sbp->len);
89                 tprintf("}");
90         }
91 }
92
93 static void
94 printstrbufarg(tcp, arg, getting)
95 struct tcb *tcp;
96 int arg;
97 int getting;
98 {
99         struct strbuf buf;
100
101         if (arg == 0)
102                 tprintf("NULL");
103         else if (umove(tcp, arg, &buf) < 0)
104                 tprintf("{...}");
105         else
106                 printstrbuf(tcp, &buf, getting);
107         tprintf(", ");
108 }
109
110 int
111 sys_putmsg(tcp)
112 struct tcb *tcp;
113 {
114         int i;
115
116         if (entering(tcp)) {
117                 /* fd */
118                 tprintf("%ld, ", tcp->u_arg[0]);
119                 /* control and data */
120                 for (i = 1; i < 3; i++)
121                         printstrbufarg(tcp, tcp->u_arg[i], 0);
122                 /* flags */
123                 if (!printflags(msgflags, tcp->u_arg[3]))
124                         tprintf("0");
125         }
126         return 0;
127 }
128
129 int
130 sys_getmsg(tcp)
131 struct tcb *tcp;
132 {
133         int i, flags;
134
135         if (entering(tcp)) {
136                 /* fd */
137                 tprintf("%lu, ", tcp->u_arg[0]);
138         } else {
139                 if (syserror(tcp)) {
140                         tprintf("%#lx, %#lx, %#lx",
141                                 tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
142                         return 0;
143                 }
144                 /* control and data */
145                 for (i = 1; i < 3; i++)
146                         printstrbufarg(tcp, tcp->u_arg[i], 1);
147                 /* pointer to flags */
148                 if (tcp->u_arg[3] == 0)
149                         tprintf("NULL");
150                 else if (umove(tcp, tcp->u_arg[3], &flags) < 0)
151                         tprintf("[?]");
152                 else {
153                         tprintf("[");
154                         if (!printflags(msgflags, flags))
155                                 tprintf("0");
156                         tprintf("]");
157                 }
158                 /* decode return value */
159                 switch (tcp->u_rval) {
160                 case MORECTL:
161                         tcp->auxstr = "MORECTL";
162                         break;
163                 case MORECTL|MOREDATA:
164                         tcp->auxstr = "MORECTL|MOREDATA";
165                         break;
166                 case MOREDATA:
167                         tcp->auxstr = "MORECTL";
168                         break;
169                 default:
170                         tcp->auxstr = NULL;
171                         break;
172                 }
173         }
174         return RVAL_HEX | RVAL_STR;
175 }
176
177 #ifdef HAVE_PUTPMSG
178
179 static struct xlat pmsgflags[] = {
180         { MSG_HIPRI,    "MSG_HIPRI"     },
181         { MSG_ANY,      "MSG_ANY"       },
182         { MSG_BAND,     "MSG_BAND"      },
183         { 0,            NULL            },
184 };
185
186 int
187 sys_putpmsg(tcp)
188 struct tcb *tcp;
189 {
190         int i;
191
192         if (entering(tcp)) {
193                 /* fd */
194                 tprintf("%ld, ", tcp->u_arg[0]);
195                 /* control and data */
196                 for (i = 1; i < 3; i++)
197                         printstrbufarg(tcp, tcp->u_arg[i], 0);
198                 /* band */
199                 tprintf("%ld, ", tcp->u_arg[3]);
200                 /* flags */
201                 if (!printflags(pmsgflags, tcp->u_arg[4]))
202                         tprintf("0");
203         }
204         return 0;
205 }
206
207 int
208 sys_getpmsg(tcp)
209 struct tcb *tcp;
210 {
211         int i, flags;
212
213         if (entering(tcp)) {
214                 /* fd */
215                 tprintf("%lu, ", tcp->u_arg[0]);
216         } else {
217                 if (syserror(tcp)) {
218                         tprintf("%#lx, %#lx, %#lx, %#lx", tcp->u_arg[1],
219                                 tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[4]);
220                         return 0;
221                 }
222                 /* control and data */
223                 for (i = 1; i < 3; i++)
224                         printstrbufarg(tcp, tcp->u_arg[i], 1);
225                 /* pointer to band */
226                 printnum(tcp, tcp->u_arg[3], "%d");
227                 /* pointer to flags */
228                 if (tcp->u_arg[4] == 0)
229                         tprintf("NULL");
230                 else if (umove(tcp, tcp->u_arg[4], &flags) < 0)
231                         tprintf("[?]");
232                 else {
233                         tprintf("[");
234                         if (!printflags(pmsgflags, flags))
235                                 tprintf("0");
236                         tprintf("]");
237                 }
238                 /* decode return value */
239                 switch (tcp->u_rval) {
240                 case MORECTL:
241                         tcp->auxstr = "MORECTL";
242                         break;
243                 case MORECTL|MOREDATA:
244                         tcp->auxstr = "MORECTL|MOREDATA";
245                         break;
246                 case MOREDATA:
247                         tcp->auxstr = "MORECTL";
248                         break;
249                 default:
250                         tcp->auxstr = NULL;
251                         break;
252                 }
253         }
254         return RVAL_HEX | RVAL_STR;
255 }
256
257 #endif /* HAVE_PUTPMSG */
258
259 #if !defined(LINUXSPARC)
260
261 static struct xlat pollflags[] = {
262         { POLLIN,       "POLLIN"        },
263         { POLLPRI,      "POLLPRI"       },
264         { POLLOUT,      "POLLOUT"       },
265 #ifdef POLLRDNORM
266         { POLLRDNORM,   "POLLRDNORM"    },
267 #endif
268 #ifdef POLLWRNORM
269         { POLLWRNORM,   "POLLWRNORM"    },
270 #endif
271 #ifdef POLLRDBAND
272         { POLLRDBAND,   "POLLRDBAND"    },
273 #endif
274 #ifdef POLLWRBAND
275         { POLLWRBAND,   "POLLWRBAND"    },
276 #endif
277         { POLLERR,      "POLLERR"       },
278         { POLLHUP,      "POLLHUP"       },
279         { POLLNVAL,     "POLLNVAL"      },
280         { 0,            NULL            },
281 };
282
283 int
284 sys_poll(tcp)
285 struct tcb *tcp;
286 {
287         struct pollfd *pollp;
288
289         if (exiting(tcp)) {
290                 int i;
291                 int nfds = tcp->u_arg[1];
292
293                 if (nfds <= 0) {
294                         tprintf("%#lx, %d, %ld\n",
295                                 tcp->u_arg[0], nfds, tcp->u_arg[2]);
296                         return 0;
297                 }
298                 pollp = (struct pollfd *) malloc(nfds * sizeof(*pollp));
299                 if (pollp == NULL) {
300                         fprintf(stderr, "sys_poll: no memory\n");
301                         tprintf("%#lx, %d, %ld",
302                                 tcp->u_arg[0], nfds, tcp->u_arg[2]);
303                         return 0;
304                 }
305                 if (umoven(tcp, tcp->u_arg[0],
306                            (nfds * sizeof(*pollp)), (char *) pollp) < 0) {
307                         tprintf("%#lx", tcp->u_arg[0]);
308                 }
309                 else {
310                         tprintf("[");
311                         for (i = 0; i < nfds; i++) {
312                                 if (i)
313                                         tprintf(", ");
314                                 if (pollp[i].fd < 0) {
315                                         tprintf("{fd=%d}", pollp[i].fd);
316                                         continue;
317                                 }
318                                 tprintf("{fd=%d, events=", pollp[i].fd);
319                                 if (!printflags(pollflags, pollp[i].events))
320                                         tprintf("0");
321                                 if (!syserror(tcp) && pollp[i].revents) {
322                                         tprintf(", revents=");
323                                         if (!printflags(pollflags,
324                                                         pollp[i].revents))
325                                                 tprintf("0");
326                                 }
327                                 tprintf("}");
328                         }
329                         tprintf("]");
330                 }
331                 tprintf(", %d, ", nfds);
332 #ifdef INFTIM
333                 if (tcp->u_arg[2] == INFTIM)
334                         tprintf("INFTIM");
335                 else
336 #endif
337                         tprintf("%ld", tcp->u_arg[2]);
338                 free(pollp);
339         }
340         return 0;
341 }
342
343 #ifndef linux
344
345 static 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
355 static 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
384 static struct xlat stream_read_options[] = {
385         { RNORM,        "RNORM"         },
386         { RMSGD,        "RMSGD"         },
387         { RMSGN,        "RMSGN"         },
388         { 0,            NULL            },
389 };
390
391 static 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
409 static struct xlat stream_write_flags[] = {
410         { SNDZERO,      "SNDZERO"       },
411         { SNDPIPE,      "SNDPIPE"       },
412         { 0,            NULL            },
413 };
414 #endif /* I_SWROPT */
415
416 #ifdef I_ATMARK
417 static struct xlat stream_atmark_options[] = {
418         { ANYMARK,      "ANYMARK"       },
419         { LASTMARK,     "LASTMARK"      },
420         { 0,            NULL            },
421 };
422 #endif /* I_ATMARK */
423
424 #ifdef TI_BIND
425 static 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
440 static 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
458 static int
459 internal_stream_ioctl(tcp, arg)
460 struct tcb *tcp;
461 int 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
602 int
603 stream_ioctl(tcp, code, arg)
604 struct tcb *tcp;
605 int 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
822 #endif /* HAVE_SYS_STREAM_H */