blob: e1836a20dc0d2e58fe2911fe0d69ffb2501ea7bd [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.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000027 */
28
29#include "defs.h"
Wichert Akkerman42080d82001-04-10 10:32:26 +000030
Denys Vlasenkocc902912013-03-05 16:50:12 +010031/* Who has STREAMS syscalls?
32 * Linux hasn't. Solaris has (had?).
33 * Just in case I miss something, retain in for Sparc...
34 */
Dmitry V. Levin716fb202015-07-20 21:37:24 +000035#if (defined SPARC || defined SPARC64) \
36 && (defined SYS_putpmsg || defined SYS_getpmsg)
Denys Vlasenkocc902912013-03-05 16:50:12 +010037
38# ifdef HAVE_STROPTS_H
39# include <stropts.h>
40# else
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000041struct strbuf {
Denys Vlasenkoadedb512008-12-30 18:47:55 +000042 int maxlen; /* no. of bytes in buffer */
43 int len; /* no. of bytes returned */
Dmitry V. Levin30145dd2010-09-06 22:08:24 +000044 const char *buf; /* pointer to data */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000045};
Denys Vlasenkocc902912013-03-05 16:50:12 +010046# define MORECTL 1
47# define MOREDATA 2
48# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000049
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000050static void
Denys Vlasenko12014262011-05-30 14:00:14 +020051printstrbuf(struct tcb *tcp, struct strbuf *sbp, int getting)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000052{
53 if (sbp->maxlen == -1 && getting)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020054 tprints("{maxlen=-1}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000055 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020056 tprints("{");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000057 if (getting)
58 tprintf("maxlen=%d, ", sbp->maxlen);
59 tprintf("len=%d, buf=", sbp->len);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +000060 printstr(tcp, (unsigned long) sbp->buf, sbp->len);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020061 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000062 }
63}
64
65static void
Denys Vlasenkoe7db4652013-03-05 16:17:46 +010066printstrbufarg(struct tcb *tcp, long arg, int getting)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000067{
68 struct strbuf buf;
69
70 if (arg == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020071 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000072 else if (umove(tcp, arg, &buf) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020073 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000074 else
75 printstrbuf(tcp, &buf, getting);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020076 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000077}
78
Dmitry V. Levin716fb202015-07-20 21:37:24 +000079# include "xlat/pmsgflags.h"
80# ifdef SYS_putpmsg
Dmitry V. Levina0bd3742015-04-07 01:36:50 +000081SYS_FUNC(putpmsg)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000082{
83 int i;
84
85 if (entering(tcp)) {
86 /* fd */
87 tprintf("%ld, ", tcp->u_arg[0]);
88 /* control and data */
89 for (i = 1; i < 3; i++)
90 printstrbufarg(tcp, tcp->u_arg[i], 0);
91 /* band */
92 tprintf("%ld, ", tcp->u_arg[3]);
93 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +000094 printflags(pmsgflags, tcp->u_arg[4], "MSG_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000095 }
96 return 0;
97}
Dmitry V. Levin716fb202015-07-20 21:37:24 +000098# endif
99# ifdef SYS_getpmsg
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000100SYS_FUNC(getpmsg)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000101{
102 int i, flags;
103
104 if (entering(tcp)) {
105 /* fd */
106 tprintf("%lu, ", tcp->u_arg[0]);
107 } else {
108 if (syserror(tcp)) {
109 tprintf("%#lx, %#lx, %#lx, %#lx", tcp->u_arg[1],
110 tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[4]);
111 return 0;
112 }
113 /* control and data */
114 for (i = 1; i < 3; i++)
115 printstrbufarg(tcp, tcp->u_arg[i], 1);
116 /* pointer to band */
Dmitry V. Levinf55cca72015-02-17 22:00:45 +0000117 printnum_int(tcp, tcp->u_arg[3], "%d");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200118 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000119 /* pointer to flags */
120 if (tcp->u_arg[4] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200121 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000122 else if (umove(tcp, tcp->u_arg[4], &flags) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200123 tprints("[?]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000124 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200125 tprints("[");
Roland McGrathb2dee132005-06-01 19:02:36 +0000126 printflags(pmsgflags, flags, "MSG_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200127 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000128 }
129 /* decode return value */
130 switch (tcp->u_rval) {
131 case MORECTL:
132 tcp->auxstr = "MORECTL";
133 break;
134 case MORECTL|MOREDATA:
135 tcp->auxstr = "MORECTL|MOREDATA";
136 break;
137 case MOREDATA:
138 tcp->auxstr = "MORECTL";
139 break;
140 default:
141 tcp->auxstr = NULL;
142 break;
143 }
144 }
145 return RVAL_HEX | RVAL_STR;
146}
Dmitry V. Levin716fb202015-07-20 21:37:24 +0000147# endif
Denys Vlasenkocc902912013-03-05 16:50:12 +0100148#endif /* STREAMS syscalls support */