Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com> |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 3 | * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 4 | * 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 Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 27 | */ |
| 28 | |
| 29 | #include "defs.h" |
Wichert Akkerman | 42080d8 | 2001-04-10 10:32:26 +0000 | [diff] [blame] | 30 | |
Denys Vlasenko | cc90291 | 2013-03-05 16:50:12 +0100 | [diff] [blame] | 31 | /* 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. Levin | 716fb20 | 2015-07-20 21:37:24 +0000 | [diff] [blame] | 35 | #if (defined SPARC || defined SPARC64) \ |
| 36 | && (defined SYS_putpmsg || defined SYS_getpmsg) |
Denys Vlasenko | cc90291 | 2013-03-05 16:50:12 +0100 | [diff] [blame] | 37 | |
| 38 | # ifdef HAVE_STROPTS_H |
| 39 | # include <stropts.h> |
| 40 | # else |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 41 | struct strbuf { |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 42 | int maxlen; /* no. of bytes in buffer */ |
| 43 | int len; /* no. of bytes returned */ |
Dmitry V. Levin | 30145dd | 2010-09-06 22:08:24 +0000 | [diff] [blame] | 44 | const char *buf; /* pointer to data */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 45 | }; |
Denys Vlasenko | cc90291 | 2013-03-05 16:50:12 +0100 | [diff] [blame] | 46 | # define MORECTL 1 |
| 47 | # define MOREDATA 2 |
| 48 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 49 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 50 | static void |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 51 | printstrbuf(struct tcb *tcp, struct strbuf *sbp, int getting) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 52 | { |
| 53 | if (sbp->maxlen == -1 && getting) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 54 | tprints("{maxlen=-1}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 55 | else { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 56 | tprints("{"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 57 | if (getting) |
| 58 | tprintf("maxlen=%d, ", sbp->maxlen); |
| 59 | tprintf("len=%d, buf=", sbp->len); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 60 | printstr(tcp, (unsigned long) sbp->buf, sbp->len); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 61 | tprints("}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 62 | } |
| 63 | } |
| 64 | |
| 65 | static void |
Denys Vlasenko | e7db465 | 2013-03-05 16:17:46 +0100 | [diff] [blame] | 66 | printstrbufarg(struct tcb *tcp, long arg, int getting) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 67 | { |
| 68 | struct strbuf buf; |
| 69 | |
| 70 | if (arg == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 71 | tprints("NULL"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 72 | else if (umove(tcp, arg, &buf) < 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 73 | tprints("{...}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 74 | else |
| 75 | printstrbuf(tcp, &buf, getting); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 76 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 77 | } |
| 78 | |
Dmitry V. Levin | 716fb20 | 2015-07-20 21:37:24 +0000 | [diff] [blame] | 79 | # include "xlat/pmsgflags.h" |
| 80 | # ifdef SYS_putpmsg |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 81 | SYS_FUNC(putpmsg) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 82 | { |
| 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 McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 94 | printflags(pmsgflags, tcp->u_arg[4], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 95 | } |
| 96 | return 0; |
| 97 | } |
Dmitry V. Levin | 716fb20 | 2015-07-20 21:37:24 +0000 | [diff] [blame] | 98 | # endif |
| 99 | # ifdef SYS_getpmsg |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 100 | SYS_FUNC(getpmsg) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 101 | { |
| 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. Levin | f55cca7 | 2015-02-17 22:00:45 +0000 | [diff] [blame] | 117 | printnum_int(tcp, tcp->u_arg[3], "%d"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 118 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 119 | /* pointer to flags */ |
| 120 | if (tcp->u_arg[4] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 121 | tprints("NULL"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 122 | else if (umove(tcp, tcp->u_arg[4], &flags) < 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 123 | tprints("[?]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 124 | else { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 125 | tprints("["); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 126 | printflags(pmsgflags, flags, "MSG_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 127 | tprints("]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 128 | } |
| 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. Levin | 716fb20 | 2015-07-20 21:37:24 +0000 | [diff] [blame] | 147 | # endif |
Denys Vlasenko | cc90291 | 2013-03-05 16:50:12 +0100 | [diff] [blame] | 148 | #endif /* STREAMS syscalls support */ |