1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28*0Sstevel@tonic-gate /*	  All Rights Reserved  	*/
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate 
31*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
32*0Sstevel@tonic-gate 
33*0Sstevel@tonic-gate #define	_SYSCALL32
34*0Sstevel@tonic-gate 
35*0Sstevel@tonic-gate #include <stdio.h>
36*0Sstevel@tonic-gate #include <stdlib.h>
37*0Sstevel@tonic-gate #include <unistd.h>
38*0Sstevel@tonic-gate #include <ctype.h>
39*0Sstevel@tonic-gate #include <sys/types.h>
40*0Sstevel@tonic-gate #include <sys/mman.h>
41*0Sstevel@tonic-gate #include <libproc.h>
42*0Sstevel@tonic-gate #include <string.h>
43*0Sstevel@tonic-gate #include <limits.h>
44*0Sstevel@tonic-gate #include <sys/statfs.h>
45*0Sstevel@tonic-gate #include <sys/times.h>
46*0Sstevel@tonic-gate #include <sys/timex.h>
47*0Sstevel@tonic-gate #include <sys/utssys.h>
48*0Sstevel@tonic-gate #include <sys/utsname.h>
49*0Sstevel@tonic-gate #include <sys/ipc.h>
50*0Sstevel@tonic-gate #include <sys/ipc_impl.h>
51*0Sstevel@tonic-gate #include <sys/msg.h>
52*0Sstevel@tonic-gate #include <sys/msg_impl.h>
53*0Sstevel@tonic-gate #include <sys/sem.h>
54*0Sstevel@tonic-gate #include <sys/sem_impl.h>
55*0Sstevel@tonic-gate #include <sys/shm.h>
56*0Sstevel@tonic-gate #include <sys/shm_impl.h>
57*0Sstevel@tonic-gate #include <sys/dirent.h>
58*0Sstevel@tonic-gate #include <sys/utime.h>
59*0Sstevel@tonic-gate #include <ustat.h>
60*0Sstevel@tonic-gate #include <fcntl.h>
61*0Sstevel@tonic-gate #include <time.h>
62*0Sstevel@tonic-gate #include <sys/termios.h>
63*0Sstevel@tonic-gate #include <sys/termiox.h>
64*0Sstevel@tonic-gate #include <sys/termio.h>
65*0Sstevel@tonic-gate #include <sys/ttold.h>
66*0Sstevel@tonic-gate #include <sys/jioctl.h>
67*0Sstevel@tonic-gate #include <sys/filio.h>
68*0Sstevel@tonic-gate #include <stropts.h>
69*0Sstevel@tonic-gate #include <poll.h>
70*0Sstevel@tonic-gate #include <sys/uio.h>
71*0Sstevel@tonic-gate #include <sys/resource.h>
72*0Sstevel@tonic-gate #include <sys/statvfs.h>
73*0Sstevel@tonic-gate #include <sys/time.h>
74*0Sstevel@tonic-gate #include <sys/aio.h>
75*0Sstevel@tonic-gate #include <sys/socket.h>
76*0Sstevel@tonic-gate #include <netinet/in.h>
77*0Sstevel@tonic-gate #include <sys/un.h>
78*0Sstevel@tonic-gate #include <sys/byteorder.h>
79*0Sstevel@tonic-gate #include <arpa/inet.h>
80*0Sstevel@tonic-gate #include <sys/audioio.h>
81*0Sstevel@tonic-gate #include <sys/cladm.h>
82*0Sstevel@tonic-gate #include <sys/synch.h>
83*0Sstevel@tonic-gate #include <sys/synch32.h>
84*0Sstevel@tonic-gate #include <sys/sysmacros.h>
85*0Sstevel@tonic-gate #include <sys/sendfile.h>
86*0Sstevel@tonic-gate #include <priv.h>
87*0Sstevel@tonic-gate #include <ucred.h>
88*0Sstevel@tonic-gate #include <sys/ucred.h>
89*0Sstevel@tonic-gate #include <sys/port_impl.h>
90*0Sstevel@tonic-gate 
91*0Sstevel@tonic-gate #include "ramdata.h"
92*0Sstevel@tonic-gate #include "systable.h"
93*0Sstevel@tonic-gate #include "proto.h"
94*0Sstevel@tonic-gate 
95*0Sstevel@tonic-gate void	show_sigset(private_t *, long, const char *);
96*0Sstevel@tonic-gate void	show_ioctl(private_t *, int, long);
97*0Sstevel@tonic-gate 
98*0Sstevel@tonic-gate void
99*0Sstevel@tonic-gate prtime(private_t *pri, const char *name, time_t value)
100*0Sstevel@tonic-gate {
101*0Sstevel@tonic-gate 	char str[80];
102*0Sstevel@tonic-gate 
103*0Sstevel@tonic-gate 	(void) strftime(str, sizeof (str), "%b %e %H:%M:%S %Z %Y",
104*0Sstevel@tonic-gate 		localtime(&value));
105*0Sstevel@tonic-gate 	(void) printf("%s\t%s%s  [ %llu ]\n",
106*0Sstevel@tonic-gate 	    pri->pname,
107*0Sstevel@tonic-gate 	    name,
108*0Sstevel@tonic-gate 	    str,
109*0Sstevel@tonic-gate 	    (longlong_t)value);
110*0Sstevel@tonic-gate }
111*0Sstevel@tonic-gate 
112*0Sstevel@tonic-gate void
113*0Sstevel@tonic-gate prtimestruc(private_t *pri, const char *name, timestruc_t *value)
114*0Sstevel@tonic-gate {
115*0Sstevel@tonic-gate 	prtime(pri, name, value->tv_sec);
116*0Sstevel@tonic-gate }
117*0Sstevel@tonic-gate 
118*0Sstevel@tonic-gate void
119*0Sstevel@tonic-gate show_utime(private_t *pri)
120*0Sstevel@tonic-gate {
121*0Sstevel@tonic-gate 	long offset;
122*0Sstevel@tonic-gate 	struct utimbuf utimbuf;
123*0Sstevel@tonic-gate 
124*0Sstevel@tonic-gate 	if (pri->sys_nargs < 2 || (offset = pri->sys_args[1]) == NULL)
125*0Sstevel@tonic-gate 		return;
126*0Sstevel@tonic-gate 
127*0Sstevel@tonic-gate 	if (data_model == PR_MODEL_NATIVE) {
128*0Sstevel@tonic-gate 		if (Pread(Proc, &utimbuf, sizeof (utimbuf), offset)
129*0Sstevel@tonic-gate 		    != sizeof (utimbuf))
130*0Sstevel@tonic-gate 			return;
131*0Sstevel@tonic-gate 	} else {
132*0Sstevel@tonic-gate 		struct utimbuf32 utimbuf32;
133*0Sstevel@tonic-gate 
134*0Sstevel@tonic-gate 		if (Pread(Proc, &utimbuf32, sizeof (utimbuf32), offset)
135*0Sstevel@tonic-gate 		    != sizeof (utimbuf32))
136*0Sstevel@tonic-gate 			return;
137*0Sstevel@tonic-gate 
138*0Sstevel@tonic-gate 		utimbuf.actime = (time_t)utimbuf32.actime;
139*0Sstevel@tonic-gate 		utimbuf.modtime = (time_t)utimbuf32.modtime;
140*0Sstevel@tonic-gate 	}
141*0Sstevel@tonic-gate 
142*0Sstevel@tonic-gate 	/* print access and modification times */
143*0Sstevel@tonic-gate 	prtime(pri, "atime: ", utimbuf.actime);
144*0Sstevel@tonic-gate 	prtime(pri, "mtime: ", utimbuf.modtime);
145*0Sstevel@tonic-gate }
146*0Sstevel@tonic-gate 
147*0Sstevel@tonic-gate void
148*0Sstevel@tonic-gate show_utimes(private_t *pri)
149*0Sstevel@tonic-gate {
150*0Sstevel@tonic-gate 	long offset;
151*0Sstevel@tonic-gate 	struct {
152*0Sstevel@tonic-gate 		struct timeval	atime;
153*0Sstevel@tonic-gate 		struct timeval	mtime;
154*0Sstevel@tonic-gate 	} utimbuf;
155*0Sstevel@tonic-gate 
156*0Sstevel@tonic-gate 	if (pri->sys_nargs < 2 || (offset = pri->sys_args[1]) == NULL)
157*0Sstevel@tonic-gate 		return;
158*0Sstevel@tonic-gate 
159*0Sstevel@tonic-gate 	if (data_model == PR_MODEL_NATIVE) {
160*0Sstevel@tonic-gate 		if (Pread(Proc, &utimbuf, sizeof (utimbuf), offset)
161*0Sstevel@tonic-gate 		    != sizeof (utimbuf))
162*0Sstevel@tonic-gate 			return;
163*0Sstevel@tonic-gate 	} else {
164*0Sstevel@tonic-gate 		struct {
165*0Sstevel@tonic-gate 			struct timeval32 atime;
166*0Sstevel@tonic-gate 			struct timeval32 mtime;
167*0Sstevel@tonic-gate 		} utimbuf32;
168*0Sstevel@tonic-gate 
169*0Sstevel@tonic-gate 		if (Pread(Proc, &utimbuf32, sizeof (utimbuf32), offset)
170*0Sstevel@tonic-gate 		    != sizeof (utimbuf32))
171*0Sstevel@tonic-gate 			return;
172*0Sstevel@tonic-gate 
173*0Sstevel@tonic-gate 		TIMEVAL32_TO_TIMEVAL(&utimbuf.atime, &utimbuf32.atime);
174*0Sstevel@tonic-gate 		TIMEVAL32_TO_TIMEVAL(&utimbuf.mtime, &utimbuf32.mtime);
175*0Sstevel@tonic-gate 	}
176*0Sstevel@tonic-gate 
177*0Sstevel@tonic-gate 	/* print access and modification times */
178*0Sstevel@tonic-gate 	prtime(pri, "atime: ", utimbuf.atime.tv_sec);
179*0Sstevel@tonic-gate 	prtime(pri, "mtime: ", utimbuf.mtime.tv_sec);
180*0Sstevel@tonic-gate }
181*0Sstevel@tonic-gate 
182*0Sstevel@tonic-gate void
183*0Sstevel@tonic-gate show_timeofday(private_t *pri)
184*0Sstevel@tonic-gate {
185*0Sstevel@tonic-gate 	struct timeval tod;
186*0Sstevel@tonic-gate 	long offset;
187*0Sstevel@tonic-gate 
188*0Sstevel@tonic-gate 	if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == NULL)
189*0Sstevel@tonic-gate 		return;
190*0Sstevel@tonic-gate 
191*0Sstevel@tonic-gate 	if (data_model == PR_MODEL_NATIVE) {
192*0Sstevel@tonic-gate 		if (Pread(Proc, &tod, sizeof (tod), offset)
193*0Sstevel@tonic-gate 		    != sizeof (tod))
194*0Sstevel@tonic-gate 			return;
195*0Sstevel@tonic-gate 	} else {
196*0Sstevel@tonic-gate 		struct timeval32 tod32;
197*0Sstevel@tonic-gate 
198*0Sstevel@tonic-gate 		if (Pread(Proc, &tod32, sizeof (tod32), offset)
199*0Sstevel@tonic-gate 		    != sizeof (tod32))
200*0Sstevel@tonic-gate 			return;
201*0Sstevel@tonic-gate 
202*0Sstevel@tonic-gate 		TIMEVAL32_TO_TIMEVAL(&tod, &tod32);
203*0Sstevel@tonic-gate 	}
204*0Sstevel@tonic-gate 
205*0Sstevel@tonic-gate 	prtime(pri, "time: ", tod.tv_sec);
206*0Sstevel@tonic-gate }
207*0Sstevel@tonic-gate 
208*0Sstevel@tonic-gate void
209*0Sstevel@tonic-gate show_itimerval(private_t *pri, long offset, const char *name)
210*0Sstevel@tonic-gate {
211*0Sstevel@tonic-gate 	struct itimerval itimerval;
212*0Sstevel@tonic-gate 
213*0Sstevel@tonic-gate 	if (offset == NULL)
214*0Sstevel@tonic-gate 		return;
215*0Sstevel@tonic-gate 
216*0Sstevel@tonic-gate 	if (data_model == PR_MODEL_NATIVE) {
217*0Sstevel@tonic-gate 		if (Pread(Proc, &itimerval, sizeof (itimerval), offset)
218*0Sstevel@tonic-gate 		    != sizeof (itimerval))
219*0Sstevel@tonic-gate 			return;
220*0Sstevel@tonic-gate 	} else {
221*0Sstevel@tonic-gate 		struct itimerval32 itimerval32;
222*0Sstevel@tonic-gate 
223*0Sstevel@tonic-gate 		if (Pread(Proc, &itimerval32, sizeof (itimerval32), offset)
224*0Sstevel@tonic-gate 		    != sizeof (itimerval32))
225*0Sstevel@tonic-gate 			return;
226*0Sstevel@tonic-gate 
227*0Sstevel@tonic-gate 		ITIMERVAL32_TO_ITIMERVAL(&itimerval, &itimerval32);
228*0Sstevel@tonic-gate 	}
229*0Sstevel@tonic-gate 
230*0Sstevel@tonic-gate 	(void) printf(
231*0Sstevel@tonic-gate 	    "%s\t%s:  interval: %4ld.%6.6ld sec  value: %4ld.%6.6ld sec\n",
232*0Sstevel@tonic-gate 	    pri->pname,
233*0Sstevel@tonic-gate 	    name,
234*0Sstevel@tonic-gate 	    itimerval.it_interval.tv_sec,
235*0Sstevel@tonic-gate 	    itimerval.it_interval.tv_usec,
236*0Sstevel@tonic-gate 	    itimerval.it_value.tv_sec,
237*0Sstevel@tonic-gate 	    itimerval.it_value.tv_usec);
238*0Sstevel@tonic-gate }
239*0Sstevel@tonic-gate 
240*0Sstevel@tonic-gate void
241*0Sstevel@tonic-gate show_timeval(private_t *pri, long offset, const char *name)
242*0Sstevel@tonic-gate {
243*0Sstevel@tonic-gate 	struct timeval timeval;
244*0Sstevel@tonic-gate 
245*0Sstevel@tonic-gate 	if (offset == NULL)
246*0Sstevel@tonic-gate 		return;
247*0Sstevel@tonic-gate 
248*0Sstevel@tonic-gate 	if (data_model == PR_MODEL_NATIVE) {
249*0Sstevel@tonic-gate 		if (Pread(Proc, &timeval, sizeof (timeval), offset)
250*0Sstevel@tonic-gate 		    != sizeof (timeval))
251*0Sstevel@tonic-gate 			return;
252*0Sstevel@tonic-gate 	} else {
253*0Sstevel@tonic-gate 		struct timeval32 timeval32;
254*0Sstevel@tonic-gate 
255*0Sstevel@tonic-gate 		if (Pread(Proc, &timeval32, sizeof (timeval32), offset)
256*0Sstevel@tonic-gate 		    != sizeof (timeval32))
257*0Sstevel@tonic-gate 			return;
258*0Sstevel@tonic-gate 
259*0Sstevel@tonic-gate 		TIMEVAL32_TO_TIMEVAL(&timeval, &timeval32);
260*0Sstevel@tonic-gate 	}
261*0Sstevel@tonic-gate 
262*0Sstevel@tonic-gate 	(void) printf(
263*0Sstevel@tonic-gate 	    "%s\t%s: %ld.%6.6ld sec\n",
264*0Sstevel@tonic-gate 	    pri->pname,
265*0Sstevel@tonic-gate 	    name,
266*0Sstevel@tonic-gate 	    timeval.tv_sec,
267*0Sstevel@tonic-gate 	    timeval.tv_usec);
268*0Sstevel@tonic-gate }
269*0Sstevel@tonic-gate 
270*0Sstevel@tonic-gate void
271*0Sstevel@tonic-gate show_timestruc(private_t *pri, long offset, const char *name)
272*0Sstevel@tonic-gate {
273*0Sstevel@tonic-gate 	timestruc_t timestruc;
274*0Sstevel@tonic-gate 
275*0Sstevel@tonic-gate 	if (offset == NULL)
276*0Sstevel@tonic-gate 		return;
277*0Sstevel@tonic-gate 
278*0Sstevel@tonic-gate 	if (data_model == PR_MODEL_NATIVE) {
279*0Sstevel@tonic-gate 		if (Pread(Proc, &timestruc, sizeof (timestruc), offset)
280*0Sstevel@tonic-gate 		    != sizeof (timestruc))
281*0Sstevel@tonic-gate 			return;
282*0Sstevel@tonic-gate 	} else {
283*0Sstevel@tonic-gate 		timestruc32_t timestruc32;
284*0Sstevel@tonic-gate 
285*0Sstevel@tonic-gate 		if (Pread(Proc, &timestruc32, sizeof (timestruc32), offset)
286*0Sstevel@tonic-gate 		    != sizeof (timestruc32))
287*0Sstevel@tonic-gate 			return;
288*0Sstevel@tonic-gate 
289*0Sstevel@tonic-gate 		TIMESPEC32_TO_TIMESPEC(&timestruc, &timestruc32);
290*0Sstevel@tonic-gate 	}
291*0Sstevel@tonic-gate 
292*0Sstevel@tonic-gate 	(void) printf(
293*0Sstevel@tonic-gate 	    "%s\t%s: %ld.%9.9ld sec\n",
294*0Sstevel@tonic-gate 	    pri->pname,
295*0Sstevel@tonic-gate 	    name,
296*0Sstevel@tonic-gate 	    timestruc.tv_sec,
297*0Sstevel@tonic-gate 	    timestruc.tv_nsec);
298*0Sstevel@tonic-gate }
299*0Sstevel@tonic-gate 
300*0Sstevel@tonic-gate void
301*0Sstevel@tonic-gate show_stime(private_t *pri)
302*0Sstevel@tonic-gate {
303*0Sstevel@tonic-gate 	if (pri->sys_nargs >= 1) {
304*0Sstevel@tonic-gate 		/* print new system time */
305*0Sstevel@tonic-gate 		prtime(pri, "systime = ", (time_t)pri->sys_args[0]);
306*0Sstevel@tonic-gate 	}
307*0Sstevel@tonic-gate }
308*0Sstevel@tonic-gate 
309*0Sstevel@tonic-gate void
310*0Sstevel@tonic-gate show_times(private_t *pri)
311*0Sstevel@tonic-gate {
312*0Sstevel@tonic-gate 	long hz = sysconf(_SC_CLK_TCK);
313*0Sstevel@tonic-gate 	long offset;
314*0Sstevel@tonic-gate 	struct tms tms;
315*0Sstevel@tonic-gate 
316*0Sstevel@tonic-gate 	if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == NULL)
317*0Sstevel@tonic-gate 		return;
318*0Sstevel@tonic-gate 
319*0Sstevel@tonic-gate 	if (data_model == PR_MODEL_NATIVE) {
320*0Sstevel@tonic-gate 		if (Pread(Proc, &tms, sizeof (tms), offset)
321*0Sstevel@tonic-gate 		    != sizeof (tms))
322*0Sstevel@tonic-gate 			return;
323*0Sstevel@tonic-gate 	} else {
324*0Sstevel@tonic-gate 		struct tms32 tms32;
325*0Sstevel@tonic-gate 
326*0Sstevel@tonic-gate 		if (Pread(Proc, &tms32, sizeof (tms32), offset)
327*0Sstevel@tonic-gate 		    != sizeof (tms32))
328*0Sstevel@tonic-gate 			return;
329*0Sstevel@tonic-gate 
330*0Sstevel@tonic-gate 		/*
331*0Sstevel@tonic-gate 		 * This looks a bit odd (since the values are actually
332*0Sstevel@tonic-gate 		 * signed), but we need to suppress sign extension to
333*0Sstevel@tonic-gate 		 * preserve compatibility (we've always printed these
334*0Sstevel@tonic-gate 		 * numbers as unsigned quantities).
335*0Sstevel@tonic-gate 		 */
336*0Sstevel@tonic-gate 		tms.tms_utime = (unsigned)tms32.tms_utime;
337*0Sstevel@tonic-gate 		tms.tms_stime = (unsigned)tms32.tms_stime;
338*0Sstevel@tonic-gate 		tms.tms_cutime = (unsigned)tms32.tms_cutime;
339*0Sstevel@tonic-gate 		tms.tms_cstime = (unsigned)tms32.tms_cstime;
340*0Sstevel@tonic-gate 	}
341*0Sstevel@tonic-gate 
342*0Sstevel@tonic-gate 	(void) printf(
343*0Sstevel@tonic-gate 	    "%s\tutim=%-6lu stim=%-6lu cutim=%-6lu cstim=%-6lu (HZ=%ld)\n",
344*0Sstevel@tonic-gate 	    pri->pname,
345*0Sstevel@tonic-gate 	    tms.tms_utime,
346*0Sstevel@tonic-gate 	    tms.tms_stime,
347*0Sstevel@tonic-gate 	    tms.tms_cutime,
348*0Sstevel@tonic-gate 	    tms.tms_cstime,
349*0Sstevel@tonic-gate 	    hz);
350*0Sstevel@tonic-gate }
351*0Sstevel@tonic-gate 
352*0Sstevel@tonic-gate void
353*0Sstevel@tonic-gate show_uname(private_t *pri, long offset)
354*0Sstevel@tonic-gate {
355*0Sstevel@tonic-gate 	/*
356*0Sstevel@tonic-gate 	 * Old utsname buffer (no longer accessible in <sys/utsname.h>).
357*0Sstevel@tonic-gate 	 */
358*0Sstevel@tonic-gate 	struct {
359*0Sstevel@tonic-gate 		char	sysname[9];
360*0Sstevel@tonic-gate 		char	nodename[9];
361*0Sstevel@tonic-gate 		char	release[9];
362*0Sstevel@tonic-gate 		char	version[9];
363*0Sstevel@tonic-gate 		char	machine[9];
364*0Sstevel@tonic-gate 	} ubuf;
365*0Sstevel@tonic-gate 
366*0Sstevel@tonic-gate 	if (offset != NULL &&
367*0Sstevel@tonic-gate 	    Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) {
368*0Sstevel@tonic-gate 		(void) printf(
369*0Sstevel@tonic-gate 		"%s\tsys=%-9.9snod=%-9.9srel=%-9.9sver=%-9.9smch=%.9s\n",
370*0Sstevel@tonic-gate 			pri->pname,
371*0Sstevel@tonic-gate 			ubuf.sysname,
372*0Sstevel@tonic-gate 			ubuf.nodename,
373*0Sstevel@tonic-gate 			ubuf.release,
374*0Sstevel@tonic-gate 			ubuf.version,
375*0Sstevel@tonic-gate 			ubuf.machine);
376*0Sstevel@tonic-gate 	}
377*0Sstevel@tonic-gate }
378*0Sstevel@tonic-gate 
379*0Sstevel@tonic-gate /* XX64 -- definition of 'struct ustat' is strange -- check out the defn */
380*0Sstevel@tonic-gate void
381*0Sstevel@tonic-gate show_ustat(private_t *pri, long offset)
382*0Sstevel@tonic-gate {
383*0Sstevel@tonic-gate 	struct ustat ubuf;
384*0Sstevel@tonic-gate 
385*0Sstevel@tonic-gate 	if (offset != NULL &&
386*0Sstevel@tonic-gate 	    Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) {
387*0Sstevel@tonic-gate 		(void) printf(
388*0Sstevel@tonic-gate 		"%s\ttfree=%-6ld tinode=%-5lu fname=%-6.6s fpack=%-.6s\n",
389*0Sstevel@tonic-gate 			pri->pname,
390*0Sstevel@tonic-gate 			ubuf.f_tfree,
391*0Sstevel@tonic-gate 			ubuf.f_tinode,
392*0Sstevel@tonic-gate 			ubuf.f_fname,
393*0Sstevel@tonic-gate 			ubuf.f_fpack);
394*0Sstevel@tonic-gate 	}
395*0Sstevel@tonic-gate }
396*0Sstevel@tonic-gate 
397*0Sstevel@tonic-gate #ifdef _LP64
398*0Sstevel@tonic-gate void
399*0Sstevel@tonic-gate show_ustat32(private_t *pri, long offset)
400*0Sstevel@tonic-gate {
401*0Sstevel@tonic-gate 	struct ustat32 ubuf;
402*0Sstevel@tonic-gate 
403*0Sstevel@tonic-gate 	if (offset != NULL &&
404*0Sstevel@tonic-gate 	    Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) {
405*0Sstevel@tonic-gate 		(void) printf(
406*0Sstevel@tonic-gate 		"%s\ttfree=%-6d tinode=%-5u fname=%-6.6s fpack=%-.6s\n",
407*0Sstevel@tonic-gate 			pri->pname,
408*0Sstevel@tonic-gate 			ubuf.f_tfree,
409*0Sstevel@tonic-gate 			ubuf.f_tinode,
410*0Sstevel@tonic-gate 			ubuf.f_fname,
411*0Sstevel@tonic-gate 			ubuf.f_fpack);
412*0Sstevel@tonic-gate 	}
413*0Sstevel@tonic-gate }
414*0Sstevel@tonic-gate #endif	/* _LP64 */
415*0Sstevel@tonic-gate 
416*0Sstevel@tonic-gate void
417*0Sstevel@tonic-gate show_fusers(private_t *pri, long offset, long nproc)
418*0Sstevel@tonic-gate {
419*0Sstevel@tonic-gate 	f_user_t fubuf;
420*0Sstevel@tonic-gate 	int serial = (nproc > 4);
421*0Sstevel@tonic-gate 
422*0Sstevel@tonic-gate 	if (offset == NULL)
423*0Sstevel@tonic-gate 		return;
424*0Sstevel@tonic-gate 
425*0Sstevel@tonic-gate 	/* enter region of lengthy output */
426*0Sstevel@tonic-gate 	if (serial)
427*0Sstevel@tonic-gate 		Eserialize();
428*0Sstevel@tonic-gate 
429*0Sstevel@tonic-gate 	while (nproc > 0 &&
430*0Sstevel@tonic-gate 	    Pread(Proc, &fubuf, sizeof (fubuf), offset) == sizeof (fubuf)) {
431*0Sstevel@tonic-gate 		(void) printf("%s\tpid=%-5d uid=%-5d flags=%s\n",
432*0Sstevel@tonic-gate 		    pri->pname,
433*0Sstevel@tonic-gate 		    (int)fubuf.fu_pid,
434*0Sstevel@tonic-gate 		    (int)fubuf.fu_uid,
435*0Sstevel@tonic-gate 		    fuflags(pri, fubuf.fu_flags));
436*0Sstevel@tonic-gate 		nproc--;
437*0Sstevel@tonic-gate 		offset += sizeof (fubuf);
438*0Sstevel@tonic-gate 	}
439*0Sstevel@tonic-gate 
440*0Sstevel@tonic-gate 	/* exit region of lengthy output */
441*0Sstevel@tonic-gate 	if (serial)
442*0Sstevel@tonic-gate 		Xserialize();
443*0Sstevel@tonic-gate }
444*0Sstevel@tonic-gate 
445*0Sstevel@tonic-gate void
446*0Sstevel@tonic-gate show_utssys(private_t *pri, long r0)
447*0Sstevel@tonic-gate {
448*0Sstevel@tonic-gate 	if (pri->sys_nargs >= 3) {
449*0Sstevel@tonic-gate 		switch (pri->sys_args[2]) {
450*0Sstevel@tonic-gate 		case UTS_UNAME:
451*0Sstevel@tonic-gate 			show_uname(pri, (long)pri->sys_args[0]);
452*0Sstevel@tonic-gate 			break;
453*0Sstevel@tonic-gate 		case UTS_USTAT:
454*0Sstevel@tonic-gate 			show_ustat(pri, (long)pri->sys_args[0]);
455*0Sstevel@tonic-gate 			break;
456*0Sstevel@tonic-gate 		case UTS_FUSERS:
457*0Sstevel@tonic-gate 			show_fusers(pri, (long)pri->sys_args[3], r0);
458*0Sstevel@tonic-gate 			break;
459*0Sstevel@tonic-gate 		}
460*0Sstevel@tonic-gate 	}
461*0Sstevel@tonic-gate }
462*0Sstevel@tonic-gate 
463*0Sstevel@tonic-gate #ifdef _LP64
464*0Sstevel@tonic-gate void
465*0Sstevel@tonic-gate show_utssys32(private_t *pri, long r0)
466*0Sstevel@tonic-gate {
467*0Sstevel@tonic-gate 	if (pri->sys_nargs >= 3) {
468*0Sstevel@tonic-gate 		switch (pri->sys_args[2]) {
469*0Sstevel@tonic-gate 		case UTS_UNAME:
470*0Sstevel@tonic-gate 			show_uname(pri, (long)pri->sys_args[0]);
471*0Sstevel@tonic-gate 			break;
472*0Sstevel@tonic-gate 		case UTS_USTAT:
473*0Sstevel@tonic-gate 			show_ustat32(pri, (long)pri->sys_args[0]);
474*0Sstevel@tonic-gate 			break;
475*0Sstevel@tonic-gate 		case UTS_FUSERS:
476*0Sstevel@tonic-gate 			show_fusers(pri, (long)pri->sys_args[3], r0);
477*0Sstevel@tonic-gate 			break;
478*0Sstevel@tonic-gate 		}
479*0Sstevel@tonic-gate 	}
480*0Sstevel@tonic-gate }
481*0Sstevel@tonic-gate #endif	/* _LP64 */
482*0Sstevel@tonic-gate 
483*0Sstevel@tonic-gate void
484*0Sstevel@tonic-gate show_cladm(private_t *pri, int code, int function, long offset)
485*0Sstevel@tonic-gate {
486*0Sstevel@tonic-gate 	int	arg;
487*0Sstevel@tonic-gate 
488*0Sstevel@tonic-gate 	switch (code) {
489*0Sstevel@tonic-gate 	case CL_INITIALIZE:
490*0Sstevel@tonic-gate 		switch (function) {
491*0Sstevel@tonic-gate 		case CL_GET_BOOTFLAG:
492*0Sstevel@tonic-gate 			if (Pread(Proc, &arg, sizeof (arg), offset)
493*0Sstevel@tonic-gate 			    == sizeof (arg)) {
494*0Sstevel@tonic-gate 				if (arg & CLUSTER_CONFIGURED)
495*0Sstevel@tonic-gate 					(void) printf("%s\tbootflags="
496*0Sstevel@tonic-gate 					    "CLUSTER_CONFIGURED", pri->pname);
497*0Sstevel@tonic-gate 				if (arg & CLUSTER_BOOTED)
498*0Sstevel@tonic-gate 					(void) printf("|CLUSTER_BOOTED\n");
499*0Sstevel@tonic-gate 			}
500*0Sstevel@tonic-gate 			break;
501*0Sstevel@tonic-gate 		}
502*0Sstevel@tonic-gate 		break;
503*0Sstevel@tonic-gate 	case CL_CONFIG:
504*0Sstevel@tonic-gate 		switch (function) {
505*0Sstevel@tonic-gate 		case CL_NODEID:
506*0Sstevel@tonic-gate 		case CL_HIGHEST_NODEID:
507*0Sstevel@tonic-gate 			if (Pread(Proc, &arg, sizeof (arg), offset)
508*0Sstevel@tonic-gate 			    == sizeof (arg))
509*0Sstevel@tonic-gate 				(void) printf("%s\tnodeid=%d\n",
510*0Sstevel@tonic-gate 					pri->pname, arg);
511*0Sstevel@tonic-gate 		}
512*0Sstevel@tonic-gate 		break;
513*0Sstevel@tonic-gate 	}
514*0Sstevel@tonic-gate }
515*0Sstevel@tonic-gate 
516*0Sstevel@tonic-gate #define	ALL_LOCK_TYPES	\
517*0Sstevel@tonic-gate 	(USYNC_PROCESS|LOCK_ERRORCHECK|LOCK_RECURSIVE|USYNC_PROCESS_ROBUST|\
518*0Sstevel@tonic-gate 	    LOCK_PRIO_INHERIT|LOCK_PRIO_PROTECT|LOCK_ROBUST_NP)
519*0Sstevel@tonic-gate 
520*0Sstevel@tonic-gate /* return cv and mutex types */
521*0Sstevel@tonic-gate const char *
522*0Sstevel@tonic-gate synch_type(private_t *pri, uint_t type)
523*0Sstevel@tonic-gate {
524*0Sstevel@tonic-gate 	char *str = pri->code_buf;
525*0Sstevel@tonic-gate 
526*0Sstevel@tonic-gate 	if (type & USYNC_PROCESS)
527*0Sstevel@tonic-gate 		(void) strcpy(str, "USYNC_PROCESS");
528*0Sstevel@tonic-gate 	else
529*0Sstevel@tonic-gate 		(void) strcpy(str, "USYNC_THREAD");
530*0Sstevel@tonic-gate 
531*0Sstevel@tonic-gate 	if (type & LOCK_ERRORCHECK)
532*0Sstevel@tonic-gate 		(void) strcat(str, "|LOCK_ERRORCHECK");
533*0Sstevel@tonic-gate 	if (type & LOCK_RECURSIVE)
534*0Sstevel@tonic-gate 		(void) strcat(str, "|LOCK_RECURSIVE");
535*0Sstevel@tonic-gate 	if (type & USYNC_PROCESS_ROBUST)
536*0Sstevel@tonic-gate 		(void) strcat(str, "|USYNC_PROCESS_ROBUST");
537*0Sstevel@tonic-gate 	if (type & LOCK_PRIO_INHERIT)
538*0Sstevel@tonic-gate 		(void) strcat(str, "|LOCK_PRIO_INHERIT");
539*0Sstevel@tonic-gate 	if (type & LOCK_PRIO_PROTECT)
540*0Sstevel@tonic-gate 		(void) strcat(str, "|LOCK_PRIO_PROTECT");
541*0Sstevel@tonic-gate 	if (type & LOCK_ROBUST_NP)
542*0Sstevel@tonic-gate 		(void) strcat(str, "|LOCK_ROBUST_NP");
543*0Sstevel@tonic-gate 
544*0Sstevel@tonic-gate 	if ((type &= ~ALL_LOCK_TYPES) != 0)
545*0Sstevel@tonic-gate 		(void) sprintf(str + strlen(str), "|0x%.4X", type);
546*0Sstevel@tonic-gate 
547*0Sstevel@tonic-gate 	return ((const char *)str);
548*0Sstevel@tonic-gate }
549*0Sstevel@tonic-gate 
550*0Sstevel@tonic-gate void
551*0Sstevel@tonic-gate show_mutex(private_t *pri, long offset)
552*0Sstevel@tonic-gate {
553*0Sstevel@tonic-gate 	lwp_mutex_t mutex;
554*0Sstevel@tonic-gate 
555*0Sstevel@tonic-gate 	if (Pread(Proc, &mutex, sizeof (mutex), offset) == sizeof (mutex)) {
556*0Sstevel@tonic-gate 		(void) printf("%s\tmutex type: %s\n",
557*0Sstevel@tonic-gate 			pri->pname,
558*0Sstevel@tonic-gate 			synch_type(pri, mutex.mutex_type));
559*0Sstevel@tonic-gate 	}
560*0Sstevel@tonic-gate }
561*0Sstevel@tonic-gate 
562*0Sstevel@tonic-gate void
563*0Sstevel@tonic-gate show_condvar(private_t *pri, long offset)
564*0Sstevel@tonic-gate {
565*0Sstevel@tonic-gate 	lwp_cond_t condvar;
566*0Sstevel@tonic-gate 
567*0Sstevel@tonic-gate 	if (Pread(Proc, &condvar, sizeof (condvar), offset)
568*0Sstevel@tonic-gate 	    == sizeof (condvar)) {
569*0Sstevel@tonic-gate 		(void) printf("%s\tcondvar type: %s\n",
570*0Sstevel@tonic-gate 			pri->pname,
571*0Sstevel@tonic-gate 			synch_type(pri, condvar.cond_type));
572*0Sstevel@tonic-gate 	}
573*0Sstevel@tonic-gate }
574*0Sstevel@tonic-gate 
575*0Sstevel@tonic-gate void
576*0Sstevel@tonic-gate show_sema(private_t *pri, long offset)
577*0Sstevel@tonic-gate {
578*0Sstevel@tonic-gate 	lwp_sema_t sema;
579*0Sstevel@tonic-gate 
580*0Sstevel@tonic-gate 	if (Pread(Proc, &sema, sizeof (sema), offset) == sizeof (sema)) {
581*0Sstevel@tonic-gate 		(void) printf("%s\tsema type: %s  count = %u\n",
582*0Sstevel@tonic-gate 			pri->pname,
583*0Sstevel@tonic-gate 			synch_type(pri, sema.sema_type),
584*0Sstevel@tonic-gate 			sema.sema_count);
585*0Sstevel@tonic-gate 	}
586*0Sstevel@tonic-gate }
587*0Sstevel@tonic-gate 
588*0Sstevel@tonic-gate void
589*0Sstevel@tonic-gate show_rwlock(private_t *pri, long offset)
590*0Sstevel@tonic-gate {
591*0Sstevel@tonic-gate 	lwp_rwlock_t rwlock;
592*0Sstevel@tonic-gate 
593*0Sstevel@tonic-gate 	if (Pread(Proc, &rwlock, sizeof (rwlock), offset) == sizeof (rwlock)) {
594*0Sstevel@tonic-gate 		(void) printf("%s\trwlock type: %s  readers = %d\n",
595*0Sstevel@tonic-gate 			pri->pname,
596*0Sstevel@tonic-gate 			synch_type(pri, rwlock.rwlock_type),
597*0Sstevel@tonic-gate 			rwlock.rwlock_readers);
598*0Sstevel@tonic-gate 	}
599*0Sstevel@tonic-gate }
600*0Sstevel@tonic-gate 
601*0Sstevel@tonic-gate /* represent character as itself ('c') or octal (012) */
602*0Sstevel@tonic-gate char *
603*0Sstevel@tonic-gate show_char(char *buf, int c)
604*0Sstevel@tonic-gate {
605*0Sstevel@tonic-gate 	const char *fmt;
606*0Sstevel@tonic-gate 
607*0Sstevel@tonic-gate 	if (c >= ' ' && c < 0177)
608*0Sstevel@tonic-gate 		fmt = "'%c'";
609*0Sstevel@tonic-gate 	else
610*0Sstevel@tonic-gate 		fmt = "%.3o";
611*0Sstevel@tonic-gate 
612*0Sstevel@tonic-gate 	(void) sprintf(buf, fmt, c&0xff);
613*0Sstevel@tonic-gate 	return (buf);
614*0Sstevel@tonic-gate }
615*0Sstevel@tonic-gate 
616*0Sstevel@tonic-gate void
617*0Sstevel@tonic-gate show_termio(private_t *pri, long offset)
618*0Sstevel@tonic-gate {
619*0Sstevel@tonic-gate 	struct termio termio;
620*0Sstevel@tonic-gate 	char cbuf[8];
621*0Sstevel@tonic-gate 	int i;
622*0Sstevel@tonic-gate 
623*0Sstevel@tonic-gate 	if (Pread(Proc, &termio, sizeof (termio), offset) == sizeof (termio)) {
624*0Sstevel@tonic-gate 		(void) printf(
625*0Sstevel@tonic-gate 		"%s\tiflag=0%.6o oflag=0%.6o cflag=0%.6o lflag=0%.6o line=%d\n",
626*0Sstevel@tonic-gate 			pri->pname,
627*0Sstevel@tonic-gate 			termio.c_iflag,
628*0Sstevel@tonic-gate 			termio.c_oflag,
629*0Sstevel@tonic-gate 			termio.c_cflag,
630*0Sstevel@tonic-gate 			termio.c_lflag,
631*0Sstevel@tonic-gate 			termio.c_line);
632*0Sstevel@tonic-gate 		(void) printf("%s\t    cc: ", pri->pname);
633*0Sstevel@tonic-gate 		for (i = 0; i < NCC; i++)
634*0Sstevel@tonic-gate 			(void) printf(" %s",
635*0Sstevel@tonic-gate 				show_char(cbuf, (int)termio.c_cc[i]));
636*0Sstevel@tonic-gate 		(void) fputc('\n', stdout);
637*0Sstevel@tonic-gate 	}
638*0Sstevel@tonic-gate }
639*0Sstevel@tonic-gate 
640*0Sstevel@tonic-gate void
641*0Sstevel@tonic-gate show_termios(private_t *pri, long offset)
642*0Sstevel@tonic-gate {
643*0Sstevel@tonic-gate 	struct termios termios;
644*0Sstevel@tonic-gate 	char cbuf[8];
645*0Sstevel@tonic-gate 	int i;
646*0Sstevel@tonic-gate 
647*0Sstevel@tonic-gate 	if (Pread(Proc, &termios, sizeof (termios), offset)
648*0Sstevel@tonic-gate 	    == sizeof (termios)) {
649*0Sstevel@tonic-gate 		(void) printf(
650*0Sstevel@tonic-gate 		"%s\tiflag=0%.6o oflag=0%.6o cflag=0%.6o lflag=0%.6o\n",
651*0Sstevel@tonic-gate 			pri->pname,
652*0Sstevel@tonic-gate 			termios.c_iflag,
653*0Sstevel@tonic-gate 			termios.c_oflag,
654*0Sstevel@tonic-gate 			termios.c_cflag,
655*0Sstevel@tonic-gate 			termios.c_lflag);
656*0Sstevel@tonic-gate 		(void) printf("%s\t    cc: ", pri->pname);
657*0Sstevel@tonic-gate 		for (i = 0; i < NCCS; i++) {
658*0Sstevel@tonic-gate 			if (i == NCC)	/* show new chars on new line */
659*0Sstevel@tonic-gate 				(void) printf("\n%s\t\t", pri->pname);
660*0Sstevel@tonic-gate 			(void) printf(" %s",
661*0Sstevel@tonic-gate 				show_char(cbuf, (int)termios.c_cc[i]));
662*0Sstevel@tonic-gate 		}
663*0Sstevel@tonic-gate 		(void) fputc('\n', stdout);
664*0Sstevel@tonic-gate 	}
665*0Sstevel@tonic-gate }
666*0Sstevel@tonic-gate 
667*0Sstevel@tonic-gate void
668*0Sstevel@tonic-gate show_termiox(private_t *pri, long offset)
669*0Sstevel@tonic-gate {
670*0Sstevel@tonic-gate 	struct termiox termiox;
671*0Sstevel@tonic-gate 	int i;
672*0Sstevel@tonic-gate 
673*0Sstevel@tonic-gate 	if (Pread(Proc, &termiox, sizeof (termiox), offset)
674*0Sstevel@tonic-gate 	    == sizeof (termiox)) {
675*0Sstevel@tonic-gate 		(void) printf("%s\thflag=0%.3o cflag=0%.3o rflag=0%.3o",
676*0Sstevel@tonic-gate 			pri->pname,
677*0Sstevel@tonic-gate 			termiox.x_hflag,
678*0Sstevel@tonic-gate 			termiox.x_cflag,
679*0Sstevel@tonic-gate 			termiox.x_rflag[0]);
680*0Sstevel@tonic-gate 		for (i = 1; i < NFF; i++)
681*0Sstevel@tonic-gate 			(void) printf(",0%.3o", termiox.x_rflag[i]);
682*0Sstevel@tonic-gate 		(void) printf(" sflag=0%.3o\n",
683*0Sstevel@tonic-gate 			termiox.x_sflag);
684*0Sstevel@tonic-gate 	}
685*0Sstevel@tonic-gate }
686*0Sstevel@tonic-gate 
687*0Sstevel@tonic-gate void
688*0Sstevel@tonic-gate show_sgttyb(private_t *pri, long offset)
689*0Sstevel@tonic-gate {
690*0Sstevel@tonic-gate 	struct sgttyb sgttyb;
691*0Sstevel@tonic-gate 
692*0Sstevel@tonic-gate 	if (Pread(Proc, &sgttyb, sizeof (sgttyb), offset) == sizeof (sgttyb)) {
693*0Sstevel@tonic-gate 		char erase[8];
694*0Sstevel@tonic-gate 		char kill[8];
695*0Sstevel@tonic-gate 
696*0Sstevel@tonic-gate 		(void) printf(
697*0Sstevel@tonic-gate 		"%s\tispeed=%-2d ospeed=%-2d erase=%s kill=%s flags=0x%.8x\n",
698*0Sstevel@tonic-gate 			pri->pname,
699*0Sstevel@tonic-gate 			sgttyb.sg_ispeed&0xff,
700*0Sstevel@tonic-gate 			sgttyb.sg_ospeed&0xff,
701*0Sstevel@tonic-gate 			show_char(erase, sgttyb.sg_erase),
702*0Sstevel@tonic-gate 			show_char(kill, sgttyb.sg_kill),
703*0Sstevel@tonic-gate 			sgttyb.sg_flags);
704*0Sstevel@tonic-gate 	}
705*0Sstevel@tonic-gate }
706*0Sstevel@tonic-gate 
707*0Sstevel@tonic-gate void
708*0Sstevel@tonic-gate show_ltchars(private_t *pri, long offset)
709*0Sstevel@tonic-gate {
710*0Sstevel@tonic-gate 	struct ltchars ltchars;
711*0Sstevel@tonic-gate 	char *p;
712*0Sstevel@tonic-gate 	char cbuf[8];
713*0Sstevel@tonic-gate 	int i;
714*0Sstevel@tonic-gate 
715*0Sstevel@tonic-gate 	if (Pread(Proc, &ltchars, sizeof (ltchars), offset)
716*0Sstevel@tonic-gate 	    == sizeof (ltchars)) {
717*0Sstevel@tonic-gate 		(void) printf("%s\t    cc: ", pri->pname);
718*0Sstevel@tonic-gate 		for (p = (char *)&ltchars, i = 0; i < sizeof (ltchars); i++)
719*0Sstevel@tonic-gate 			(void) printf(" %s", show_char(cbuf, (int)*p++));
720*0Sstevel@tonic-gate 		(void) fputc('\n', stdout);
721*0Sstevel@tonic-gate 	}
722*0Sstevel@tonic-gate }
723*0Sstevel@tonic-gate 
724*0Sstevel@tonic-gate void
725*0Sstevel@tonic-gate show_tchars(private_t *pri, long offset)
726*0Sstevel@tonic-gate {
727*0Sstevel@tonic-gate 	struct tchars tchars;
728*0Sstevel@tonic-gate 	char *p;
729*0Sstevel@tonic-gate 	char cbuf[8];
730*0Sstevel@tonic-gate 	int i;
731*0Sstevel@tonic-gate 
732*0Sstevel@tonic-gate 	if (Pread(Proc, &tchars, sizeof (tchars), offset) == sizeof (tchars)) {
733*0Sstevel@tonic-gate 		(void) printf("%s\t    cc: ", pri->pname);
734*0Sstevel@tonic-gate 		for (p = (char *)&tchars, i = 0; i < sizeof (tchars); i++)
735*0Sstevel@tonic-gate 			(void) printf(" %s", show_char(cbuf, (int)*p++));
736*0Sstevel@tonic-gate 		(void) fputc('\n', stdout);
737*0Sstevel@tonic-gate 	}
738*0Sstevel@tonic-gate }
739*0Sstevel@tonic-gate 
740*0Sstevel@tonic-gate void
741*0Sstevel@tonic-gate show_termcb(private_t *pri, long offset)
742*0Sstevel@tonic-gate {
743*0Sstevel@tonic-gate 	struct termcb termcb;
744*0Sstevel@tonic-gate 
745*0Sstevel@tonic-gate 	if (Pread(Proc, &termcb, sizeof (termcb), offset) == sizeof (termcb)) {
746*0Sstevel@tonic-gate 		(void) printf(
747*0Sstevel@tonic-gate 		"%s\tflgs=0%.2o termt=%d crow=%d ccol=%d vrow=%d lrow=%d\n",
748*0Sstevel@tonic-gate 			pri->pname,
749*0Sstevel@tonic-gate 			termcb.st_flgs&0xff,
750*0Sstevel@tonic-gate 			termcb.st_termt&0xff,
751*0Sstevel@tonic-gate 			termcb.st_crow&0xff,
752*0Sstevel@tonic-gate 			termcb.st_ccol&0xff,
753*0Sstevel@tonic-gate 			termcb.st_vrow&0xff,
754*0Sstevel@tonic-gate 			termcb.st_lrow&0xff);
755*0Sstevel@tonic-gate 	}
756*0Sstevel@tonic-gate }
757*0Sstevel@tonic-gate 
758*0Sstevel@tonic-gate /* integer value pointed to by ioctl() arg */
759*0Sstevel@tonic-gate void
760*0Sstevel@tonic-gate show_strint(private_t *pri, int code, long offset)
761*0Sstevel@tonic-gate {
762*0Sstevel@tonic-gate 	int val;
763*0Sstevel@tonic-gate 
764*0Sstevel@tonic-gate 	if (Pread(Proc, &val, sizeof (val), offset) == sizeof (val)) {
765*0Sstevel@tonic-gate 		const char *s = NULL;
766*0Sstevel@tonic-gate 
767*0Sstevel@tonic-gate 		switch (code) {		/* interpret these symbolically */
768*0Sstevel@tonic-gate 		case I_GRDOPT:
769*0Sstevel@tonic-gate 			s = strrdopt(val);
770*0Sstevel@tonic-gate 			break;
771*0Sstevel@tonic-gate 		case I_GETSIG:
772*0Sstevel@tonic-gate 			s = strevents(pri, val);
773*0Sstevel@tonic-gate 			break;
774*0Sstevel@tonic-gate 		case TIOCFLUSH:
775*0Sstevel@tonic-gate 			s = tiocflush(pri, val);
776*0Sstevel@tonic-gate 			break;
777*0Sstevel@tonic-gate 		}
778*0Sstevel@tonic-gate 
779*0Sstevel@tonic-gate 		if (s == NULL)
780*0Sstevel@tonic-gate 			(void) printf("%s\t0x%.8lX: %d\n",
781*0Sstevel@tonic-gate 				pri->pname, offset, val);
782*0Sstevel@tonic-gate 		else
783*0Sstevel@tonic-gate 			(void) printf("%s\t0x%.8lX: %s\n",
784*0Sstevel@tonic-gate 				pri->pname, offset, s);
785*0Sstevel@tonic-gate 	}
786*0Sstevel@tonic-gate }
787*0Sstevel@tonic-gate 
788*0Sstevel@tonic-gate void
789*0Sstevel@tonic-gate show_strioctl(private_t *pri, long offset)
790*0Sstevel@tonic-gate {
791*0Sstevel@tonic-gate 	struct strioctl strioctl;
792*0Sstevel@tonic-gate 
793*0Sstevel@tonic-gate 	if (Pread(Proc, &strioctl, sizeof (strioctl), offset) ==
794*0Sstevel@tonic-gate 	    sizeof (strioctl)) {
795*0Sstevel@tonic-gate 		(void) printf(
796*0Sstevel@tonic-gate 			"%s\tcmd=%s timout=%d len=%d dp=0x%.8lX\n",
797*0Sstevel@tonic-gate 			pri->pname,
798*0Sstevel@tonic-gate 			ioctlname(pri, strioctl.ic_cmd),
799*0Sstevel@tonic-gate 			strioctl.ic_timout,
800*0Sstevel@tonic-gate 			strioctl.ic_len,
801*0Sstevel@tonic-gate 			(long)strioctl.ic_dp);
802*0Sstevel@tonic-gate 
803*0Sstevel@tonic-gate 		if (pri->recur++ == 0)	/* avoid indefinite recursion */
804*0Sstevel@tonic-gate 			show_ioctl(pri, strioctl.ic_cmd,
805*0Sstevel@tonic-gate 				(long)strioctl.ic_dp);
806*0Sstevel@tonic-gate 		--pri->recur;
807*0Sstevel@tonic-gate 	}
808*0Sstevel@tonic-gate }
809*0Sstevel@tonic-gate 
810*0Sstevel@tonic-gate #ifdef _LP64
811*0Sstevel@tonic-gate void
812*0Sstevel@tonic-gate show_strioctl32(private_t *pri, long offset)
813*0Sstevel@tonic-gate {
814*0Sstevel@tonic-gate 	struct strioctl32 strioctl;
815*0Sstevel@tonic-gate 
816*0Sstevel@tonic-gate 	if (Pread(Proc, &strioctl, sizeof (strioctl), offset) ==
817*0Sstevel@tonic-gate 	    sizeof (strioctl)) {
818*0Sstevel@tonic-gate 		(void) printf(
819*0Sstevel@tonic-gate 			"%s\tcmd=%s timout=%d len=%d dp=0x%.8lX\n",
820*0Sstevel@tonic-gate 			pri->pname,
821*0Sstevel@tonic-gate 			ioctlname(pri, strioctl.ic_cmd),
822*0Sstevel@tonic-gate 			strioctl.ic_timout,
823*0Sstevel@tonic-gate 			strioctl.ic_len,
824*0Sstevel@tonic-gate 			(long)strioctl.ic_dp);
825*0Sstevel@tonic-gate 
826*0Sstevel@tonic-gate 		if (pri->recur++ == 0)	/* avoid indefinite recursion */
827*0Sstevel@tonic-gate 			show_ioctl(pri, strioctl.ic_cmd,
828*0Sstevel@tonic-gate 				(long)strioctl.ic_dp);
829*0Sstevel@tonic-gate 		--pri->recur;
830*0Sstevel@tonic-gate 	}
831*0Sstevel@tonic-gate }
832*0Sstevel@tonic-gate #endif	/* _LP64 */
833*0Sstevel@tonic-gate 
834*0Sstevel@tonic-gate void
835*0Sstevel@tonic-gate print_strbuf(private_t *pri, struct strbuf *sp, const char *name, int dump)
836*0Sstevel@tonic-gate {
837*0Sstevel@tonic-gate 	(void) printf(
838*0Sstevel@tonic-gate 		"%s\t%s:  maxlen=%-4d len=%-4d buf=0x%.8lX",
839*0Sstevel@tonic-gate 		pri->pname,
840*0Sstevel@tonic-gate 		name,
841*0Sstevel@tonic-gate 		sp->maxlen,
842*0Sstevel@tonic-gate 		sp->len,
843*0Sstevel@tonic-gate 		(long)sp->buf);
844*0Sstevel@tonic-gate 	/*
845*0Sstevel@tonic-gate 	 * Should we show the buffer contents?
846*0Sstevel@tonic-gate 	 * Keyed to the '-r fds' and '-w fds' options?
847*0Sstevel@tonic-gate 	 */
848*0Sstevel@tonic-gate 	if (sp->buf == NULL || sp->len <= 0)
849*0Sstevel@tonic-gate 		(void) fputc('\n', stdout);
850*0Sstevel@tonic-gate 	else {
851*0Sstevel@tonic-gate 		int nb = (sp->len > 8)? 8 : sp->len;
852*0Sstevel@tonic-gate 		char buffer[8];
853*0Sstevel@tonic-gate 		char obuf[40];
854*0Sstevel@tonic-gate 
855*0Sstevel@tonic-gate 		if (Pread(Proc, buffer, (size_t)nb, (long)sp->buf) == nb) {
856*0Sstevel@tonic-gate 			(void) strcpy(obuf, ": \"");
857*0Sstevel@tonic-gate 			showbytes(buffer, nb, obuf+3);
858*0Sstevel@tonic-gate 			(void) strcat(obuf,
859*0Sstevel@tonic-gate 				(nb == sp->len)?
860*0Sstevel@tonic-gate 				    (const char *)"\"" : (const char *)"\"..");
861*0Sstevel@tonic-gate 			(void) fputs(obuf, stdout);
862*0Sstevel@tonic-gate 		}
863*0Sstevel@tonic-gate 		(void) fputc('\n', stdout);
864*0Sstevel@tonic-gate 		if (dump && sp->len > 8)
865*0Sstevel@tonic-gate 			showbuffer(pri, (long)sp->buf, (long)sp->len);
866*0Sstevel@tonic-gate 	}
867*0Sstevel@tonic-gate }
868*0Sstevel@tonic-gate 
869*0Sstevel@tonic-gate #ifdef _LP64
870*0Sstevel@tonic-gate void
871*0Sstevel@tonic-gate print_strbuf32(private_t *pri, struct strbuf32 *sp, const char *name, int dump)
872*0Sstevel@tonic-gate {
873*0Sstevel@tonic-gate 	(void) printf(
874*0Sstevel@tonic-gate 		"%s\t%s:  maxlen=%-4d len=%-4d buf=0x%.8lX",
875*0Sstevel@tonic-gate 		pri->pname,
876*0Sstevel@tonic-gate 		name,
877*0Sstevel@tonic-gate 		sp->maxlen,
878*0Sstevel@tonic-gate 		sp->len,
879*0Sstevel@tonic-gate 		(long)sp->buf);
880*0Sstevel@tonic-gate 	/*
881*0Sstevel@tonic-gate 	 * Should we show the buffer contents?
882*0Sstevel@tonic-gate 	 * Keyed to the '-r fds' and '-w fds' options?
883*0Sstevel@tonic-gate 	 */
884*0Sstevel@tonic-gate 	if (sp->buf == NULL || sp->len <= 0)
885*0Sstevel@tonic-gate 		(void) fputc('\n', stdout);
886*0Sstevel@tonic-gate 	else {
887*0Sstevel@tonic-gate 		int nb = (sp->len > 8)? 8 : sp->len;
888*0Sstevel@tonic-gate 		char buffer[8];
889*0Sstevel@tonic-gate 		char obuf[40];
890*0Sstevel@tonic-gate 
891*0Sstevel@tonic-gate 		if (Pread(Proc, buffer, (size_t)nb, (long)sp->buf) == nb) {
892*0Sstevel@tonic-gate 			(void) strcpy(obuf, ": \"");
893*0Sstevel@tonic-gate 			showbytes(buffer, nb, obuf+3);
894*0Sstevel@tonic-gate 			(void) strcat(obuf,
895*0Sstevel@tonic-gate 				(nb == sp->len)?
896*0Sstevel@tonic-gate 				    (const char *)"\"" : (const char *)"\"..");
897*0Sstevel@tonic-gate 			(void) fputs(obuf, stdout);
898*0Sstevel@tonic-gate 		}
899*0Sstevel@tonic-gate 		(void) fputc('\n', stdout);
900*0Sstevel@tonic-gate 		if (dump && sp->len > 8)
901*0Sstevel@tonic-gate 			showbuffer(pri, (long)sp->buf, (long)sp->len);
902*0Sstevel@tonic-gate 	}
903*0Sstevel@tonic-gate }
904*0Sstevel@tonic-gate #endif	/* _LP64 */
905*0Sstevel@tonic-gate 
906*0Sstevel@tonic-gate /* strpeek and strfdinsert flags word */
907*0Sstevel@tonic-gate const char *
908*0Sstevel@tonic-gate strflags(private_t *pri, int flags)
909*0Sstevel@tonic-gate {
910*0Sstevel@tonic-gate 	const char *s;
911*0Sstevel@tonic-gate 
912*0Sstevel@tonic-gate 	switch (flags) {
913*0Sstevel@tonic-gate 	case 0:
914*0Sstevel@tonic-gate 		s = "0";
915*0Sstevel@tonic-gate 		break;
916*0Sstevel@tonic-gate 	case RS_HIPRI:
917*0Sstevel@tonic-gate 		s = "RS_HIPRI";
918*0Sstevel@tonic-gate 		break;
919*0Sstevel@tonic-gate 	default:
920*0Sstevel@tonic-gate 		(void) sprintf(pri->code_buf, "0x%.4X", flags);
921*0Sstevel@tonic-gate 		s = pri->code_buf;
922*0Sstevel@tonic-gate 	}
923*0Sstevel@tonic-gate 
924*0Sstevel@tonic-gate 	return (s);
925*0Sstevel@tonic-gate }
926*0Sstevel@tonic-gate 
927*0Sstevel@tonic-gate void
928*0Sstevel@tonic-gate show_strpeek(private_t *pri, long offset)
929*0Sstevel@tonic-gate {
930*0Sstevel@tonic-gate 	struct strpeek strpeek;
931*0Sstevel@tonic-gate 
932*0Sstevel@tonic-gate 	if (Pread(Proc, &strpeek, sizeof (strpeek), offset)
933*0Sstevel@tonic-gate 	    == sizeof (strpeek)) {
934*0Sstevel@tonic-gate 
935*0Sstevel@tonic-gate 		print_strbuf(pri, &strpeek.ctlbuf, "ctl", FALSE);
936*0Sstevel@tonic-gate 		print_strbuf(pri, &strpeek.databuf, "dat", FALSE);
937*0Sstevel@tonic-gate 
938*0Sstevel@tonic-gate 		(void) printf("%s\tflags=%s\n",
939*0Sstevel@tonic-gate 			pri->pname,
940*0Sstevel@tonic-gate 			strflags(pri, strpeek.flags));
941*0Sstevel@tonic-gate 	}
942*0Sstevel@tonic-gate }
943*0Sstevel@tonic-gate 
944*0Sstevel@tonic-gate #ifdef _LP64
945*0Sstevel@tonic-gate void
946*0Sstevel@tonic-gate show_strpeek32(private_t *pri, long offset)
947*0Sstevel@tonic-gate {
948*0Sstevel@tonic-gate 	struct strpeek32 strpeek;
949*0Sstevel@tonic-gate 
950*0Sstevel@tonic-gate 	if (Pread(Proc, &strpeek, sizeof (strpeek), offset)
951*0Sstevel@tonic-gate 	    == sizeof (strpeek)) {
952*0Sstevel@tonic-gate 
953*0Sstevel@tonic-gate 		print_strbuf32(pri, &strpeek.ctlbuf, "ctl", FALSE);
954*0Sstevel@tonic-gate 		print_strbuf32(pri, &strpeek.databuf, "dat", FALSE);
955*0Sstevel@tonic-gate 
956*0Sstevel@tonic-gate 		(void) printf("%s\tflags=%s\n",
957*0Sstevel@tonic-gate 			pri->pname,
958*0Sstevel@tonic-gate 			strflags(pri, strpeek.flags));
959*0Sstevel@tonic-gate 	}
960*0Sstevel@tonic-gate }
961*0Sstevel@tonic-gate #endif	/* _LP64 */
962*0Sstevel@tonic-gate 
963*0Sstevel@tonic-gate void
964*0Sstevel@tonic-gate show_strfdinsert(private_t *pri, long offset)
965*0Sstevel@tonic-gate {
966*0Sstevel@tonic-gate 	struct strfdinsert strfdinsert;
967*0Sstevel@tonic-gate 
968*0Sstevel@tonic-gate 	if (Pread(Proc, &strfdinsert, sizeof (strfdinsert), offset) ==
969*0Sstevel@tonic-gate 	    sizeof (strfdinsert)) {
970*0Sstevel@tonic-gate 
971*0Sstevel@tonic-gate 		print_strbuf(pri, &strfdinsert.ctlbuf, "ctl", FALSE);
972*0Sstevel@tonic-gate 		print_strbuf(pri, &strfdinsert.databuf, "dat", FALSE);
973*0Sstevel@tonic-gate 
974*0Sstevel@tonic-gate 		(void) printf("%s\tflags=%s fildes=%d offset=%d\n",
975*0Sstevel@tonic-gate 			pri->pname,
976*0Sstevel@tonic-gate 			strflags(pri, strfdinsert.flags),
977*0Sstevel@tonic-gate 			strfdinsert.fildes,
978*0Sstevel@tonic-gate 			strfdinsert.offset);
979*0Sstevel@tonic-gate 	}
980*0Sstevel@tonic-gate }
981*0Sstevel@tonic-gate 
982*0Sstevel@tonic-gate #ifdef _LP64
983*0Sstevel@tonic-gate void
984*0Sstevel@tonic-gate show_strfdinsert32(private_t *pri, long offset)
985*0Sstevel@tonic-gate {
986*0Sstevel@tonic-gate 	struct strfdinsert32 strfdinsert;
987*0Sstevel@tonic-gate 
988*0Sstevel@tonic-gate 	if (Pread(Proc, &strfdinsert, sizeof (strfdinsert), offset) ==
989*0Sstevel@tonic-gate 	    sizeof (strfdinsert)) {
990*0Sstevel@tonic-gate 
991*0Sstevel@tonic-gate 		print_strbuf32(pri, &strfdinsert.ctlbuf, "ctl", FALSE);
992*0Sstevel@tonic-gate 		print_strbuf32(pri, &strfdinsert.databuf, "dat", FALSE);
993*0Sstevel@tonic-gate 
994*0Sstevel@tonic-gate 		(void) printf("%s\tflags=%s fildes=%d offset=%d\n",
995*0Sstevel@tonic-gate 			pri->pname,
996*0Sstevel@tonic-gate 			strflags(pri, strfdinsert.flags),
997*0Sstevel@tonic-gate 			strfdinsert.fildes,
998*0Sstevel@tonic-gate 			strfdinsert.offset);
999*0Sstevel@tonic-gate 	}
1000*0Sstevel@tonic-gate }
1001*0Sstevel@tonic-gate #endif	/* _LP64 */
1002*0Sstevel@tonic-gate 
1003*0Sstevel@tonic-gate void
1004*0Sstevel@tonic-gate show_strrecvfd(private_t *pri, long offset)
1005*0Sstevel@tonic-gate {
1006*0Sstevel@tonic-gate 	struct strrecvfd strrecvfd;
1007*0Sstevel@tonic-gate 
1008*0Sstevel@tonic-gate 	if (Pread(Proc, &strrecvfd, sizeof (strrecvfd), offset) ==
1009*0Sstevel@tonic-gate 	    sizeof (strrecvfd)) {
1010*0Sstevel@tonic-gate 		(void) printf(
1011*0Sstevel@tonic-gate 			"%s\tfd=%-5d uid=%-5d gid=%d\n",
1012*0Sstevel@tonic-gate 			pri->pname,
1013*0Sstevel@tonic-gate 			strrecvfd.fd,
1014*0Sstevel@tonic-gate 			(int)strrecvfd.uid,
1015*0Sstevel@tonic-gate 			(int)strrecvfd.gid);
1016*0Sstevel@tonic-gate 	}
1017*0Sstevel@tonic-gate }
1018*0Sstevel@tonic-gate 
1019*0Sstevel@tonic-gate void
1020*0Sstevel@tonic-gate show_strlist(private_t *pri, long offset)
1021*0Sstevel@tonic-gate {
1022*0Sstevel@tonic-gate 	struct str_list strlist;
1023*0Sstevel@tonic-gate 	struct str_mlist list;
1024*0Sstevel@tonic-gate 	int count;
1025*0Sstevel@tonic-gate 
1026*0Sstevel@tonic-gate 	if (Pread(Proc, &strlist, sizeof (strlist), offset) ==
1027*0Sstevel@tonic-gate 	    sizeof (strlist)) {
1028*0Sstevel@tonic-gate 		(void) printf("%s\tnmods=%d  modlist=0x%.8lX\n",
1029*0Sstevel@tonic-gate 			pri->pname,
1030*0Sstevel@tonic-gate 			strlist.sl_nmods,
1031*0Sstevel@tonic-gate 			(long)strlist.sl_modlist);
1032*0Sstevel@tonic-gate 
1033*0Sstevel@tonic-gate 		count = strlist.sl_nmods;
1034*0Sstevel@tonic-gate 		offset = (long)strlist.sl_modlist;
1035*0Sstevel@tonic-gate 		while (!interrupt && --count >= 0) {
1036*0Sstevel@tonic-gate 			if (Pread(Proc, &list, sizeof (list), offset) !=
1037*0Sstevel@tonic-gate 			    sizeof (list))
1038*0Sstevel@tonic-gate 				break;
1039*0Sstevel@tonic-gate 			(void) printf("%s\t\t\"%.*s\"\n",
1040*0Sstevel@tonic-gate 				pri->pname,
1041*0Sstevel@tonic-gate 				(int)sizeof (list.l_name),
1042*0Sstevel@tonic-gate 				list.l_name);
1043*0Sstevel@tonic-gate 			offset += sizeof (struct str_mlist);
1044*0Sstevel@tonic-gate 		}
1045*0Sstevel@tonic-gate 	}
1046*0Sstevel@tonic-gate }
1047*0Sstevel@tonic-gate 
1048*0Sstevel@tonic-gate #ifdef _LP64
1049*0Sstevel@tonic-gate void
1050*0Sstevel@tonic-gate show_strlist32(private_t *pri, long offset)
1051*0Sstevel@tonic-gate {
1052*0Sstevel@tonic-gate 	struct str_list32 strlist;
1053*0Sstevel@tonic-gate 	struct str_mlist list;
1054*0Sstevel@tonic-gate 	int count;
1055*0Sstevel@tonic-gate 
1056*0Sstevel@tonic-gate 	if (Pread(Proc, &strlist, sizeof (strlist), offset) ==
1057*0Sstevel@tonic-gate 	    sizeof (strlist)) {
1058*0Sstevel@tonic-gate 		(void) printf("%s\tnmods=%d  modlist=0x%.8lX\n",
1059*0Sstevel@tonic-gate 			pri->pname,
1060*0Sstevel@tonic-gate 			strlist.sl_nmods,
1061*0Sstevel@tonic-gate 			(long)strlist.sl_modlist);
1062*0Sstevel@tonic-gate 
1063*0Sstevel@tonic-gate 		count = strlist.sl_nmods;
1064*0Sstevel@tonic-gate 		offset = (long)strlist.sl_modlist;
1065*0Sstevel@tonic-gate 		while (!interrupt && --count >= 0) {
1066*0Sstevel@tonic-gate 			if (Pread(Proc, &list, sizeof (list), offset) !=
1067*0Sstevel@tonic-gate 			    sizeof (list))
1068*0Sstevel@tonic-gate 				break;
1069*0Sstevel@tonic-gate 			(void) printf("%s\t\t\"%.*s\"\n",
1070*0Sstevel@tonic-gate 				pri->pname,
1071*0Sstevel@tonic-gate 				(int)sizeof (list.l_name),
1072*0Sstevel@tonic-gate 				list.l_name);
1073*0Sstevel@tonic-gate 			offset += sizeof (struct str_mlist);
1074*0Sstevel@tonic-gate 		}
1075*0Sstevel@tonic-gate 	}
1076*0Sstevel@tonic-gate }
1077*0Sstevel@tonic-gate #endif	/* _LP64 */
1078*0Sstevel@tonic-gate 
1079*0Sstevel@tonic-gate void
1080*0Sstevel@tonic-gate show_jwinsize(private_t *pri, long offset)
1081*0Sstevel@tonic-gate {
1082*0Sstevel@tonic-gate 	struct jwinsize jwinsize;
1083*0Sstevel@tonic-gate 
1084*0Sstevel@tonic-gate 	if (Pread(Proc, &jwinsize, sizeof (jwinsize), offset) ==
1085*0Sstevel@tonic-gate 	    sizeof (jwinsize)) {
1086*0Sstevel@tonic-gate 		(void) printf(
1087*0Sstevel@tonic-gate 			"%s\tbytesx=%-3u bytesy=%-3u bitsx=%-3u bitsy=%-3u\n",
1088*0Sstevel@tonic-gate 			pri->pname,
1089*0Sstevel@tonic-gate 			(unsigned)jwinsize.bytesx,
1090*0Sstevel@tonic-gate 			(unsigned)jwinsize.bytesy,
1091*0Sstevel@tonic-gate 			(unsigned)jwinsize.bitsx,
1092*0Sstevel@tonic-gate 			(unsigned)jwinsize.bitsy);
1093*0Sstevel@tonic-gate 	}
1094*0Sstevel@tonic-gate }
1095*0Sstevel@tonic-gate 
1096*0Sstevel@tonic-gate void
1097*0Sstevel@tonic-gate show_winsize(private_t *pri, long offset)
1098*0Sstevel@tonic-gate {
1099*0Sstevel@tonic-gate 	struct winsize winsize;
1100*0Sstevel@tonic-gate 
1101*0Sstevel@tonic-gate 	if (Pread(Proc, &winsize, sizeof (winsize), offset)
1102*0Sstevel@tonic-gate 	    == sizeof (winsize)) {
1103*0Sstevel@tonic-gate 		(void) printf(
1104*0Sstevel@tonic-gate 			"%s\trow=%-3d col=%-3d xpixel=%-3d ypixel=%-3d\n",
1105*0Sstevel@tonic-gate 			pri->pname,
1106*0Sstevel@tonic-gate 			winsize.ws_row,
1107*0Sstevel@tonic-gate 			winsize.ws_col,
1108*0Sstevel@tonic-gate 			winsize.ws_xpixel,
1109*0Sstevel@tonic-gate 			winsize.ws_ypixel);
1110*0Sstevel@tonic-gate 	}
1111*0Sstevel@tonic-gate }
1112*0Sstevel@tonic-gate 
1113*0Sstevel@tonic-gate struct audio_stuff {
1114*0Sstevel@tonic-gate 	uint_t	bit;
1115*0Sstevel@tonic-gate 	const char *str;
1116*0Sstevel@tonic-gate };
1117*0Sstevel@tonic-gate 
1118*0Sstevel@tonic-gate const struct audio_stuff audio_output_ports[] = {
1119*0Sstevel@tonic-gate 	{ AUDIO_SPEAKER, "SPEAKER" },
1120*0Sstevel@tonic-gate 	{ AUDIO_HEADPHONE, "HEADPHONE" },
1121*0Sstevel@tonic-gate 	{ AUDIO_LINE_OUT, "LINE_OUT" },
1122*0Sstevel@tonic-gate 	{ AUDIO_SPDIF_OUT, "SPDIF_OUT" },
1123*0Sstevel@tonic-gate 	{ AUDIO_AUX1_OUT, "AUX1_OUT" },
1124*0Sstevel@tonic-gate 	{ AUDIO_AUX2_OUT, "AUX2_OUT" },
1125*0Sstevel@tonic-gate 	{ 0, NULL }
1126*0Sstevel@tonic-gate };
1127*0Sstevel@tonic-gate 
1128*0Sstevel@tonic-gate const struct audio_stuff audio_input_ports[] = {
1129*0Sstevel@tonic-gate 	{ AUDIO_MICROPHONE, "MICROPHONE" },
1130*0Sstevel@tonic-gate 	{ AUDIO_LINE_IN, "LINE_IN" },
1131*0Sstevel@tonic-gate 	{ AUDIO_CD, "CD" },
1132*0Sstevel@tonic-gate 	{ AUDIO_SPDIF_IN, "SPDIF_IN" },
1133*0Sstevel@tonic-gate 	{ AUDIO_AUX1_IN, "AUX1_IN" },
1134*0Sstevel@tonic-gate 	{ AUDIO_AUX2_IN, "AUX2_IN" },
1135*0Sstevel@tonic-gate 	{ AUDIO_CODEC_LOOPB_IN, "CODEC_LOOPB_IN" },
1136*0Sstevel@tonic-gate 	{ AUDIO_SUNVTS, "SUNVTS" },
1137*0Sstevel@tonic-gate 	{ 0, NULL }
1138*0Sstevel@tonic-gate };
1139*0Sstevel@tonic-gate 
1140*0Sstevel@tonic-gate static const struct audio_stuff audio_hw_features[] = {
1141*0Sstevel@tonic-gate 	{ AUDIO_HWFEATURE_DUPLEX, "DUPLEX" },
1142*0Sstevel@tonic-gate 	{ AUDIO_HWFEATURE_MSCODEC, "MSCODEC" },
1143*0Sstevel@tonic-gate 	{ AUDIO_HWFEATURE_IN2OUT, "IN2OUT" },
1144*0Sstevel@tonic-gate 	{ AUDIO_HWFEATURE_PLAY, "PLAY" },
1145*0Sstevel@tonic-gate 	{ AUDIO_HWFEATURE_RECORD, "RECORD" },
1146*0Sstevel@tonic-gate 	{ 0, NULL }
1147*0Sstevel@tonic-gate };
1148*0Sstevel@tonic-gate 
1149*0Sstevel@tonic-gate static const struct audio_stuff audio_sw_features[] = {
1150*0Sstevel@tonic-gate 	{ AUDIO_SWFEATURE_MIXER, "MIXER" },
1151*0Sstevel@tonic-gate 	{ 0, NULL }
1152*0Sstevel@tonic-gate };
1153*0Sstevel@tonic-gate 
1154*0Sstevel@tonic-gate void
1155*0Sstevel@tonic-gate show_audio_features(const private_t *pri,
1156*0Sstevel@tonic-gate 	const struct audio_stuff *audio_porttab, uint_t features,
1157*0Sstevel@tonic-gate 	const char *name)
1158*0Sstevel@tonic-gate {
1159*0Sstevel@tonic-gate 	(void) printf("%s\t%s=", pri->pname, name);
1160*0Sstevel@tonic-gate 	if (features == 0) {
1161*0Sstevel@tonic-gate 		(void) printf("0\n");
1162*0Sstevel@tonic-gate 		return;
1163*0Sstevel@tonic-gate 	}
1164*0Sstevel@tonic-gate 
1165*0Sstevel@tonic-gate 	for (; audio_porttab->bit != 0; ++audio_porttab) {
1166*0Sstevel@tonic-gate 		if (features & audio_porttab->bit) {
1167*0Sstevel@tonic-gate 			(void) printf(audio_porttab->str);
1168*0Sstevel@tonic-gate 			features &= ~audio_porttab->bit;
1169*0Sstevel@tonic-gate 			if (features)
1170*0Sstevel@tonic-gate 				(void) putchar('|');
1171*0Sstevel@tonic-gate 		}
1172*0Sstevel@tonic-gate 	}
1173*0Sstevel@tonic-gate 	if (features)
1174*0Sstevel@tonic-gate 		(void) printf("0x%x", features);
1175*0Sstevel@tonic-gate 	(void) putchar('\n');
1176*0Sstevel@tonic-gate }
1177*0Sstevel@tonic-gate 
1178*0Sstevel@tonic-gate void
1179*0Sstevel@tonic-gate show_audio_ports(private_t *pri, const char *mode,
1180*0Sstevel@tonic-gate 	const char *field, uint_t ports)
1181*0Sstevel@tonic-gate {
1182*0Sstevel@tonic-gate 	const struct audio_stuff *audio_porttab;
1183*0Sstevel@tonic-gate 
1184*0Sstevel@tonic-gate 	(void) printf("%s\t%s\t%s=", pri->pname, mode, field);
1185*0Sstevel@tonic-gate 	if (ports == 0) {
1186*0Sstevel@tonic-gate 		(void) printf("0\n");
1187*0Sstevel@tonic-gate 		return;
1188*0Sstevel@tonic-gate 	}
1189*0Sstevel@tonic-gate 	if (*mode == 'p')
1190*0Sstevel@tonic-gate 		audio_porttab = audio_output_ports;
1191*0Sstevel@tonic-gate 	else
1192*0Sstevel@tonic-gate 		audio_porttab = audio_input_ports;
1193*0Sstevel@tonic-gate 	for (; audio_porttab->bit != 0; ++audio_porttab) {
1194*0Sstevel@tonic-gate 		if (ports & audio_porttab->bit) {
1195*0Sstevel@tonic-gate 			(void) printf(audio_porttab->str);
1196*0Sstevel@tonic-gate 			ports &= ~audio_porttab->bit;
1197*0Sstevel@tonic-gate 			if (ports)
1198*0Sstevel@tonic-gate 				(void) putchar('|');
1199*0Sstevel@tonic-gate 		}
1200*0Sstevel@tonic-gate 	}
1201*0Sstevel@tonic-gate 	if (ports)
1202*0Sstevel@tonic-gate 		(void) printf("0x%x", ports);
1203*0Sstevel@tonic-gate 	(void) putchar('\n');
1204*0Sstevel@tonic-gate }
1205*0Sstevel@tonic-gate 
1206*0Sstevel@tonic-gate void
1207*0Sstevel@tonic-gate show_audio_prinfo(private_t *pri, const char *mode, struct audio_prinfo *au_pr)
1208*0Sstevel@tonic-gate {
1209*0Sstevel@tonic-gate 	const char *s;
1210*0Sstevel@tonic-gate 
1211*0Sstevel@tonic-gate 	/*
1212*0Sstevel@tonic-gate 	 * The following values describe the audio data encoding.
1213*0Sstevel@tonic-gate 	 */
1214*0Sstevel@tonic-gate 
1215*0Sstevel@tonic-gate 	(void) printf("%s\t%s\tsample_rate=%u channels=%u precision=%u\n",
1216*0Sstevel@tonic-gate 		pri->pname, mode,
1217*0Sstevel@tonic-gate 		au_pr->sample_rate,
1218*0Sstevel@tonic-gate 		au_pr->channels,
1219*0Sstevel@tonic-gate 		au_pr->precision);
1220*0Sstevel@tonic-gate 
1221*0Sstevel@tonic-gate 	s = NULL;
1222*0Sstevel@tonic-gate 	switch (au_pr->encoding) {
1223*0Sstevel@tonic-gate 	case AUDIO_ENCODING_NONE:	s = "NONE";	break;
1224*0Sstevel@tonic-gate 	case AUDIO_ENCODING_ULAW:	s = "ULAW";	break;
1225*0Sstevel@tonic-gate 	case AUDIO_ENCODING_ALAW:	s = "ALAW";	break;
1226*0Sstevel@tonic-gate 	case AUDIO_ENCODING_LINEAR:	s = "LINEAR";	break;
1227*0Sstevel@tonic-gate 	case AUDIO_ENCODING_DVI:	s = "DVI";	break;
1228*0Sstevel@tonic-gate 	case AUDIO_ENCODING_LINEAR8:	s = "LINEAR8";	break;
1229*0Sstevel@tonic-gate 	}
1230*0Sstevel@tonic-gate 	if (s)
1231*0Sstevel@tonic-gate 		(void) printf("%s\t%s\tencoding=%s\n", pri->pname, mode, s);
1232*0Sstevel@tonic-gate 	else {
1233*0Sstevel@tonic-gate 		(void) printf("%s\t%s\tencoding=%u\n",
1234*0Sstevel@tonic-gate 			pri->pname, mode, au_pr->encoding);
1235*0Sstevel@tonic-gate 	}
1236*0Sstevel@tonic-gate 
1237*0Sstevel@tonic-gate 	/*
1238*0Sstevel@tonic-gate 	 * The following values control audio device configuration
1239*0Sstevel@tonic-gate 	 */
1240*0Sstevel@tonic-gate 
1241*0Sstevel@tonic-gate 	(void) printf(
1242*0Sstevel@tonic-gate 	"%s\t%s\tgain=%u buffer_size=%u\n",
1243*0Sstevel@tonic-gate 		pri->pname, mode,
1244*0Sstevel@tonic-gate 		au_pr->gain,
1245*0Sstevel@tonic-gate 		au_pr->buffer_size);
1246*0Sstevel@tonic-gate 	show_audio_ports(pri, mode, "port", au_pr->port);
1247*0Sstevel@tonic-gate 	show_audio_ports(pri, mode, "avail_ports", au_pr->avail_ports);
1248*0Sstevel@tonic-gate 	show_audio_ports(pri, mode, "mod_ports", au_pr->mod_ports);
1249*0Sstevel@tonic-gate 
1250*0Sstevel@tonic-gate 	/*
1251*0Sstevel@tonic-gate 	 * The following values describe driver state
1252*0Sstevel@tonic-gate 	 */
1253*0Sstevel@tonic-gate 
1254*0Sstevel@tonic-gate 	(void) printf("%s\t%s\tsamples=%u eof=%u pause=%u error=%u\n",
1255*0Sstevel@tonic-gate 		pri->pname, mode,
1256*0Sstevel@tonic-gate 		au_pr->samples,
1257*0Sstevel@tonic-gate 		au_pr->eof,
1258*0Sstevel@tonic-gate 		au_pr->pause,
1259*0Sstevel@tonic-gate 		au_pr->error);
1260*0Sstevel@tonic-gate 	(void) printf("%s\t%s\twaiting=%u balance=%u minordev=%u\n",
1261*0Sstevel@tonic-gate 		pri->pname, mode,
1262*0Sstevel@tonic-gate 		au_pr->waiting,
1263*0Sstevel@tonic-gate 		au_pr->balance,
1264*0Sstevel@tonic-gate 		au_pr->minordev);
1265*0Sstevel@tonic-gate 
1266*0Sstevel@tonic-gate 	/*
1267*0Sstevel@tonic-gate 	 * The following values are read-only state flags
1268*0Sstevel@tonic-gate 	 */
1269*0Sstevel@tonic-gate 	(void) printf("%s\t%s\topen=%u active=%u\n",
1270*0Sstevel@tonic-gate 		pri->pname, mode,
1271*0Sstevel@tonic-gate 		au_pr->open,
1272*0Sstevel@tonic-gate 		au_pr->active);
1273*0Sstevel@tonic-gate }
1274*0Sstevel@tonic-gate 
1275*0Sstevel@tonic-gate void
1276*0Sstevel@tonic-gate show_audio_info(private_t *pri, long offset)
1277*0Sstevel@tonic-gate {
1278*0Sstevel@tonic-gate 	struct audio_info au;
1279*0Sstevel@tonic-gate 
1280*0Sstevel@tonic-gate 	if (Pread(Proc, &au, sizeof (au), offset) == sizeof (au)) {
1281*0Sstevel@tonic-gate 		show_audio_prinfo(pri, "play", &au.play);
1282*0Sstevel@tonic-gate 		show_audio_prinfo(pri, "record", &au.record);
1283*0Sstevel@tonic-gate 		(void) printf("%s\tmonitor_gain=%u output_muted=%u\n",
1284*0Sstevel@tonic-gate 			pri->pname, au.monitor_gain, au.output_muted);
1285*0Sstevel@tonic-gate 		show_audio_features(pri, audio_hw_features, au.hw_features,
1286*0Sstevel@tonic-gate 		    "hw_features");
1287*0Sstevel@tonic-gate 		show_audio_features(pri, audio_sw_features, au.sw_features,
1288*0Sstevel@tonic-gate 		    "sw_features");
1289*0Sstevel@tonic-gate 		show_audio_features(pri, audio_sw_features,
1290*0Sstevel@tonic-gate 		    au.sw_features_enabled, "sw_features_enabled");
1291*0Sstevel@tonic-gate 	}
1292*0Sstevel@tonic-gate }
1293*0Sstevel@tonic-gate 
1294*0Sstevel@tonic-gate void
1295*0Sstevel@tonic-gate show_ioctl(private_t *pri, int code, long offset)
1296*0Sstevel@tonic-gate {
1297*0Sstevel@tonic-gate 	int lp64 = (data_model == PR_MODEL_LP64);
1298*0Sstevel@tonic-gate 	int err = pri->Errno;	/* don't display output parameters */
1299*0Sstevel@tonic-gate 				/* for a failed system call */
1300*0Sstevel@tonic-gate #ifndef _LP64
1301*0Sstevel@tonic-gate 	if (lp64)
1302*0Sstevel@tonic-gate 		return;
1303*0Sstevel@tonic-gate #endif
1304*0Sstevel@tonic-gate 	if (offset == NULL)
1305*0Sstevel@tonic-gate 		return;
1306*0Sstevel@tonic-gate 
1307*0Sstevel@tonic-gate 	switch (code) {
1308*0Sstevel@tonic-gate 	case TCGETA:
1309*0Sstevel@tonic-gate 		if (err)
1310*0Sstevel@tonic-gate 			break;
1311*0Sstevel@tonic-gate 		/*FALLTHROUGH*/
1312*0Sstevel@tonic-gate 	case TCSETA:
1313*0Sstevel@tonic-gate 	case TCSETAW:
1314*0Sstevel@tonic-gate 	case TCSETAF:
1315*0Sstevel@tonic-gate 		show_termio(pri, offset);
1316*0Sstevel@tonic-gate 		break;
1317*0Sstevel@tonic-gate 	case TCGETS:
1318*0Sstevel@tonic-gate 		if (err)
1319*0Sstevel@tonic-gate 			break;
1320*0Sstevel@tonic-gate 		/*FALLTHROUGH*/
1321*0Sstevel@tonic-gate 	case TCSETS:
1322*0Sstevel@tonic-gate 	case TCSETSW:
1323*0Sstevel@tonic-gate 	case TCSETSF:
1324*0Sstevel@tonic-gate 		show_termios(pri, offset);
1325*0Sstevel@tonic-gate 		break;
1326*0Sstevel@tonic-gate 	case TCGETX:
1327*0Sstevel@tonic-gate 		if (err)
1328*0Sstevel@tonic-gate 			break;
1329*0Sstevel@tonic-gate 		/*FALLTHROUGH*/
1330*0Sstevel@tonic-gate 	case TCSETX:
1331*0Sstevel@tonic-gate 	case TCSETXW:
1332*0Sstevel@tonic-gate 	case TCSETXF:
1333*0Sstevel@tonic-gate 		show_termiox(pri, offset);
1334*0Sstevel@tonic-gate 		break;
1335*0Sstevel@tonic-gate 	case TIOCGETP:
1336*0Sstevel@tonic-gate 		if (err)
1337*0Sstevel@tonic-gate 			break;
1338*0Sstevel@tonic-gate 		/*FALLTHROUGH*/
1339*0Sstevel@tonic-gate 	case TIOCSETN:
1340*0Sstevel@tonic-gate 	case TIOCSETP:
1341*0Sstevel@tonic-gate 		show_sgttyb(pri, offset);
1342*0Sstevel@tonic-gate 		break;
1343*0Sstevel@tonic-gate 	case TIOCGLTC:
1344*0Sstevel@tonic-gate 		if (err)
1345*0Sstevel@tonic-gate 			break;
1346*0Sstevel@tonic-gate 		/*FALLTHROUGH*/
1347*0Sstevel@tonic-gate 	case TIOCSLTC:
1348*0Sstevel@tonic-gate 		show_ltchars(pri, offset);
1349*0Sstevel@tonic-gate 		break;
1350*0Sstevel@tonic-gate 	case TIOCGETC:
1351*0Sstevel@tonic-gate 		if (err)
1352*0Sstevel@tonic-gate 			break;
1353*0Sstevel@tonic-gate 		/*FALLTHROUGH*/
1354*0Sstevel@tonic-gate 	case TIOCSETC:
1355*0Sstevel@tonic-gate 		show_tchars(pri, offset);
1356*0Sstevel@tonic-gate 		break;
1357*0Sstevel@tonic-gate 	case LDGETT:
1358*0Sstevel@tonic-gate 		if (err)
1359*0Sstevel@tonic-gate 			break;
1360*0Sstevel@tonic-gate 		/*FALLTHROUGH*/
1361*0Sstevel@tonic-gate 	case LDSETT:
1362*0Sstevel@tonic-gate 		show_termcb(pri, offset);
1363*0Sstevel@tonic-gate 		break;
1364*0Sstevel@tonic-gate 	/* streams ioctl()s */
1365*0Sstevel@tonic-gate #if 0
1366*0Sstevel@tonic-gate 		/* these are displayed as strings in the arg list */
1367*0Sstevel@tonic-gate 		/* by prt_ioa().  don't display them again here */
1368*0Sstevel@tonic-gate 	case I_PUSH:
1369*0Sstevel@tonic-gate 	case I_LOOK:
1370*0Sstevel@tonic-gate 	case I_FIND:
1371*0Sstevel@tonic-gate 		/* these are displayed as decimal in the arg list */
1372*0Sstevel@tonic-gate 		/* by prt_ioa().  don't display them again here */
1373*0Sstevel@tonic-gate 	case I_LINK:
1374*0Sstevel@tonic-gate 	case I_UNLINK:
1375*0Sstevel@tonic-gate 	case I_SENDFD:
1376*0Sstevel@tonic-gate 		/* these are displayed symbolically in the arg list */
1377*0Sstevel@tonic-gate 		/* by prt_ioa().  don't display them again here */
1378*0Sstevel@tonic-gate 	case I_SRDOPT:
1379*0Sstevel@tonic-gate 	case I_SETSIG:
1380*0Sstevel@tonic-gate 	case I_FLUSH:
1381*0Sstevel@tonic-gate 		break;
1382*0Sstevel@tonic-gate 		/* this one just ignores the argument */
1383*0Sstevel@tonic-gate 	case I_POP:
1384*0Sstevel@tonic-gate 		break;
1385*0Sstevel@tonic-gate #endif
1386*0Sstevel@tonic-gate 		/* these return something in an int pointed to by arg */
1387*0Sstevel@tonic-gate 	case I_NREAD:
1388*0Sstevel@tonic-gate 	case I_GRDOPT:
1389*0Sstevel@tonic-gate 	case I_GETSIG:
1390*0Sstevel@tonic-gate 	case TIOCGSID:
1391*0Sstevel@tonic-gate 	case TIOCGPGRP:
1392*0Sstevel@tonic-gate 	case TIOCLGET:
1393*0Sstevel@tonic-gate 	case FIONREAD:
1394*0Sstevel@tonic-gate 	case FIORDCHK:
1395*0Sstevel@tonic-gate 		if (err)
1396*0Sstevel@tonic-gate 			break;
1397*0Sstevel@tonic-gate 		/*FALLTHROUGH*/
1398*0Sstevel@tonic-gate 		/* these pass something in an int pointed to by arg */
1399*0Sstevel@tonic-gate 	case TIOCSPGRP:
1400*0Sstevel@tonic-gate 	case TIOCFLUSH:
1401*0Sstevel@tonic-gate 	case TIOCLBIS:
1402*0Sstevel@tonic-gate 	case TIOCLBIC:
1403*0Sstevel@tonic-gate 	case TIOCLSET:
1404*0Sstevel@tonic-gate 		show_strint(pri, code, offset);
1405*0Sstevel@tonic-gate 		break;
1406*0Sstevel@tonic-gate 		/* these all point to structures */
1407*0Sstevel@tonic-gate 	case I_STR:
1408*0Sstevel@tonic-gate #ifdef _LP64
1409*0Sstevel@tonic-gate 		if (lp64)
1410*0Sstevel@tonic-gate 			show_strioctl(pri, offset);
1411*0Sstevel@tonic-gate 		else
1412*0Sstevel@tonic-gate 			show_strioctl32(pri, offset);
1413*0Sstevel@tonic-gate #else
1414*0Sstevel@tonic-gate 		show_strioctl(pri, offset);
1415*0Sstevel@tonic-gate #endif
1416*0Sstevel@tonic-gate 		break;
1417*0Sstevel@tonic-gate 	case I_PEEK:
1418*0Sstevel@tonic-gate #ifdef _LP64
1419*0Sstevel@tonic-gate 		if (lp64)
1420*0Sstevel@tonic-gate 			show_strpeek(pri, offset);
1421*0Sstevel@tonic-gate 		else
1422*0Sstevel@tonic-gate 			show_strpeek32(pri, offset);
1423*0Sstevel@tonic-gate #else
1424*0Sstevel@tonic-gate 		show_strpeek(pri, offset);
1425*0Sstevel@tonic-gate #endif
1426*0Sstevel@tonic-gate 		break;
1427*0Sstevel@tonic-gate 	case I_FDINSERT:
1428*0Sstevel@tonic-gate #ifdef _LP64
1429*0Sstevel@tonic-gate 		if (lp64)
1430*0Sstevel@tonic-gate 			show_strfdinsert(pri, offset);
1431*0Sstevel@tonic-gate 		else
1432*0Sstevel@tonic-gate 			show_strfdinsert32(pri, offset);
1433*0Sstevel@tonic-gate #else
1434*0Sstevel@tonic-gate 		show_strfdinsert(pri, offset);
1435*0Sstevel@tonic-gate #endif
1436*0Sstevel@tonic-gate 		break;
1437*0Sstevel@tonic-gate 	case I_RECVFD:
1438*0Sstevel@tonic-gate 		if (err)
1439*0Sstevel@tonic-gate 			break;
1440*0Sstevel@tonic-gate 		show_strrecvfd(pri, offset);
1441*0Sstevel@tonic-gate 		break;
1442*0Sstevel@tonic-gate 	case I_LIST:
1443*0Sstevel@tonic-gate 		if (err)
1444*0Sstevel@tonic-gate 			break;
1445*0Sstevel@tonic-gate #ifdef _LP64
1446*0Sstevel@tonic-gate 		if (lp64)
1447*0Sstevel@tonic-gate 			show_strlist(pri, offset);
1448*0Sstevel@tonic-gate 		else
1449*0Sstevel@tonic-gate 			show_strlist32(pri, offset);
1450*0Sstevel@tonic-gate #else
1451*0Sstevel@tonic-gate 		show_strlist(pri, offset);
1452*0Sstevel@tonic-gate #endif
1453*0Sstevel@tonic-gate 		break;
1454*0Sstevel@tonic-gate 	case JWINSIZE:
1455*0Sstevel@tonic-gate 		if (err)
1456*0Sstevel@tonic-gate 			break;
1457*0Sstevel@tonic-gate 		show_jwinsize(pri, offset);
1458*0Sstevel@tonic-gate 		break;
1459*0Sstevel@tonic-gate 	case TIOCGWINSZ:
1460*0Sstevel@tonic-gate 		if (err)
1461*0Sstevel@tonic-gate 			break;
1462*0Sstevel@tonic-gate 		/*FALLTHROUGH*/
1463*0Sstevel@tonic-gate 	case TIOCSWINSZ:
1464*0Sstevel@tonic-gate 		show_winsize(pri, offset);
1465*0Sstevel@tonic-gate 		break;
1466*0Sstevel@tonic-gate 	case AUDIO_GETINFO:
1467*0Sstevel@tonic-gate 	case (int)AUDIO_SETINFO:
1468*0Sstevel@tonic-gate 		show_audio_info(pri, offset);
1469*0Sstevel@tonic-gate 		break;
1470*0Sstevel@tonic-gate 
1471*0Sstevel@tonic-gate 	default:
1472*0Sstevel@tonic-gate 		if (code & IOC_INOUT) {
1473*0Sstevel@tonic-gate 			const char *str = ioctldatastruct(code);
1474*0Sstevel@tonic-gate 
1475*0Sstevel@tonic-gate 			(void) printf("\t\t%s",
1476*0Sstevel@tonic-gate 			    (code & IOC_INOUT) == IOC_INOUT ? "write/read" :
1477*0Sstevel@tonic-gate 			    code & IOC_IN ? "write" : "read");
1478*0Sstevel@tonic-gate 			if (str != NULL) {
1479*0Sstevel@tonic-gate 				(void) printf(" (struct %s)\n", str);
1480*0Sstevel@tonic-gate 			} else {
1481*0Sstevel@tonic-gate 				(void) printf(" %d bytes\n",
1482*0Sstevel@tonic-gate 				    (code >> 16) & IOCPARM_MASK);
1483*0Sstevel@tonic-gate 			}
1484*0Sstevel@tonic-gate 		}
1485*0Sstevel@tonic-gate 	}
1486*0Sstevel@tonic-gate }
1487*0Sstevel@tonic-gate 
1488*0Sstevel@tonic-gate void
1489*0Sstevel@tonic-gate show_statvfs(private_t *pri)
1490*0Sstevel@tonic-gate {
1491*0Sstevel@tonic-gate 	long offset;
1492*0Sstevel@tonic-gate 	struct statvfs statvfs;
1493*0Sstevel@tonic-gate 	char *cp;
1494*0Sstevel@tonic-gate 
1495*0Sstevel@tonic-gate 	if (pri->sys_nargs > 1 && (offset = pri->sys_args[1]) != NULL &&
1496*0Sstevel@tonic-gate 	    Pread(Proc, &statvfs, sizeof (statvfs), offset)
1497*0Sstevel@tonic-gate 	    == sizeof (statvfs)) {
1498*0Sstevel@tonic-gate 		(void) printf(
1499*0Sstevel@tonic-gate 		"%s\tbsize=%-10lu frsize=%-9lu blocks=%-8llu bfree=%-9llu\n",
1500*0Sstevel@tonic-gate 			pri->pname,
1501*0Sstevel@tonic-gate 			statvfs.f_bsize,
1502*0Sstevel@tonic-gate 			statvfs.f_frsize,
1503*0Sstevel@tonic-gate 			(u_longlong_t)statvfs.f_blocks,
1504*0Sstevel@tonic-gate 			(u_longlong_t)statvfs.f_bfree);
1505*0Sstevel@tonic-gate 		(void) printf(
1506*0Sstevel@tonic-gate 		"%s\tbavail=%-9llu files=%-10llu ffree=%-9llu favail=%-9llu\n",
1507*0Sstevel@tonic-gate 			pri->pname,
1508*0Sstevel@tonic-gate 			(u_longlong_t)statvfs.f_bavail,
1509*0Sstevel@tonic-gate 			(u_longlong_t)statvfs.f_files,
1510*0Sstevel@tonic-gate 			(u_longlong_t)statvfs.f_ffree,
1511*0Sstevel@tonic-gate 			(u_longlong_t)statvfs.f_favail);
1512*0Sstevel@tonic-gate 		(void) printf(
1513*0Sstevel@tonic-gate 		"%s\tfsid=0x%-9.4lX basetype=%-7.16s namemax=%ld\n",
1514*0Sstevel@tonic-gate 			pri->pname,
1515*0Sstevel@tonic-gate 			statvfs.f_fsid,
1516*0Sstevel@tonic-gate 			statvfs.f_basetype,
1517*0Sstevel@tonic-gate 			(long)statvfs.f_namemax);
1518*0Sstevel@tonic-gate 		(void) printf(
1519*0Sstevel@tonic-gate 		"%s\tflag=%s\n",
1520*0Sstevel@tonic-gate 			pri->pname,
1521*0Sstevel@tonic-gate 			svfsflags(pri, (ulong_t)statvfs.f_flag));
1522*0Sstevel@tonic-gate 		cp = statvfs.f_fstr + strlen(statvfs.f_fstr);
1523*0Sstevel@tonic-gate 		if (cp < statvfs.f_fstr + sizeof (statvfs.f_fstr) - 1 &&
1524*0Sstevel@tonic-gate 		    *(cp+1) != '\0')
1525*0Sstevel@tonic-gate 			*cp = ' ';
1526*0Sstevel@tonic-gate 		(void) printf("%s\tfstr=\"%.*s\"\n",
1527*0Sstevel@tonic-gate 			pri->pname,
1528*0Sstevel@tonic-gate 			(int)sizeof (statvfs.f_fstr),
1529*0Sstevel@tonic-gate 			statvfs.f_fstr);
1530*0Sstevel@tonic-gate 	}
1531*0Sstevel@tonic-gate }
1532*0Sstevel@tonic-gate 
1533*0Sstevel@tonic-gate #ifdef _LP64
1534*0Sstevel@tonic-gate void
1535*0Sstevel@tonic-gate show_statvfs32(private_t *pri)
1536*0Sstevel@tonic-gate {
1537*0Sstevel@tonic-gate 	long offset;
1538*0Sstevel@tonic-gate 	struct statvfs32 statvfs;
1539*0Sstevel@tonic-gate 	char *cp;
1540*0Sstevel@tonic-gate 
1541*0Sstevel@tonic-gate 	if (pri->sys_nargs > 1 && (offset = pri->sys_args[1]) != NULL &&
1542*0Sstevel@tonic-gate 	    Pread(Proc, &statvfs, sizeof (statvfs), offset)
1543*0Sstevel@tonic-gate 	    == sizeof (statvfs)) {
1544*0Sstevel@tonic-gate 		(void) printf(
1545*0Sstevel@tonic-gate 		"%s\tbsize=%-10u frsize=%-9u blocks=%-8u bfree=%-9u\n",
1546*0Sstevel@tonic-gate 			pri->pname,
1547*0Sstevel@tonic-gate 			statvfs.f_bsize,
1548*0Sstevel@tonic-gate 			statvfs.f_frsize,
1549*0Sstevel@tonic-gate 			statvfs.f_blocks,
1550*0Sstevel@tonic-gate 			statvfs.f_bfree);
1551*0Sstevel@tonic-gate 		(void) printf(
1552*0Sstevel@tonic-gate 		"%s\tbavail=%-9u files=%-10u ffree=%-9u favail=%-9u\n",
1553*0Sstevel@tonic-gate 			pri->pname,
1554*0Sstevel@tonic-gate 			statvfs.f_bavail,
1555*0Sstevel@tonic-gate 			statvfs.f_files,
1556*0Sstevel@tonic-gate 			statvfs.f_ffree,
1557*0Sstevel@tonic-gate 			statvfs.f_favail);
1558*0Sstevel@tonic-gate 		(void) printf(
1559*0Sstevel@tonic-gate 		"%s\tfsid=0x%-9.4X basetype=%-7.16s namemax=%d\n",
1560*0Sstevel@tonic-gate 			pri->pname,
1561*0Sstevel@tonic-gate 			statvfs.f_fsid,
1562*0Sstevel@tonic-gate 			statvfs.f_basetype,
1563*0Sstevel@tonic-gate 			(int)statvfs.f_namemax);
1564*0Sstevel@tonic-gate 		(void) printf(
1565*0Sstevel@tonic-gate 		"%s\tflag=%s\n",
1566*0Sstevel@tonic-gate 			pri->pname,
1567*0Sstevel@tonic-gate 			svfsflags(pri, (ulong_t)statvfs.f_flag));
1568*0Sstevel@tonic-gate 		cp = statvfs.f_fstr + strlen(statvfs.f_fstr);
1569*0Sstevel@tonic-gate 		if (cp < statvfs.f_fstr + sizeof (statvfs.f_fstr) - 1 &&
1570*0Sstevel@tonic-gate 		    *(cp+1) != '\0')
1571*0Sstevel@tonic-gate 			*cp = ' ';
1572*0Sstevel@tonic-gate 		(void) printf("%s\tfstr=\"%.*s\"\n",
1573*0Sstevel@tonic-gate 			pri->pname,
1574*0Sstevel@tonic-gate 			(int)sizeof (statvfs.f_fstr),
1575*0Sstevel@tonic-gate 			statvfs.f_fstr);
1576*0Sstevel@tonic-gate 	}
1577*0Sstevel@tonic-gate }
1578*0Sstevel@tonic-gate #endif	/* _LP64 */
1579*0Sstevel@tonic-gate 
1580*0Sstevel@tonic-gate void
1581*0Sstevel@tonic-gate show_statvfs64(private_t *pri)
1582*0Sstevel@tonic-gate {
1583*0Sstevel@tonic-gate 	long offset;
1584*0Sstevel@tonic-gate 	struct statvfs64_32 statvfs;
1585*0Sstevel@tonic-gate 	char *cp;
1586*0Sstevel@tonic-gate 
1587*0Sstevel@tonic-gate 	if (pri->sys_nargs > 1 && (offset = pri->sys_args[1]) != NULL &&
1588*0Sstevel@tonic-gate 	    Pread(Proc, &statvfs, sizeof (statvfs), offset)
1589*0Sstevel@tonic-gate 	    == sizeof (statvfs)) {
1590*0Sstevel@tonic-gate 		(void) printf(
1591*0Sstevel@tonic-gate 		"%s\tbsize=%-10u frsize=%-9u blocks=%-8llu bfree=%-9llu\n",
1592*0Sstevel@tonic-gate 			pri->pname,
1593*0Sstevel@tonic-gate 			statvfs.f_bsize,
1594*0Sstevel@tonic-gate 			statvfs.f_frsize,
1595*0Sstevel@tonic-gate 			(u_longlong_t)statvfs.f_blocks,
1596*0Sstevel@tonic-gate 			(u_longlong_t)statvfs.f_bfree);
1597*0Sstevel@tonic-gate 		(void) printf(
1598*0Sstevel@tonic-gate 		"%s\tbavail=%-9llu files=%-10llu ffree=%-9llu favail=%-9llu\n",
1599*0Sstevel@tonic-gate 			pri->pname,
1600*0Sstevel@tonic-gate 			(u_longlong_t)statvfs.f_bavail,
1601*0Sstevel@tonic-gate 			(u_longlong_t)statvfs.f_files,
1602*0Sstevel@tonic-gate 			(u_longlong_t)statvfs.f_ffree,
1603*0Sstevel@tonic-gate 			(u_longlong_t)statvfs.f_favail);
1604*0Sstevel@tonic-gate 		(void) printf(
1605*0Sstevel@tonic-gate 		"%s\tfsid=0x%-9.4X basetype=%-7.16s namemax=%d\n",
1606*0Sstevel@tonic-gate 			pri->pname,
1607*0Sstevel@tonic-gate 			statvfs.f_fsid,
1608*0Sstevel@tonic-gate 			statvfs.f_basetype,
1609*0Sstevel@tonic-gate 			(int)statvfs.f_namemax);
1610*0Sstevel@tonic-gate 		(void) printf(
1611*0Sstevel@tonic-gate 		"%s\tflag=%s\n",
1612*0Sstevel@tonic-gate 			pri->pname,
1613*0Sstevel@tonic-gate 			svfsflags(pri, (ulong_t)statvfs.f_flag));
1614*0Sstevel@tonic-gate 		cp = statvfs.f_fstr + strlen(statvfs.f_fstr);
1615*0Sstevel@tonic-gate 		if (cp < statvfs.f_fstr + sizeof (statvfs.f_fstr) - 1 &&
1616*0Sstevel@tonic-gate 		    *(cp+1) != '\0')
1617*0Sstevel@tonic-gate 			*cp = ' ';
1618*0Sstevel@tonic-gate 		(void) printf("%s\tfstr=\"%.*s\"\n",
1619*0Sstevel@tonic-gate 			pri->pname,
1620*0Sstevel@tonic-gate 			(int)sizeof (statvfs.f_fstr),
1621*0Sstevel@tonic-gate 			statvfs.f_fstr);
1622*0Sstevel@tonic-gate 	}
1623*0Sstevel@tonic-gate }
1624*0Sstevel@tonic-gate 
1625*0Sstevel@tonic-gate void
1626*0Sstevel@tonic-gate show_statfs(private_t *pri)
1627*0Sstevel@tonic-gate {
1628*0Sstevel@tonic-gate 	long offset;
1629*0Sstevel@tonic-gate 	struct statfs statfs;
1630*0Sstevel@tonic-gate 
1631*0Sstevel@tonic-gate 	if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != NULL &&
1632*0Sstevel@tonic-gate 	    Pread(Proc, &statfs, sizeof (statfs), offset) == sizeof (statfs)) {
1633*0Sstevel@tonic-gate 		(void) printf(
1634*0Sstevel@tonic-gate 		"%s\tfty=%d bsz=%ld fsz=%ld blk=%ld bfr=%ld fil=%lu ffr=%lu\n",
1635*0Sstevel@tonic-gate 			pri->pname,
1636*0Sstevel@tonic-gate 			statfs.f_fstyp,
1637*0Sstevel@tonic-gate 			statfs.f_bsize,
1638*0Sstevel@tonic-gate 			statfs.f_frsize,
1639*0Sstevel@tonic-gate 			statfs.f_blocks,
1640*0Sstevel@tonic-gate 			statfs.f_bfree,
1641*0Sstevel@tonic-gate 			statfs.f_files,
1642*0Sstevel@tonic-gate 			statfs.f_ffree);
1643*0Sstevel@tonic-gate 		(void) printf("%s\t    fname=%.6s fpack=%.6s\n",
1644*0Sstevel@tonic-gate 			pri->pname,
1645*0Sstevel@tonic-gate 			statfs.f_fname,
1646*0Sstevel@tonic-gate 			statfs.f_fpack);
1647*0Sstevel@tonic-gate 	}
1648*0Sstevel@tonic-gate }
1649*0Sstevel@tonic-gate 
1650*0Sstevel@tonic-gate #ifdef _LP64
1651*0Sstevel@tonic-gate void
1652*0Sstevel@tonic-gate show_statfs32(private_t *pri)
1653*0Sstevel@tonic-gate {
1654*0Sstevel@tonic-gate 	long offset;
1655*0Sstevel@tonic-gate 	struct statfs32 statfs;
1656*0Sstevel@tonic-gate 
1657*0Sstevel@tonic-gate 	if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != NULL &&
1658*0Sstevel@tonic-gate 	    Pread(Proc, &statfs, sizeof (statfs), offset) == sizeof (statfs)) {
1659*0Sstevel@tonic-gate 		(void) printf(
1660*0Sstevel@tonic-gate 		"%s\tfty=%d bsz=%d fsz=%d blk=%d bfr=%d fil=%u ffr=%u\n",
1661*0Sstevel@tonic-gate 			pri->pname,
1662*0Sstevel@tonic-gate 			statfs.f_fstyp,
1663*0Sstevel@tonic-gate 			statfs.f_bsize,
1664*0Sstevel@tonic-gate 			statfs.f_frsize,
1665*0Sstevel@tonic-gate 			statfs.f_blocks,
1666*0Sstevel@tonic-gate 			statfs.f_bfree,
1667*0Sstevel@tonic-gate 			statfs.f_files,
1668*0Sstevel@tonic-gate 			statfs.f_ffree);
1669*0Sstevel@tonic-gate 		(void) printf("%s\t    fname=%.6s fpack=%.6s\n",
1670*0Sstevel@tonic-gate 			pri->pname,
1671*0Sstevel@tonic-gate 			statfs.f_fname,
1672*0Sstevel@tonic-gate 			statfs.f_fpack);
1673*0Sstevel@tonic-gate 	}
1674*0Sstevel@tonic-gate }
1675*0Sstevel@tonic-gate #endif	/* _LP64 */
1676*0Sstevel@tonic-gate 
1677*0Sstevel@tonic-gate void
1678*0Sstevel@tonic-gate show_flock32(private_t *pri, long offset)
1679*0Sstevel@tonic-gate {
1680*0Sstevel@tonic-gate 	struct flock32 flock;
1681*0Sstevel@tonic-gate 
1682*0Sstevel@tonic-gate 	if (Pread(Proc, &flock, sizeof (flock), offset) == sizeof (flock)) {
1683*0Sstevel@tonic-gate 		const char *str = NULL;
1684*0Sstevel@tonic-gate 
1685*0Sstevel@tonic-gate 		(void) printf("%s\ttyp=", pri->pname);
1686*0Sstevel@tonic-gate 
1687*0Sstevel@tonic-gate 		switch (flock.l_type) {
1688*0Sstevel@tonic-gate 		case F_RDLCK:
1689*0Sstevel@tonic-gate 			str = "F_RDLCK";
1690*0Sstevel@tonic-gate 			break;
1691*0Sstevel@tonic-gate 		case F_WRLCK:
1692*0Sstevel@tonic-gate 			str = "F_WRLCK";
1693*0Sstevel@tonic-gate 			break;
1694*0Sstevel@tonic-gate 		case F_UNLCK:
1695*0Sstevel@tonic-gate 			str = "F_UNLCK";
1696*0Sstevel@tonic-gate 			break;
1697*0Sstevel@tonic-gate 		}
1698*0Sstevel@tonic-gate 		if (str != NULL)
1699*0Sstevel@tonic-gate 			(void) printf("%s", str);
1700*0Sstevel@tonic-gate 		else
1701*0Sstevel@tonic-gate 			(void) printf("%-7d", flock.l_type);
1702*0Sstevel@tonic-gate 
1703*0Sstevel@tonic-gate 		str = whencearg(flock.l_whence);
1704*0Sstevel@tonic-gate 		if (str != NULL)
1705*0Sstevel@tonic-gate 			(void) printf("  whence=%s", str);
1706*0Sstevel@tonic-gate 		else
1707*0Sstevel@tonic-gate 			(void) printf("  whence=%-8u", flock.l_whence);
1708*0Sstevel@tonic-gate 
1709*0Sstevel@tonic-gate 		(void) printf(
1710*0Sstevel@tonic-gate 			" start=%-5d len=%-5d sys=%-2u pid=%d\n",
1711*0Sstevel@tonic-gate 			flock.l_start,
1712*0Sstevel@tonic-gate 			flock.l_len,
1713*0Sstevel@tonic-gate 			flock.l_sysid,
1714*0Sstevel@tonic-gate 			flock.l_pid);
1715*0Sstevel@tonic-gate 	}
1716*0Sstevel@tonic-gate }
1717*0Sstevel@tonic-gate 
1718*0Sstevel@tonic-gate void
1719*0Sstevel@tonic-gate show_flock64(private_t *pri, long offset)
1720*0Sstevel@tonic-gate {
1721*0Sstevel@tonic-gate 	struct flock64 flock;
1722*0Sstevel@tonic-gate 
1723*0Sstevel@tonic-gate 	if (Pread(Proc, &flock, sizeof (flock), offset) == sizeof (flock)) {
1724*0Sstevel@tonic-gate 		const char *str = NULL;
1725*0Sstevel@tonic-gate 
1726*0Sstevel@tonic-gate 		(void) printf("%s\ttyp=", pri->pname);
1727*0Sstevel@tonic-gate 
1728*0Sstevel@tonic-gate 		switch (flock.l_type) {
1729*0Sstevel@tonic-gate 		case F_RDLCK:
1730*0Sstevel@tonic-gate 			str = "F_RDLCK";
1731*0Sstevel@tonic-gate 			break;
1732*0Sstevel@tonic-gate 		case F_WRLCK:
1733*0Sstevel@tonic-gate 			str = "F_WRLCK";
1734*0Sstevel@tonic-gate 			break;
1735*0Sstevel@tonic-gate 		case F_UNLCK:
1736*0Sstevel@tonic-gate 			str = "F_UNLCK";
1737*0Sstevel@tonic-gate 			break;
1738*0Sstevel@tonic-gate 		}
1739*0Sstevel@tonic-gate 		if (str != NULL)
1740*0Sstevel@tonic-gate 			(void) printf("%s", str);
1741*0Sstevel@tonic-gate 		else
1742*0Sstevel@tonic-gate 			(void) printf("%-7d", flock.l_type);
1743*0Sstevel@tonic-gate 
1744*0Sstevel@tonic-gate 		str = whencearg(flock.l_whence);
1745*0Sstevel@tonic-gate 		if (str != NULL)
1746*0Sstevel@tonic-gate 			(void) printf("  whence=%s", str);
1747*0Sstevel@tonic-gate 		else
1748*0Sstevel@tonic-gate 			(void) printf("  whence=%-8u", flock.l_whence);
1749*0Sstevel@tonic-gate 
1750*0Sstevel@tonic-gate 		(void) printf(
1751*0Sstevel@tonic-gate 			" start=%-5lld len=%-5lld sys=%-2u pid=%d\n",
1752*0Sstevel@tonic-gate 			(long long)flock.l_start,
1753*0Sstevel@tonic-gate 			(long long)flock.l_len,
1754*0Sstevel@tonic-gate 			flock.l_sysid,
1755*0Sstevel@tonic-gate 			(int)flock.l_pid);
1756*0Sstevel@tonic-gate 	}
1757*0Sstevel@tonic-gate }
1758*0Sstevel@tonic-gate 
1759*0Sstevel@tonic-gate void
1760*0Sstevel@tonic-gate show_share(private_t *pri, long offset)
1761*0Sstevel@tonic-gate {
1762*0Sstevel@tonic-gate 	struct fshare fshare;
1763*0Sstevel@tonic-gate 
1764*0Sstevel@tonic-gate 	if (Pread(Proc, &fshare, sizeof (fshare), offset) == sizeof (fshare)) {
1765*0Sstevel@tonic-gate 		const char *str = NULL;
1766*0Sstevel@tonic-gate 		int manddny = 0;
1767*0Sstevel@tonic-gate 
1768*0Sstevel@tonic-gate 		(void) printf("%s\taccess=", pri->pname);
1769*0Sstevel@tonic-gate 
1770*0Sstevel@tonic-gate 		switch (fshare.f_access) {
1771*0Sstevel@tonic-gate 		case F_RDACC:
1772*0Sstevel@tonic-gate 			str = "F_RDACC";
1773*0Sstevel@tonic-gate 			break;
1774*0Sstevel@tonic-gate 		case F_WRACC:
1775*0Sstevel@tonic-gate 			str = "F_WRACC";
1776*0Sstevel@tonic-gate 			break;
1777*0Sstevel@tonic-gate 		case F_RWACC:
1778*0Sstevel@tonic-gate 			str = "F_RWACC";
1779*0Sstevel@tonic-gate 			break;
1780*0Sstevel@tonic-gate 		}
1781*0Sstevel@tonic-gate 		if (str != NULL)
1782*0Sstevel@tonic-gate 			(void) printf("%s", str);
1783*0Sstevel@tonic-gate 		else
1784*0Sstevel@tonic-gate 			(void) printf("%-7d", fshare.f_access);
1785*0Sstevel@tonic-gate 
1786*0Sstevel@tonic-gate 		str = NULL;
1787*0Sstevel@tonic-gate 		if (fshare.f_deny & F_MANDDNY) {
1788*0Sstevel@tonic-gate 			fshare.f_deny &= ~F_MANDDNY;
1789*0Sstevel@tonic-gate 			manddny = 1;
1790*0Sstevel@tonic-gate 		}
1791*0Sstevel@tonic-gate 		switch (fshare.f_deny) {
1792*0Sstevel@tonic-gate 		case F_NODNY:
1793*0Sstevel@tonic-gate 			str = "F_NODNY";
1794*0Sstevel@tonic-gate 			break;
1795*0Sstevel@tonic-gate 		case F_RDDNY:
1796*0Sstevel@tonic-gate 			str = "F_RDDNY";
1797*0Sstevel@tonic-gate 			break;
1798*0Sstevel@tonic-gate 		case F_WRDNY:
1799*0Sstevel@tonic-gate 			str = "F_WRDNY";
1800*0Sstevel@tonic-gate 			break;
1801*0Sstevel@tonic-gate 		case F_RWDNY:
1802*0Sstevel@tonic-gate 			str = "F_RWDNY";
1803*0Sstevel@tonic-gate 			break;
1804*0Sstevel@tonic-gate 		case F_COMPAT:
1805*0Sstevel@tonic-gate 			str = "F_COMPAT";
1806*0Sstevel@tonic-gate 			break;
1807*0Sstevel@tonic-gate 		}
1808*0Sstevel@tonic-gate 		if (str != NULL) {
1809*0Sstevel@tonic-gate 			if (manddny)
1810*0Sstevel@tonic-gate 				(void) printf("  deny=F_MANDDNY|%s", str);
1811*0Sstevel@tonic-gate 			else
1812*0Sstevel@tonic-gate 				(void) printf("  deny=%s", str);
1813*0Sstevel@tonic-gate 		} else {
1814*0Sstevel@tonic-gate 			(void) printf("  deny=0x%x", manddny?
1815*0Sstevel@tonic-gate 				fshare.f_deny | F_MANDDNY : fshare.f_deny);
1816*0Sstevel@tonic-gate 		}
1817*0Sstevel@tonic-gate 
1818*0Sstevel@tonic-gate 		(void) printf("  id=%x\n", fshare.f_id);
1819*0Sstevel@tonic-gate 	}
1820*0Sstevel@tonic-gate }
1821*0Sstevel@tonic-gate 
1822*0Sstevel@tonic-gate void
1823*0Sstevel@tonic-gate show_ffg(private_t *pri)
1824*0Sstevel@tonic-gate {
1825*0Sstevel@tonic-gate 	(void) putchar('\t');
1826*0Sstevel@tonic-gate 	(void) putchar('\t');
1827*0Sstevel@tonic-gate 	prt_ffg(pri, 0, pri->Rval1);
1828*0Sstevel@tonic-gate 	(void) puts(pri->sys_string);
1829*0Sstevel@tonic-gate }
1830*0Sstevel@tonic-gate 
1831*0Sstevel@tonic-gate /* print values in fcntl() pointed-to structure */
1832*0Sstevel@tonic-gate void
1833*0Sstevel@tonic-gate show_fcntl(private_t *pri)
1834*0Sstevel@tonic-gate {
1835*0Sstevel@tonic-gate 	long offset;
1836*0Sstevel@tonic-gate 
1837*0Sstevel@tonic-gate 	if (pri->sys_nargs >= 2 && pri->sys_args[1] == F_GETFL) {
1838*0Sstevel@tonic-gate 		show_ffg(pri);
1839*0Sstevel@tonic-gate 		return;
1840*0Sstevel@tonic-gate 	}
1841*0Sstevel@tonic-gate 
1842*0Sstevel@tonic-gate 	if (pri->sys_nargs < 3 || (offset = pri->sys_args[2]) == NULL)
1843*0Sstevel@tonic-gate 		return;
1844*0Sstevel@tonic-gate 
1845*0Sstevel@tonic-gate 	switch (pri->sys_args[1]) {
1846*0Sstevel@tonic-gate #ifdef _LP64
1847*0Sstevel@tonic-gate 	case F_GETLK:
1848*0Sstevel@tonic-gate 	case F_SETLK:
1849*0Sstevel@tonic-gate 	case F_SETLKW:
1850*0Sstevel@tonic-gate 	case F_FREESP:
1851*0Sstevel@tonic-gate 	case F_ALLOCSP:
1852*0Sstevel@tonic-gate 	case F_SETLK_NBMAND:
1853*0Sstevel@tonic-gate 		if (data_model == PR_MODEL_LP64)
1854*0Sstevel@tonic-gate 			show_flock64(pri, offset);
1855*0Sstevel@tonic-gate 		else
1856*0Sstevel@tonic-gate 			show_flock32(pri, offset);
1857*0Sstevel@tonic-gate 		break;
1858*0Sstevel@tonic-gate 	case 33:	/* F_GETLK64 */
1859*0Sstevel@tonic-gate 	case 34:	/* F_SETLK64 */
1860*0Sstevel@tonic-gate 	case 35:	/* F_SETLKW64 */
1861*0Sstevel@tonic-gate 	case 27:	/* F_FREESP64 */
1862*0Sstevel@tonic-gate 	case 44:	/* F_SETLK64_NBMAND */
1863*0Sstevel@tonic-gate 		show_flock64(pri, offset);
1864*0Sstevel@tonic-gate 		break;
1865*0Sstevel@tonic-gate #else	/* _LP64 */
1866*0Sstevel@tonic-gate 	case F_GETLK:
1867*0Sstevel@tonic-gate 	case F_SETLK:
1868*0Sstevel@tonic-gate 	case F_SETLKW:
1869*0Sstevel@tonic-gate 	case F_FREESP:
1870*0Sstevel@tonic-gate 	case F_ALLOCSP:
1871*0Sstevel@tonic-gate 	case F_SETLK_NBMAND:
1872*0Sstevel@tonic-gate 		show_flock32(pri, offset);
1873*0Sstevel@tonic-gate 		break;
1874*0Sstevel@tonic-gate 	case F_GETLK64:
1875*0Sstevel@tonic-gate 	case F_SETLK64:
1876*0Sstevel@tonic-gate 	case F_SETLKW64:
1877*0Sstevel@tonic-gate 	case F_FREESP64:
1878*0Sstevel@tonic-gate 	case F_SETLK64_NBMAND:
1879*0Sstevel@tonic-gate 		show_flock64(pri, offset);
1880*0Sstevel@tonic-gate 		break;
1881*0Sstevel@tonic-gate #endif	/* _LP64 */
1882*0Sstevel@tonic-gate 	case F_SHARE:
1883*0Sstevel@tonic-gate 	case F_UNSHARE:
1884*0Sstevel@tonic-gate 		show_share(pri, offset);
1885*0Sstevel@tonic-gate 		break;
1886*0Sstevel@tonic-gate 	}
1887*0Sstevel@tonic-gate }
1888*0Sstevel@tonic-gate 
1889*0Sstevel@tonic-gate void
1890*0Sstevel@tonic-gate show_strbuf(private_t *pri, long offset, const char *name, int dump)
1891*0Sstevel@tonic-gate {
1892*0Sstevel@tonic-gate 	struct strbuf strbuf;
1893*0Sstevel@tonic-gate 
1894*0Sstevel@tonic-gate 	if (Pread(Proc, &strbuf, sizeof (strbuf), offset) == sizeof (strbuf))
1895*0Sstevel@tonic-gate 		print_strbuf(pri, &strbuf, name, dump);
1896*0Sstevel@tonic-gate }
1897*0Sstevel@tonic-gate 
1898*0Sstevel@tonic-gate #ifdef _LP64
1899*0Sstevel@tonic-gate void
1900*0Sstevel@tonic-gate show_strbuf32(private_t *pri, long offset, const char *name, int dump)
1901*0Sstevel@tonic-gate {
1902*0Sstevel@tonic-gate 	struct strbuf32 strbuf;
1903*0Sstevel@tonic-gate 
1904*0Sstevel@tonic-gate 	if (Pread(Proc, &strbuf, sizeof (strbuf), offset) == sizeof (strbuf))
1905*0Sstevel@tonic-gate 		print_strbuf32(pri, &strbuf, name, dump);
1906*0Sstevel@tonic-gate }
1907*0Sstevel@tonic-gate #endif	/* _LP64 */
1908*0Sstevel@tonic-gate 
1909*0Sstevel@tonic-gate void
1910*0Sstevel@tonic-gate show_gp_msg(private_t *pri, int what)
1911*0Sstevel@tonic-gate {
1912*0Sstevel@tonic-gate 	long offset;
1913*0Sstevel@tonic-gate 	int dump = FALSE;
1914*0Sstevel@tonic-gate 	int fdp1 = pri->sys_args[0] + 1;
1915*0Sstevel@tonic-gate 
1916*0Sstevel@tonic-gate 	switch (what) {
1917*0Sstevel@tonic-gate 	case SYS_getmsg:
1918*0Sstevel@tonic-gate 	case SYS_getpmsg:
1919*0Sstevel@tonic-gate 		if (pri->Errno == 0 && prismember(&readfd, fdp1))
1920*0Sstevel@tonic-gate 			dump = TRUE;
1921*0Sstevel@tonic-gate 		break;
1922*0Sstevel@tonic-gate 	case SYS_putmsg:
1923*0Sstevel@tonic-gate 	case SYS_putpmsg:
1924*0Sstevel@tonic-gate 		if (prismember(&writefd, fdp1))
1925*0Sstevel@tonic-gate 			dump = TRUE;
1926*0Sstevel@tonic-gate 		break;
1927*0Sstevel@tonic-gate 	}
1928*0Sstevel@tonic-gate 
1929*0Sstevel@tonic-gate 	/* enter region of lengthy output */
1930*0Sstevel@tonic-gate 	if (dump)
1931*0Sstevel@tonic-gate 		Eserialize();
1932*0Sstevel@tonic-gate 
1933*0Sstevel@tonic-gate #ifdef _LP64
1934*0Sstevel@tonic-gate 	if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != NULL) {
1935*0Sstevel@tonic-gate 		if (data_model == PR_MODEL_LP64)
1936*0Sstevel@tonic-gate 			show_strbuf(pri, offset, "ctl", dump);
1937*0Sstevel@tonic-gate 		else
1938*0Sstevel@tonic-gate 			show_strbuf32(pri, offset, "ctl", dump);
1939*0Sstevel@tonic-gate 	}
1940*0Sstevel@tonic-gate 	if (pri->sys_nargs >= 3 && (offset = pri->sys_args[2]) != NULL) {
1941*0Sstevel@tonic-gate 		if (data_model == PR_MODEL_LP64)
1942*0Sstevel@tonic-gate 			show_strbuf(pri, offset, "dat", dump);
1943*0Sstevel@tonic-gate 		else
1944*0Sstevel@tonic-gate 			show_strbuf32(pri, offset, "dat", dump);
1945*0Sstevel@tonic-gate 	}
1946*0Sstevel@tonic-gate #else	/* _LP64 */
1947*0Sstevel@tonic-gate 	if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != NULL)
1948*0Sstevel@tonic-gate 		show_strbuf(pri, offset, "ctl", dump);
1949*0Sstevel@tonic-gate 	if (pri->sys_nargs >= 3 && (offset = pri->sys_args[2]) != NULL)
1950*0Sstevel@tonic-gate 		show_strbuf(pri, offset, "dat", dump);
1951*0Sstevel@tonic-gate #endif	/* _LP64 */
1952*0Sstevel@tonic-gate 
1953*0Sstevel@tonic-gate 	/* exit region of lengthy output */
1954*0Sstevel@tonic-gate 	if (dump)
1955*0Sstevel@tonic-gate 		Xserialize();
1956*0Sstevel@tonic-gate }
1957*0Sstevel@tonic-gate 
1958*0Sstevel@tonic-gate void
1959*0Sstevel@tonic-gate show_int(private_t *pri, long offset, const char *name)
1960*0Sstevel@tonic-gate {
1961*0Sstevel@tonic-gate 	int value;
1962*0Sstevel@tonic-gate 
1963*0Sstevel@tonic-gate 	if (offset != 0 &&
1964*0Sstevel@tonic-gate 	    Pread(Proc, &value, sizeof (value), offset) == sizeof (value))
1965*0Sstevel@tonic-gate 		(void) printf("%s\t%s:\t%d\n",
1966*0Sstevel@tonic-gate 			pri->pname,
1967*0Sstevel@tonic-gate 			name,
1968*0Sstevel@tonic-gate 			value);
1969*0Sstevel@tonic-gate }
1970*0Sstevel@tonic-gate 
1971*0Sstevel@tonic-gate void
1972*0Sstevel@tonic-gate show_hhex_int(private_t *pri, long offset, const char *name)
1973*0Sstevel@tonic-gate {
1974*0Sstevel@tonic-gate 	int value;
1975*0Sstevel@tonic-gate 
1976*0Sstevel@tonic-gate 	if (Pread(Proc, &value, sizeof (value), offset) == sizeof (value))
1977*0Sstevel@tonic-gate 		(void) printf("%s\t%s:\t0x%.4X\n",
1978*0Sstevel@tonic-gate 			pri->pname,
1979*0Sstevel@tonic-gate 			name,
1980*0Sstevel@tonic-gate 			value);
1981*0Sstevel@tonic-gate }
1982*0Sstevel@tonic-gate 
1983*0Sstevel@tonic-gate #define	ALL_POLL_FLAGS	(POLLIN|POLLPRI|POLLOUT| \
1984*0Sstevel@tonic-gate 	POLLRDNORM|POLLRDBAND|POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
1985*0Sstevel@tonic-gate 
1986*0Sstevel@tonic-gate const char *
1987*0Sstevel@tonic-gate pollevent(private_t *pri, int arg)
1988*0Sstevel@tonic-gate {
1989*0Sstevel@tonic-gate 	char *str = pri->code_buf;
1990*0Sstevel@tonic-gate 
1991*0Sstevel@tonic-gate 	if (arg == 0)
1992*0Sstevel@tonic-gate 		return ("0");
1993*0Sstevel@tonic-gate 	if (arg & ~ALL_POLL_FLAGS) {
1994*0Sstevel@tonic-gate 		(void) sprintf(str, "0x%-5X", arg);
1995*0Sstevel@tonic-gate 		return ((const char *)str);
1996*0Sstevel@tonic-gate 	}
1997*0Sstevel@tonic-gate 
1998*0Sstevel@tonic-gate 	*str = '\0';
1999*0Sstevel@tonic-gate 	if (arg & POLLIN)
2000*0Sstevel@tonic-gate 		(void) strcat(str, "|POLLIN");
2001*0Sstevel@tonic-gate 	if (arg & POLLPRI)
2002*0Sstevel@tonic-gate 		(void) strcat(str, "|POLLPRI");
2003*0Sstevel@tonic-gate 	if (arg & POLLOUT)
2004*0Sstevel@tonic-gate 		(void) strcat(str, "|POLLOUT");
2005*0Sstevel@tonic-gate 	if (arg & POLLRDNORM)
2006*0Sstevel@tonic-gate 		(void) strcat(str, "|POLLRDNORM");
2007*0Sstevel@tonic-gate 	if (arg & POLLRDBAND)
2008*0Sstevel@tonic-gate 		(void) strcat(str, "|POLLRDBAND");
2009*0Sstevel@tonic-gate 	if (arg & POLLWRBAND)
2010*0Sstevel@tonic-gate 		(void) strcat(str, "|POLLWRBAND");
2011*0Sstevel@tonic-gate 	if (arg & POLLERR)
2012*0Sstevel@tonic-gate 		(void) strcat(str, "|POLLERR");
2013*0Sstevel@tonic-gate 	if (arg & POLLHUP)
2014*0Sstevel@tonic-gate 		(void) strcat(str, "|POLLHUP");
2015*0Sstevel@tonic-gate 	if (arg & POLLNVAL)
2016*0Sstevel@tonic-gate 		(void) strcat(str, "|POLLNVAL");
2017*0Sstevel@tonic-gate 
2018*0Sstevel@tonic-gate 	return ((const char *)(str+1));
2019*0Sstevel@tonic-gate }
2020*0Sstevel@tonic-gate 
2021*0Sstevel@tonic-gate static void
2022*0Sstevel@tonic-gate show_one_pollfd(private_t *pri, struct pollfd *ppollfd)
2023*0Sstevel@tonic-gate {
2024*0Sstevel@tonic-gate 	/*
2025*0Sstevel@tonic-gate 	 * can't print both events and revents in same printf.
2026*0Sstevel@tonic-gate 	 * pollevent() returns a pointer to a TSD location.
2027*0Sstevel@tonic-gate 	 */
2028*0Sstevel@tonic-gate 	(void) printf("%s\tfd=%-2d ev=%s",
2029*0Sstevel@tonic-gate 	    pri->pname, ppollfd->fd, pollevent(pri, ppollfd->events));
2030*0Sstevel@tonic-gate 	(void) printf(" rev=%s\n", pollevent(pri, ppollfd->revents));
2031*0Sstevel@tonic-gate }
2032*0Sstevel@tonic-gate 
2033*0Sstevel@tonic-gate static void
2034*0Sstevel@tonic-gate show_all_pollfds(private_t *pri, long offset, int nfds)
2035*0Sstevel@tonic-gate {
2036*0Sstevel@tonic-gate 	struct pollfd pollfd[2];
2037*0Sstevel@tonic-gate 	int skip = -1;
2038*0Sstevel@tonic-gate 
2039*0Sstevel@tonic-gate 	for (; nfds && !interrupt; nfds--, offset += sizeof (struct pollfd)) {
2040*0Sstevel@tonic-gate 		if (Pread(Proc, &pollfd[0], sizeof (struct pollfd), offset) !=
2041*0Sstevel@tonic-gate 		    sizeof (struct pollfd))
2042*0Sstevel@tonic-gate 			continue;
2043*0Sstevel@tonic-gate 
2044*0Sstevel@tonic-gate 		if (skip >= 0 && pollfd[0].fd == pollfd[1].fd &&
2045*0Sstevel@tonic-gate 		    pollfd[0].events == pollfd[1].events &&
2046*0Sstevel@tonic-gate 		    pollfd[0].revents == pollfd[1].revents) {
2047*0Sstevel@tonic-gate 			skip++;
2048*0Sstevel@tonic-gate 			continue;
2049*0Sstevel@tonic-gate 		}
2050*0Sstevel@tonic-gate 
2051*0Sstevel@tonic-gate 		if (skip > 0)
2052*0Sstevel@tonic-gate 			(void) printf("%s\t...last pollfd structure"
2053*0Sstevel@tonic-gate 			    " repeated %d time%s...\n",
2054*0Sstevel@tonic-gate 			    pri->pname, skip, (skip == 1 ? "" : "s"));
2055*0Sstevel@tonic-gate 
2056*0Sstevel@tonic-gate 		skip = 0;
2057*0Sstevel@tonic-gate 		show_one_pollfd(pri, &pollfd[0]);
2058*0Sstevel@tonic-gate 		pollfd[1] = pollfd[0];
2059*0Sstevel@tonic-gate 	}
2060*0Sstevel@tonic-gate 
2061*0Sstevel@tonic-gate 	if (skip > 0)
2062*0Sstevel@tonic-gate 		(void) printf(
2063*0Sstevel@tonic-gate 		    "%s\t...last pollfd structure repeated %d time%s...\n",
2064*0Sstevel@tonic-gate 		    pri->pname, skip, (skip == 1 ? "" : "s"));
2065*0Sstevel@tonic-gate }
2066*0Sstevel@tonic-gate 
2067*0Sstevel@tonic-gate void
2068*0Sstevel@tonic-gate show_poll(private_t *pri)
2069*0Sstevel@tonic-gate {
2070*0Sstevel@tonic-gate 	long offset;
2071*0Sstevel@tonic-gate 	int nfds;
2072*0Sstevel@tonic-gate 	int serial = 0;
2073*0Sstevel@tonic-gate 
2074*0Sstevel@tonic-gate 	if (pri->sys_nargs < 2 || (offset = pri->sys_args[0]) == NULL ||
2075*0Sstevel@tonic-gate 	    (nfds = pri->sys_args[1]) <= 0)
2076*0Sstevel@tonic-gate 		return;
2077*0Sstevel@tonic-gate 
2078*0Sstevel@tonic-gate 	/* enter region of lengthy output */
2079*0Sstevel@tonic-gate 	if (nfds > 32) {
2080*0Sstevel@tonic-gate 		Eserialize();
2081*0Sstevel@tonic-gate 		serial = 1;
2082*0Sstevel@tonic-gate 	}
2083*0Sstevel@tonic-gate 
2084*0Sstevel@tonic-gate 	show_all_pollfds(pri, offset, nfds);
2085*0Sstevel@tonic-gate 
2086*0Sstevel@tonic-gate 	/* exit region of lengthy output */
2087*0Sstevel@tonic-gate 	if (serial)
2088*0Sstevel@tonic-gate 		Xserialize();
2089*0Sstevel@tonic-gate }
2090*0Sstevel@tonic-gate 
2091*0Sstevel@tonic-gate void
2092*0Sstevel@tonic-gate show_pollsys(private_t *pri)
2093*0Sstevel@tonic-gate {
2094*0Sstevel@tonic-gate 	long offset;
2095*0Sstevel@tonic-gate 	int nfds;
2096*0Sstevel@tonic-gate 	int serial = 0;
2097*0Sstevel@tonic-gate 
2098*0Sstevel@tonic-gate 	if (pri->sys_nargs < 2)
2099*0Sstevel@tonic-gate 		return;
2100*0Sstevel@tonic-gate 
2101*0Sstevel@tonic-gate 	offset = pri->sys_args[0];
2102*0Sstevel@tonic-gate 	nfds = pri->sys_args[1];
2103*0Sstevel@tonic-gate 
2104*0Sstevel@tonic-gate 	/* enter region of lengthy output */
2105*0Sstevel@tonic-gate 	if (offset != NULL && nfds > 32) {
2106*0Sstevel@tonic-gate 		Eserialize();
2107*0Sstevel@tonic-gate 		serial = 1;
2108*0Sstevel@tonic-gate 	}
2109*0Sstevel@tonic-gate 
2110*0Sstevel@tonic-gate 	if (offset != NULL && nfds > 0)
2111*0Sstevel@tonic-gate 		show_all_pollfds(pri, offset, nfds);
2112*0Sstevel@tonic-gate 
2113*0Sstevel@tonic-gate 	if (pri->sys_nargs > 2)
2114*0Sstevel@tonic-gate 		show_timestruc(pri, (long)pri->sys_args[2], "timeout");
2115*0Sstevel@tonic-gate 
2116*0Sstevel@tonic-gate 	if (pri->sys_nargs > 3)
2117*0Sstevel@tonic-gate 		show_sigset(pri, (long)pri->sys_args[3], "sigmask");
2118*0Sstevel@tonic-gate 
2119*0Sstevel@tonic-gate 	/* exit region of lengthy output */
2120*0Sstevel@tonic-gate 	if (serial)
2121*0Sstevel@tonic-gate 		Xserialize();
2122*0Sstevel@tonic-gate }
2123*0Sstevel@tonic-gate 
2124*0Sstevel@tonic-gate static void
2125*0Sstevel@tonic-gate show_perm64(private_t *pri, struct ipc_perm64 *ip)
2126*0Sstevel@tonic-gate {
2127*0Sstevel@tonic-gate 	(void) printf("%s\tu=%-5d g=%-5d cu=%-5d cg=%-5d z=%-5d "
2128*0Sstevel@tonic-gate 	    "m=0%.6o key=%d projid=%-5d\n",
2129*0Sstevel@tonic-gate 	    pri->pname,
2130*0Sstevel@tonic-gate 	    (int)ip->ipcx_uid,
2131*0Sstevel@tonic-gate 	    (int)ip->ipcx_gid,
2132*0Sstevel@tonic-gate 	    (int)ip->ipcx_cuid,
2133*0Sstevel@tonic-gate 	    (int)ip->ipcx_cgid,
2134*0Sstevel@tonic-gate 	    (int)ip->ipcx_zoneid,
2135*0Sstevel@tonic-gate 	    (unsigned int)ip->ipcx_mode,
2136*0Sstevel@tonic-gate 	    ip->ipcx_key,
2137*0Sstevel@tonic-gate 	    (int)ip->ipcx_projid);
2138*0Sstevel@tonic-gate }
2139*0Sstevel@tonic-gate 
2140*0Sstevel@tonic-gate void
2141*0Sstevel@tonic-gate show_perm(private_t *pri, struct ipc_perm *ip)
2142*0Sstevel@tonic-gate {
2143*0Sstevel@tonic-gate 	(void) printf(
2144*0Sstevel@tonic-gate 	"%s\tu=%-5u g=%-5u cu=%-5u cg=%-5u m=0%.6o seq=%u key=%d\n",
2145*0Sstevel@tonic-gate 		pri->pname,
2146*0Sstevel@tonic-gate 		(int)ip->uid,
2147*0Sstevel@tonic-gate 		(int)ip->gid,
2148*0Sstevel@tonic-gate 		(int)ip->cuid,
2149*0Sstevel@tonic-gate 		(int)ip->cgid,
2150*0Sstevel@tonic-gate 		(int)ip->mode,
2151*0Sstevel@tonic-gate 		ip->seq,
2152*0Sstevel@tonic-gate 		ip->key);
2153*0Sstevel@tonic-gate }
2154*0Sstevel@tonic-gate 
2155*0Sstevel@tonic-gate #ifdef _LP64
2156*0Sstevel@tonic-gate void
2157*0Sstevel@tonic-gate show_perm32(private_t *pri, struct ipc_perm32 *ip)
2158*0Sstevel@tonic-gate {
2159*0Sstevel@tonic-gate 	(void) printf(
2160*0Sstevel@tonic-gate 	"%s\tu=%-5u g=%-5u cu=%-5u cg=%-5u m=0%.6o seq=%u key=%d\n",
2161*0Sstevel@tonic-gate 		pri->pname,
2162*0Sstevel@tonic-gate 		ip->uid,
2163*0Sstevel@tonic-gate 		ip->gid,
2164*0Sstevel@tonic-gate 		ip->cuid,
2165*0Sstevel@tonic-gate 		ip->cgid,
2166*0Sstevel@tonic-gate 		ip->mode,
2167*0Sstevel@tonic-gate 		ip->seq,
2168*0Sstevel@tonic-gate 		ip->key);
2169*0Sstevel@tonic-gate }
2170*0Sstevel@tonic-gate #endif	/* _LP64 */
2171*0Sstevel@tonic-gate 
2172*0Sstevel@tonic-gate static void
2173*0Sstevel@tonic-gate show_msgctl64(private_t *pri, long offset)
2174*0Sstevel@tonic-gate {
2175*0Sstevel@tonic-gate 	struct msqid_ds64 msgq;
2176*0Sstevel@tonic-gate 
2177*0Sstevel@tonic-gate 	if (offset != NULL &&
2178*0Sstevel@tonic-gate 	    Pread(Proc, &msgq, sizeof (msgq), offset) == sizeof (msgq)) {
2179*0Sstevel@tonic-gate 		show_perm64(pri, &msgq.msgx_perm);
2180*0Sstevel@tonic-gate 
2181*0Sstevel@tonic-gate 		(void) printf("%s\tbytes=%-5llu msgs=%-5llu maxby=%-5llu "
2182*0Sstevel@tonic-gate 		    "lspid=%-5d lrpid=%-5d\n", pri->pname,
2183*0Sstevel@tonic-gate 		    (unsigned long long)msgq.msgx_cbytes,
2184*0Sstevel@tonic-gate 		    (unsigned long long)msgq.msgx_qnum,
2185*0Sstevel@tonic-gate 		    (unsigned long long)msgq.msgx_qbytes,
2186*0Sstevel@tonic-gate 		    (int)msgq.msgx_lspid,
2187*0Sstevel@tonic-gate 		    (int)msgq.msgx_lrpid);
2188*0Sstevel@tonic-gate 
2189*0Sstevel@tonic-gate 		prtime(pri, "    st = ", (time_t)msgq.msgx_stime);
2190*0Sstevel@tonic-gate 		prtime(pri, "    rt = ", (time_t)msgq.msgx_rtime);
2191*0Sstevel@tonic-gate 		prtime(pri, "    ct = ", (time_t)msgq.msgx_ctime);
2192*0Sstevel@tonic-gate 	}
2193*0Sstevel@tonic-gate }
2194*0Sstevel@tonic-gate 
2195*0Sstevel@tonic-gate void
2196*0Sstevel@tonic-gate show_msgctl(private_t *pri, long offset)
2197*0Sstevel@tonic-gate {
2198*0Sstevel@tonic-gate 	struct msqid_ds msgq;
2199*0Sstevel@tonic-gate 
2200*0Sstevel@tonic-gate 	if (offset != NULL &&
2201*0Sstevel@tonic-gate 	    Pread(Proc, &msgq, sizeof (msgq), offset) == sizeof (msgq)) {
2202*0Sstevel@tonic-gate 		show_perm(pri, &msgq.msg_perm);
2203*0Sstevel@tonic-gate 
2204*0Sstevel@tonic-gate 		(void) printf(
2205*0Sstevel@tonic-gate 	"%s\tbytes=%-5lu msgs=%-5lu maxby=%-5lu lspid=%-5u lrpid=%-5u\n",
2206*0Sstevel@tonic-gate 			pri->pname,
2207*0Sstevel@tonic-gate 			msgq.msg_cbytes,
2208*0Sstevel@tonic-gate 			msgq.msg_qnum,
2209*0Sstevel@tonic-gate 			msgq.msg_qbytes,
2210*0Sstevel@tonic-gate 			(int)msgq.msg_lspid,
2211*0Sstevel@tonic-gate 			(int)msgq.msg_lrpid);
2212*0Sstevel@tonic-gate 
2213*0Sstevel@tonic-gate 		prtime(pri, "    st = ", msgq.msg_stime);
2214*0Sstevel@tonic-gate 		prtime(pri, "    rt = ", msgq.msg_rtime);
2215*0Sstevel@tonic-gate 		prtime(pri, "    ct = ", msgq.msg_ctime);
2216*0Sstevel@tonic-gate 	}
2217*0Sstevel@tonic-gate }
2218*0Sstevel@tonic-gate 
2219*0Sstevel@tonic-gate #ifdef _LP64
2220*0Sstevel@tonic-gate void
2221*0Sstevel@tonic-gate show_msgctl32(private_t *pri, long offset)
2222*0Sstevel@tonic-gate {
2223*0Sstevel@tonic-gate 	struct msqid_ds32 msgq;
2224*0Sstevel@tonic-gate 
2225*0Sstevel@tonic-gate 	if (offset != NULL &&
2226*0Sstevel@tonic-gate 	    Pread(Proc, &msgq, sizeof (msgq), offset) == sizeof (msgq)) {
2227*0Sstevel@tonic-gate 		show_perm32(pri, &msgq.msg_perm);
2228*0Sstevel@tonic-gate 
2229*0Sstevel@tonic-gate 		(void) printf(
2230*0Sstevel@tonic-gate 	"%s\tbytes=%-5u msgs=%-5u maxby=%-5u lspid=%-5u lrpid=%-5u\n",
2231*0Sstevel@tonic-gate 			pri->pname,
2232*0Sstevel@tonic-gate 			msgq.msg_cbytes,
2233*0Sstevel@tonic-gate 			msgq.msg_qnum,
2234*0Sstevel@tonic-gate 			msgq.msg_qbytes,
2235*0Sstevel@tonic-gate 			msgq.msg_lspid,
2236*0Sstevel@tonic-gate 			msgq.msg_lrpid);
2237*0Sstevel@tonic-gate 
2238*0Sstevel@tonic-gate 		prtime(pri, "    st = ", msgq.msg_stime);
2239*0Sstevel@tonic-gate 		prtime(pri, "    rt = ", msgq.msg_rtime);
2240*0Sstevel@tonic-gate 		prtime(pri, "    ct = ", msgq.msg_ctime);
2241*0Sstevel@tonic-gate 	}
2242*0Sstevel@tonic-gate }
2243*0Sstevel@tonic-gate #endif	/* _LP64 */
2244*0Sstevel@tonic-gate 
2245*0Sstevel@tonic-gate void
2246*0Sstevel@tonic-gate show_msgbuf(private_t *pri, long offset, long msgsz)
2247*0Sstevel@tonic-gate {
2248*0Sstevel@tonic-gate 	struct msgbuf msgb;
2249*0Sstevel@tonic-gate 
2250*0Sstevel@tonic-gate 	if (offset != NULL &&
2251*0Sstevel@tonic-gate 	    Pread(Proc, &msgb, sizeof (msgb.mtype), offset) ==
2252*0Sstevel@tonic-gate 	    sizeof (msgb.mtype)) {
2253*0Sstevel@tonic-gate 		/* enter region of lengthy output */
2254*0Sstevel@tonic-gate 		if (msgsz > MYBUFSIZ / 4)
2255*0Sstevel@tonic-gate 			Eserialize();
2256*0Sstevel@tonic-gate 
2257*0Sstevel@tonic-gate 		(void) printf("%s\tmtype=%lu  mtext[]=\n",
2258*0Sstevel@tonic-gate 			pri->pname,
2259*0Sstevel@tonic-gate 			msgb.mtype);
2260*0Sstevel@tonic-gate 		showbuffer(pri,
2261*0Sstevel@tonic-gate 			(long)(offset + sizeof (msgb.mtype)), msgsz);
2262*0Sstevel@tonic-gate 
2263*0Sstevel@tonic-gate 		/* exit region of lengthy output */
2264*0Sstevel@tonic-gate 		if (msgsz > MYBUFSIZ / 4)
2265*0Sstevel@tonic-gate 			Xserialize();
2266*0Sstevel@tonic-gate 	}
2267*0Sstevel@tonic-gate }
2268*0Sstevel@tonic-gate 
2269*0Sstevel@tonic-gate #ifdef _LP64
2270*0Sstevel@tonic-gate void
2271*0Sstevel@tonic-gate show_msgbuf32(private_t *pri, long offset, long msgsz)
2272*0Sstevel@tonic-gate {
2273*0Sstevel@tonic-gate 	struct ipcmsgbuf32 msgb;
2274*0Sstevel@tonic-gate 
2275*0Sstevel@tonic-gate 	if (offset != NULL &&
2276*0Sstevel@tonic-gate 	    Pread(Proc, &msgb, sizeof (msgb.mtype), offset) ==
2277*0Sstevel@tonic-gate 	    sizeof (msgb.mtype)) {
2278*0Sstevel@tonic-gate 		/* enter region of lengthy output */
2279*0Sstevel@tonic-gate 		if (msgsz > MYBUFSIZ / 4)
2280*0Sstevel@tonic-gate 			Eserialize();
2281*0Sstevel@tonic-gate 
2282*0Sstevel@tonic-gate 		(void) printf("%s\tmtype=%u  mtext[]=\n",
2283*0Sstevel@tonic-gate 			pri->pname,
2284*0Sstevel@tonic-gate 			msgb.mtype);
2285*0Sstevel@tonic-gate 		showbuffer(pri,
2286*0Sstevel@tonic-gate 			(long)(offset + sizeof (msgb.mtype)), msgsz);
2287*0Sstevel@tonic-gate 
2288*0Sstevel@tonic-gate 		/* exit region of lengthy output */
2289*0Sstevel@tonic-gate 		if (msgsz > MYBUFSIZ / 4)
2290*0Sstevel@tonic-gate 			Xserialize();
2291*0Sstevel@tonic-gate 	}
2292*0Sstevel@tonic-gate }
2293*0Sstevel@tonic-gate #endif	/* _LP64 */
2294*0Sstevel@tonic-gate 
2295*0Sstevel@tonic-gate #ifdef _LP64
2296*0Sstevel@tonic-gate void
2297*0Sstevel@tonic-gate show_msgsys(private_t *pri, long msgsz)
2298*0Sstevel@tonic-gate {
2299*0Sstevel@tonic-gate 	switch (pri->sys_args[0]) {
2300*0Sstevel@tonic-gate 	case 0:			/* msgget() */
2301*0Sstevel@tonic-gate 		break;
2302*0Sstevel@tonic-gate 	case 1:			/* msgctl() */
2303*0Sstevel@tonic-gate 		if (pri->sys_nargs > 3) {
2304*0Sstevel@tonic-gate 			switch (pri->sys_args[2]) {
2305*0Sstevel@tonic-gate 			case IPC_STAT:
2306*0Sstevel@tonic-gate 				if (pri->Errno)
2307*0Sstevel@tonic-gate 					break;
2308*0Sstevel@tonic-gate 				/*FALLTHROUGH*/
2309*0Sstevel@tonic-gate 			case IPC_SET:
2310*0Sstevel@tonic-gate 				if (data_model == PR_MODEL_LP64)
2311*0Sstevel@tonic-gate 					show_msgctl(pri,
2312*0Sstevel@tonic-gate 						(long)pri->sys_args[3]);
2313*0Sstevel@tonic-gate 				else
2314*0Sstevel@tonic-gate 					show_msgctl32(pri,
2315*0Sstevel@tonic-gate 						(long)pri->sys_args[3]);
2316*0Sstevel@tonic-gate 				break;
2317*0Sstevel@tonic-gate 			case IPC_STAT64:
2318*0Sstevel@tonic-gate 				if (pri->Errno)
2319*0Sstevel@tonic-gate 					break;
2320*0Sstevel@tonic-gate 				/*FALLTHROUGH*/
2321*0Sstevel@tonic-gate 			case IPC_SET64:
2322*0Sstevel@tonic-gate 				show_msgctl64(pri, (long)pri->sys_args[3]);
2323*0Sstevel@tonic-gate 				break;
2324*0Sstevel@tonic-gate 			}
2325*0Sstevel@tonic-gate 		}
2326*0Sstevel@tonic-gate 		break;
2327*0Sstevel@tonic-gate 	case 2:			/* msgrcv() */
2328*0Sstevel@tonic-gate 		if (!pri->Errno && pri->sys_nargs > 2) {
2329*0Sstevel@tonic-gate 			if (data_model == PR_MODEL_LP64)
2330*0Sstevel@tonic-gate 				show_msgbuf(pri, pri->sys_args[2], msgsz);
2331*0Sstevel@tonic-gate 			else
2332*0Sstevel@tonic-gate 				show_msgbuf32(pri, pri->sys_args[2], msgsz);
2333*0Sstevel@tonic-gate 		}
2334*0Sstevel@tonic-gate 		break;
2335*0Sstevel@tonic-gate 	case 3:			/* msgsnd() */
2336*0Sstevel@tonic-gate 		if (pri->sys_nargs > 3) {
2337*0Sstevel@tonic-gate 			if (data_model == PR_MODEL_LP64)
2338*0Sstevel@tonic-gate 				show_msgbuf(pri, pri->sys_args[2],
2339*0Sstevel@tonic-gate 					pri->sys_args[3]);
2340*0Sstevel@tonic-gate 			else
2341*0Sstevel@tonic-gate 				show_msgbuf32(pri, pri->sys_args[2],
2342*0Sstevel@tonic-gate 					pri->sys_args[3]);
2343*0Sstevel@tonic-gate 		}
2344*0Sstevel@tonic-gate 		break;
2345*0Sstevel@tonic-gate 	case 4:			/* msgids() */
2346*0Sstevel@tonic-gate 	case 5:			/* msgsnap() */
2347*0Sstevel@tonic-gate 	default:		/* unexpected subcode */
2348*0Sstevel@tonic-gate 		break;
2349*0Sstevel@tonic-gate 	}
2350*0Sstevel@tonic-gate }
2351*0Sstevel@tonic-gate #else	/* _LP64 */
2352*0Sstevel@tonic-gate void
2353*0Sstevel@tonic-gate show_msgsys(private_t *pri, long msgsz)
2354*0Sstevel@tonic-gate {
2355*0Sstevel@tonic-gate 	switch (pri->sys_args[0]) {
2356*0Sstevel@tonic-gate 	case 0:			/* msgget() */
2357*0Sstevel@tonic-gate 		break;
2358*0Sstevel@tonic-gate 	case 1:			/* msgctl() */
2359*0Sstevel@tonic-gate 		if (pri->sys_nargs > 3) {
2360*0Sstevel@tonic-gate 			switch (pri->sys_args[2]) {
2361*0Sstevel@tonic-gate 			case IPC_STAT:
2362*0Sstevel@tonic-gate 				if (pri->Errno)
2363*0Sstevel@tonic-gate 					break;
2364*0Sstevel@tonic-gate 				/*FALLTHROUGH*/
2365*0Sstevel@tonic-gate 			case IPC_SET:
2366*0Sstevel@tonic-gate 				show_msgctl(pri, (long)pri->sys_args[3]);
2367*0Sstevel@tonic-gate 				break;
2368*0Sstevel@tonic-gate 			case IPC_STAT64:
2369*0Sstevel@tonic-gate 				if (pri->Errno)
2370*0Sstevel@tonic-gate 					break;
2371*0Sstevel@tonic-gate 				/*FALLTHROUGH*/
2372*0Sstevel@tonic-gate 			case IPC_SET64:
2373*0Sstevel@tonic-gate 				show_msgctl64(pri, (long)pri->sys_args[3]);
2374*0Sstevel@tonic-gate 				break;
2375*0Sstevel@tonic-gate 			}
2376*0Sstevel@tonic-gate 		}
2377*0Sstevel@tonic-gate 		break;
2378*0Sstevel@tonic-gate 	case 2:			/* msgrcv() */
2379*0Sstevel@tonic-gate 		if (!pri->Errno && pri->sys_nargs > 2)
2380*0Sstevel@tonic-gate 			show_msgbuf(pri, pri->sys_args[2], msgsz);
2381*0Sstevel@tonic-gate 		break;
2382*0Sstevel@tonic-gate 	case 3:			/* msgsnd() */
2383*0Sstevel@tonic-gate 		if (pri->sys_nargs > 3)
2384*0Sstevel@tonic-gate 			show_msgbuf(pri, pri->sys_args[2],
2385*0Sstevel@tonic-gate 				pri->sys_args[3]);
2386*0Sstevel@tonic-gate 		break;
2387*0Sstevel@tonic-gate 	case 4:			/* msgids() */
2388*0Sstevel@tonic-gate 	case 5:			/* msgsnap() */
2389*0Sstevel@tonic-gate 	default:		/* unexpected subcode */
2390*0Sstevel@tonic-gate 		break;
2391*0Sstevel@tonic-gate 	}
2392*0Sstevel@tonic-gate }
2393*0Sstevel@tonic-gate #endif	/* _LP64 */
2394*0Sstevel@tonic-gate 
2395*0Sstevel@tonic-gate static void
2396*0Sstevel@tonic-gate show_semctl64(private_t *pri, long offset)
2397*0Sstevel@tonic-gate {
2398*0Sstevel@tonic-gate 	struct semid_ds64 semds;
2399*0Sstevel@tonic-gate 
2400*0Sstevel@tonic-gate 	if (offset != NULL &&
2401*0Sstevel@tonic-gate 	    Pread(Proc, &semds, sizeof (semds), offset) == sizeof (semds)) {
2402*0Sstevel@tonic-gate 		show_perm64(pri, &semds.semx_perm);
2403*0Sstevel@tonic-gate 
2404*0Sstevel@tonic-gate 		(void) printf("%s\tnsems=%u\n", pri->pname, semds.semx_nsems);
2405*0Sstevel@tonic-gate 
2406*0Sstevel@tonic-gate 		prtime(pri, "    ot = ", (time_t)semds.semx_otime);
2407*0Sstevel@tonic-gate 		prtime(pri, "    ct = ", (time_t)semds.semx_ctime);
2408*0Sstevel@tonic-gate 	}
2409*0Sstevel@tonic-gate }
2410*0Sstevel@tonic-gate 
2411*0Sstevel@tonic-gate void
2412*0Sstevel@tonic-gate show_semctl(private_t *pri, long offset)
2413*0Sstevel@tonic-gate {
2414*0Sstevel@tonic-gate 	struct semid_ds semds;
2415*0Sstevel@tonic-gate 
2416*0Sstevel@tonic-gate 	if (offset != NULL &&
2417*0Sstevel@tonic-gate 	    Pread(Proc, &semds, sizeof (semds), offset) == sizeof (semds)) {
2418*0Sstevel@tonic-gate 		show_perm(pri, &semds.sem_perm);
2419*0Sstevel@tonic-gate 
2420*0Sstevel@tonic-gate 		(void) printf("%s\tnsems=%u\n",
2421*0Sstevel@tonic-gate 			pri->pname,
2422*0Sstevel@tonic-gate 			semds.sem_nsems);
2423*0Sstevel@tonic-gate 
2424*0Sstevel@tonic-gate 		prtime(pri, "    ot = ", semds.sem_otime);
2425*0Sstevel@tonic-gate 		prtime(pri, "    ct = ", semds.sem_ctime);
2426*0Sstevel@tonic-gate 	}
2427*0Sstevel@tonic-gate }
2428*0Sstevel@tonic-gate 
2429*0Sstevel@tonic-gate #ifdef _LP64
2430*0Sstevel@tonic-gate void
2431*0Sstevel@tonic-gate show_semctl32(private_t *pri, long offset)
2432*0Sstevel@tonic-gate {
2433*0Sstevel@tonic-gate 	struct semid_ds32 semds;
2434*0Sstevel@tonic-gate 
2435*0Sstevel@tonic-gate 	if (offset != NULL &&
2436*0Sstevel@tonic-gate 	    Pread(Proc, &semds, sizeof (semds), offset) == sizeof (semds)) {
2437*0Sstevel@tonic-gate 		show_perm32(pri, &semds.sem_perm);
2438*0Sstevel@tonic-gate 
2439*0Sstevel@tonic-gate 		(void) printf("%s\tnsems=%u\n",
2440*0Sstevel@tonic-gate 			pri->pname,
2441*0Sstevel@tonic-gate 			semds.sem_nsems);
2442*0Sstevel@tonic-gate 
2443*0Sstevel@tonic-gate 		prtime(pri, "    ot = ", semds.sem_otime);
2444*0Sstevel@tonic-gate 		prtime(pri, "    ct = ", semds.sem_ctime);
2445*0Sstevel@tonic-gate 	}
2446*0Sstevel@tonic-gate }
2447*0Sstevel@tonic-gate #endif	/* _LP64 */
2448*0Sstevel@tonic-gate 
2449*0Sstevel@tonic-gate void
2450*0Sstevel@tonic-gate show_semop(private_t *pri, long offset, long nsops, long timeout)
2451*0Sstevel@tonic-gate {
2452*0Sstevel@tonic-gate 	struct sembuf sembuf;
2453*0Sstevel@tonic-gate 	const char *str;
2454*0Sstevel@tonic-gate 
2455*0Sstevel@tonic-gate 	if (offset == NULL)
2456*0Sstevel@tonic-gate 		return;
2457*0Sstevel@tonic-gate 
2458*0Sstevel@tonic-gate 	if (nsops > 40)		/* let's not be ridiculous */
2459*0Sstevel@tonic-gate 		nsops = 40;
2460*0Sstevel@tonic-gate 
2461*0Sstevel@tonic-gate 	for (; nsops > 0 && !interrupt; --nsops, offset += sizeof (sembuf)) {
2462*0Sstevel@tonic-gate 		if (Pread(Proc, &sembuf, sizeof (sembuf), offset) !=
2463*0Sstevel@tonic-gate 		    sizeof (sembuf))
2464*0Sstevel@tonic-gate 			break;
2465*0Sstevel@tonic-gate 
2466*0Sstevel@tonic-gate 		(void) printf("%s\tsemnum=%-5u semop=%-5d semflg=",
2467*0Sstevel@tonic-gate 			pri->pname,
2468*0Sstevel@tonic-gate 			sembuf.sem_num,
2469*0Sstevel@tonic-gate 			sembuf.sem_op);
2470*0Sstevel@tonic-gate 
2471*0Sstevel@tonic-gate 		if (sembuf.sem_flg == 0)
2472*0Sstevel@tonic-gate 			(void) printf("0\n");
2473*0Sstevel@tonic-gate 		else if ((str = semflags(pri, sembuf.sem_flg)) != NULL)
2474*0Sstevel@tonic-gate 			(void) printf("%s\n", str);
2475*0Sstevel@tonic-gate 		else
2476*0Sstevel@tonic-gate 			(void) printf("0%.6o\n", sembuf.sem_flg);
2477*0Sstevel@tonic-gate 	}
2478*0Sstevel@tonic-gate 	if (timeout)
2479*0Sstevel@tonic-gate 		show_timestruc(pri, timeout, "timeout");
2480*0Sstevel@tonic-gate }
2481*0Sstevel@tonic-gate 
2482*0Sstevel@tonic-gate void
2483*0Sstevel@tonic-gate show_semsys(private_t *pri)
2484*0Sstevel@tonic-gate {
2485*0Sstevel@tonic-gate 	switch (pri->sys_args[0]) {
2486*0Sstevel@tonic-gate 	case 0:			/* semctl() */
2487*0Sstevel@tonic-gate 		if (pri->sys_nargs > 4) {
2488*0Sstevel@tonic-gate 			switch (pri->sys_args[3]) {
2489*0Sstevel@tonic-gate 			case IPC_STAT:
2490*0Sstevel@tonic-gate 				if (pri->Errno)
2491*0Sstevel@tonic-gate 					break;
2492*0Sstevel@tonic-gate 				/*FALLTHROUGH*/
2493*0Sstevel@tonic-gate 			case IPC_SET:
2494*0Sstevel@tonic-gate #ifdef _LP64
2495*0Sstevel@tonic-gate 				if (data_model == PR_MODEL_LP64)
2496*0Sstevel@tonic-gate 					show_semctl(pri,
2497*0Sstevel@tonic-gate 						(long)pri->sys_args[4]);
2498*0Sstevel@tonic-gate 				else
2499*0Sstevel@tonic-gate 					show_semctl32(pri,
2500*0Sstevel@tonic-gate 						(long)pri->sys_args[4]);
2501*0Sstevel@tonic-gate #else
2502*0Sstevel@tonic-gate 				show_semctl(pri, (long)pri->sys_args[4]);
2503*0Sstevel@tonic-gate #endif
2504*0Sstevel@tonic-gate 				break;
2505*0Sstevel@tonic-gate 			case IPC_STAT64:
2506*0Sstevel@tonic-gate 				if (pri->Errno)
2507*0Sstevel@tonic-gate 					break;
2508*0Sstevel@tonic-gate 				/*FALLTHROUGH*/
2509*0Sstevel@tonic-gate 			case IPC_SET64:
2510*0Sstevel@tonic-gate 				show_semctl64(pri, (long)pri->sys_args[4]);
2511*0Sstevel@tonic-gate 				break;
2512*0Sstevel@tonic-gate 			}
2513*0Sstevel@tonic-gate 		}
2514*0Sstevel@tonic-gate 		break;
2515*0Sstevel@tonic-gate 	case 1:			/* semget() */
2516*0Sstevel@tonic-gate 		break;
2517*0Sstevel@tonic-gate 	case 2:			/* semop() */
2518*0Sstevel@tonic-gate 		if (pri->sys_nargs > 3)
2519*0Sstevel@tonic-gate 			show_semop(pri, (long)pri->sys_args[2],
2520*0Sstevel@tonic-gate 				pri->sys_args[3], 0);
2521*0Sstevel@tonic-gate 		break;
2522*0Sstevel@tonic-gate 	case 3:			/* semids() */
2523*0Sstevel@tonic-gate 		break;
2524*0Sstevel@tonic-gate 	case 4:			/* semtimedop() */
2525*0Sstevel@tonic-gate 		if (pri->sys_nargs > 4)
2526*0Sstevel@tonic-gate 			show_semop(pri, (long)pri->sys_args[2],
2527*0Sstevel@tonic-gate 				pri->sys_args[3], pri->sys_args[4]);
2528*0Sstevel@tonic-gate 		break;
2529*0Sstevel@tonic-gate 	default:		/* unexpected subcode */
2530*0Sstevel@tonic-gate 		break;
2531*0Sstevel@tonic-gate 	}
2532*0Sstevel@tonic-gate }
2533*0Sstevel@tonic-gate 
2534*0Sstevel@tonic-gate static void
2535*0Sstevel@tonic-gate show_shmctl64(private_t *pri, long offset)
2536*0Sstevel@tonic-gate {
2537*0Sstevel@tonic-gate 	struct shmid_ds64 shmds;
2538*0Sstevel@tonic-gate 
2539*0Sstevel@tonic-gate 	if (offset != NULL &&
2540*0Sstevel@tonic-gate 	    Pread(Proc, &shmds, sizeof (shmds), offset) == sizeof (shmds)) {
2541*0Sstevel@tonic-gate 		show_perm64(pri, &shmds.shmx_perm);
2542*0Sstevel@tonic-gate 
2543*0Sstevel@tonic-gate 		(void) printf(
2544*0Sstevel@tonic-gate 		    "%s\tsize=%-6llu lpid=%-5d cpid=%-5d na=%-5llu cna=%llu\n",
2545*0Sstevel@tonic-gate 		    pri->pname,
2546*0Sstevel@tonic-gate 		    (unsigned long long)shmds.shmx_segsz,
2547*0Sstevel@tonic-gate 		    (int)shmds.shmx_lpid,
2548*0Sstevel@tonic-gate 		    (int)shmds.shmx_cpid,
2549*0Sstevel@tonic-gate 		    (unsigned long long)shmds.shmx_nattch,
2550*0Sstevel@tonic-gate 		    (unsigned long long)shmds.shmx_cnattch);
2551*0Sstevel@tonic-gate 
2552*0Sstevel@tonic-gate 		prtime(pri, "    at = ", (time_t)shmds.shmx_atime);
2553*0Sstevel@tonic-gate 		prtime(pri, "    dt = ", (time_t)shmds.shmx_dtime);
2554*0Sstevel@tonic-gate 		prtime(pri, "    ct = ", (time_t)shmds.shmx_ctime);
2555*0Sstevel@tonic-gate 	}
2556*0Sstevel@tonic-gate }
2557*0Sstevel@tonic-gate 
2558*0Sstevel@tonic-gate void
2559*0Sstevel@tonic-gate show_shmctl(private_t *pri, long offset)
2560*0Sstevel@tonic-gate {
2561*0Sstevel@tonic-gate 	struct shmid_ds shmds;
2562*0Sstevel@tonic-gate 
2563*0Sstevel@tonic-gate 	if (offset != NULL &&
2564*0Sstevel@tonic-gate 	    Pread(Proc, &shmds, sizeof (shmds), offset) == sizeof (shmds)) {
2565*0Sstevel@tonic-gate 		show_perm(pri, &shmds.shm_perm);
2566*0Sstevel@tonic-gate 
2567*0Sstevel@tonic-gate 		(void) printf(
2568*0Sstevel@tonic-gate 		"%s\tsize=%-6lu lpid=%-5u cpid=%-5u na=%-5lu cna=%lu\n",
2569*0Sstevel@tonic-gate 			pri->pname,
2570*0Sstevel@tonic-gate 			(ulong_t)shmds.shm_segsz,
2571*0Sstevel@tonic-gate 			(int)shmds.shm_lpid,
2572*0Sstevel@tonic-gate 			(int)shmds.shm_cpid,
2573*0Sstevel@tonic-gate 			shmds.shm_nattch,
2574*0Sstevel@tonic-gate 			shmds.shm_cnattch);
2575*0Sstevel@tonic-gate 
2576*0Sstevel@tonic-gate 		prtime(pri, "    at = ", shmds.shm_atime);
2577*0Sstevel@tonic-gate 		prtime(pri, "    dt = ", shmds.shm_dtime);
2578*0Sstevel@tonic-gate 		prtime(pri, "    ct = ", shmds.shm_ctime);
2579*0Sstevel@tonic-gate 	}
2580*0Sstevel@tonic-gate }
2581*0Sstevel@tonic-gate 
2582*0Sstevel@tonic-gate #ifdef _LP64
2583*0Sstevel@tonic-gate void
2584*0Sstevel@tonic-gate show_shmctl32(private_t *pri, long offset)
2585*0Sstevel@tonic-gate {
2586*0Sstevel@tonic-gate 	struct shmid_ds32 shmds;
2587*0Sstevel@tonic-gate 
2588*0Sstevel@tonic-gate 	if (offset != NULL &&
2589*0Sstevel@tonic-gate 	    Pread(Proc, &shmds, sizeof (shmds), offset) == sizeof (shmds)) {
2590*0Sstevel@tonic-gate 		show_perm32(pri, &shmds.shm_perm);
2591*0Sstevel@tonic-gate 
2592*0Sstevel@tonic-gate 		(void) printf(
2593*0Sstevel@tonic-gate 		"%s\tsize=%-6u lpid=%-5u cpid=%-5u na=%-5u cna=%u\n",
2594*0Sstevel@tonic-gate 			pri->pname,
2595*0Sstevel@tonic-gate 			shmds.shm_segsz,
2596*0Sstevel@tonic-gate 			shmds.shm_lpid,
2597*0Sstevel@tonic-gate 			shmds.shm_cpid,
2598*0Sstevel@tonic-gate 			shmds.shm_nattch,
2599*0Sstevel@tonic-gate 			shmds.shm_cnattch);
2600*0Sstevel@tonic-gate 
2601*0Sstevel@tonic-gate 		prtime(pri, "    at = ", shmds.shm_atime);
2602*0Sstevel@tonic-gate 		prtime(pri, "    dt = ", shmds.shm_dtime);
2603*0Sstevel@tonic-gate 		prtime(pri, "    ct = ", shmds.shm_ctime);
2604*0Sstevel@tonic-gate 	}
2605*0Sstevel@tonic-gate }
2606*0Sstevel@tonic-gate #endif	/* _LP64 */
2607*0Sstevel@tonic-gate 
2608*0Sstevel@tonic-gate void
2609*0Sstevel@tonic-gate show_shmsys(private_t *pri)
2610*0Sstevel@tonic-gate {
2611*0Sstevel@tonic-gate 	switch (pri->sys_args[0]) {
2612*0Sstevel@tonic-gate 	case 0:			/* shmat() */
2613*0Sstevel@tonic-gate 		break;
2614*0Sstevel@tonic-gate 	case 1:			/* shmctl() */
2615*0Sstevel@tonic-gate 		if (pri->sys_nargs > 3) {
2616*0Sstevel@tonic-gate 			switch (pri->sys_args[2]) {
2617*0Sstevel@tonic-gate 			case IPC_STAT:
2618*0Sstevel@tonic-gate 				if (pri->Errno)
2619*0Sstevel@tonic-gate 					break;
2620*0Sstevel@tonic-gate 				/*FALLTHROUGH*/
2621*0Sstevel@tonic-gate 			case IPC_SET:
2622*0Sstevel@tonic-gate #ifdef _LP64
2623*0Sstevel@tonic-gate 				if (data_model == PR_MODEL_LP64)
2624*0Sstevel@tonic-gate 					show_shmctl(pri,
2625*0Sstevel@tonic-gate 						(long)pri->sys_args[3]);
2626*0Sstevel@tonic-gate 				else
2627*0Sstevel@tonic-gate 					show_shmctl32(pri,
2628*0Sstevel@tonic-gate 						(long)pri->sys_args[3]);
2629*0Sstevel@tonic-gate #else
2630*0Sstevel@tonic-gate 				show_shmctl(pri, (long)pri->sys_args[3]);
2631*0Sstevel@tonic-gate #endif
2632*0Sstevel@tonic-gate 				break;
2633*0Sstevel@tonic-gate 			case IPC_STAT64:
2634*0Sstevel@tonic-gate 				if (pri->Errno)
2635*0Sstevel@tonic-gate 					break;
2636*0Sstevel@tonic-gate 				/*FALLTHROUGH*/
2637*0Sstevel@tonic-gate 			case IPC_SET64:
2638*0Sstevel@tonic-gate 				show_shmctl64(pri, (long)pri->sys_args[3]);
2639*0Sstevel@tonic-gate 				break;
2640*0Sstevel@tonic-gate 			}
2641*0Sstevel@tonic-gate 		}
2642*0Sstevel@tonic-gate 		break;
2643*0Sstevel@tonic-gate 	case 2:			/* shmdt() */
2644*0Sstevel@tonic-gate 	case 3:			/* shmget() */
2645*0Sstevel@tonic-gate 	case 4:			/* shmids() */
2646*0Sstevel@tonic-gate 	default:		/* unexpected subcode */
2647*0Sstevel@tonic-gate 		break;
2648*0Sstevel@tonic-gate 	}
2649*0Sstevel@tonic-gate }
2650*0Sstevel@tonic-gate 
2651*0Sstevel@tonic-gate void
2652*0Sstevel@tonic-gate show_groups(private_t *pri, long offset, long count)
2653*0Sstevel@tonic-gate {
2654*0Sstevel@tonic-gate 	int groups[100];
2655*0Sstevel@tonic-gate 
2656*0Sstevel@tonic-gate 	if (count > 100)
2657*0Sstevel@tonic-gate 		count = 100;
2658*0Sstevel@tonic-gate 
2659*0Sstevel@tonic-gate 	if (count > 0 && offset != NULL &&
2660*0Sstevel@tonic-gate 	    Pread(Proc, &groups[0], count*sizeof (int), offset) ==
2661*0Sstevel@tonic-gate 	    count*sizeof (int)) {
2662*0Sstevel@tonic-gate 		int n;
2663*0Sstevel@tonic-gate 
2664*0Sstevel@tonic-gate 		(void) printf("%s\t", pri->pname);
2665*0Sstevel@tonic-gate 		for (n = 0; !interrupt && n < count; n++) {
2666*0Sstevel@tonic-gate 			if (n != 0 && n%10 == 0)
2667*0Sstevel@tonic-gate 				(void) printf("\n%s\t", pri->pname);
2668*0Sstevel@tonic-gate 			(void) printf(" %5d", groups[n]);
2669*0Sstevel@tonic-gate 		}
2670*0Sstevel@tonic-gate 		(void) fputc('\n', stdout);
2671*0Sstevel@tonic-gate 	}
2672*0Sstevel@tonic-gate }
2673*0Sstevel@tonic-gate 
2674*0Sstevel@tonic-gate /*
2675*0Sstevel@tonic-gate  * This assumes that a sigset_t is simply an array of ints.
2676*0Sstevel@tonic-gate  */
2677*0Sstevel@tonic-gate char *
2678*0Sstevel@tonic-gate sigset_string(private_t *pri, sigset_t *sp)
2679*0Sstevel@tonic-gate {
2680*0Sstevel@tonic-gate 	char *s = pri->code_buf;
2681*0Sstevel@tonic-gate 	int n = sizeof (*sp) / sizeof (int32_t);
2682*0Sstevel@tonic-gate 	int32_t *lp = (int32_t *)sp;
2683*0Sstevel@tonic-gate 
2684*0Sstevel@tonic-gate 	while (--n >= 0) {
2685*0Sstevel@tonic-gate 		int32_t val = *lp++;
2686*0Sstevel@tonic-gate 
2687*0Sstevel@tonic-gate 		if (val == 0)
2688*0Sstevel@tonic-gate 			s += sprintf(s, " 0");
2689*0Sstevel@tonic-gate 		else
2690*0Sstevel@tonic-gate 			s += sprintf(s, " 0x%.8X", val);
2691*0Sstevel@tonic-gate 	}
2692*0Sstevel@tonic-gate 
2693*0Sstevel@tonic-gate 	return (pri->code_buf);
2694*0Sstevel@tonic-gate }
2695*0Sstevel@tonic-gate 
2696*0Sstevel@tonic-gate void
2697*0Sstevel@tonic-gate show_sigset(private_t *pri, long offset, const char *name)
2698*0Sstevel@tonic-gate {
2699*0Sstevel@tonic-gate 	sigset_t sigset;
2700*0Sstevel@tonic-gate 
2701*0Sstevel@tonic-gate 	if (offset != NULL &&
2702*0Sstevel@tonic-gate 	    Pread(Proc, &sigset, sizeof (sigset), offset) == sizeof (sigset)) {
2703*0Sstevel@tonic-gate 		(void) printf("%s\t%s =%s\n",
2704*0Sstevel@tonic-gate 			pri->pname, name, sigset_string(pri, &sigset));
2705*0Sstevel@tonic-gate 	}
2706*0Sstevel@tonic-gate }
2707*0Sstevel@tonic-gate 
2708*0Sstevel@tonic-gate #ifdef _LP64
2709*0Sstevel@tonic-gate void
2710*0Sstevel@tonic-gate show_sigaltstack32(private_t *pri, long offset, const char *name)
2711*0Sstevel@tonic-gate {
2712*0Sstevel@tonic-gate 	struct sigaltstack32 altstack;
2713*0Sstevel@tonic-gate 
2714*0Sstevel@tonic-gate 	if (offset != NULL &&
2715*0Sstevel@tonic-gate 	    Pread(Proc, &altstack, sizeof (altstack), offset) ==
2716*0Sstevel@tonic-gate 	    sizeof (altstack)) {
2717*0Sstevel@tonic-gate 		(void) printf("%s\t%s: sp=0x%.8X size=%u flags=0x%.4X\n",
2718*0Sstevel@tonic-gate 			pri->pname,
2719*0Sstevel@tonic-gate 			name,
2720*0Sstevel@tonic-gate 			altstack.ss_sp,
2721*0Sstevel@tonic-gate 			altstack.ss_size,
2722*0Sstevel@tonic-gate 			altstack.ss_flags);
2723*0Sstevel@tonic-gate 	}
2724*0Sstevel@tonic-gate }
2725*0Sstevel@tonic-gate #endif	/* _LP64 */
2726*0Sstevel@tonic-gate 
2727*0Sstevel@tonic-gate void
2728*0Sstevel@tonic-gate show_sigaltstack(private_t *pri, long offset, const char *name)
2729*0Sstevel@tonic-gate {
2730*0Sstevel@tonic-gate 	struct sigaltstack altstack;
2731*0Sstevel@tonic-gate 
2732*0Sstevel@tonic-gate #ifdef _LP64
2733*0Sstevel@tonic-gate 	if (data_model != PR_MODEL_LP64) {
2734*0Sstevel@tonic-gate 		show_sigaltstack32(pri, offset, name);
2735*0Sstevel@tonic-gate 		return;
2736*0Sstevel@tonic-gate 	}
2737*0Sstevel@tonic-gate #endif
2738*0Sstevel@tonic-gate 	if (offset != NULL &&
2739*0Sstevel@tonic-gate 	    Pread(Proc, &altstack, sizeof (altstack), offset) ==
2740*0Sstevel@tonic-gate 	    sizeof (altstack)) {
2741*0Sstevel@tonic-gate 		(void) printf("%s\t%s: sp=0x%.8lX size=%lu flags=0x%.4X\n",
2742*0Sstevel@tonic-gate 			pri->pname,
2743*0Sstevel@tonic-gate 			name,
2744*0Sstevel@tonic-gate 			(ulong_t)altstack.ss_sp,
2745*0Sstevel@tonic-gate 			(ulong_t)altstack.ss_size,
2746*0Sstevel@tonic-gate 			altstack.ss_flags);
2747*0Sstevel@tonic-gate 	}
2748*0Sstevel@tonic-gate }
2749*0Sstevel@tonic-gate 
2750*0Sstevel@tonic-gate #ifdef _LP64
2751*0Sstevel@tonic-gate void
2752*0Sstevel@tonic-gate show_sigaction32(private_t *pri, long offset, const char *name, long odisp)
2753*0Sstevel@tonic-gate {
2754*0Sstevel@tonic-gate 	struct sigaction32 sigaction;
2755*0Sstevel@tonic-gate 
2756*0Sstevel@tonic-gate 	if (offset != NULL &&
2757*0Sstevel@tonic-gate 	    Pread(Proc, &sigaction, sizeof (sigaction), offset) ==
2758*0Sstevel@tonic-gate 	    sizeof (sigaction)) {
2759*0Sstevel@tonic-gate 		/* This is stupid, we shouldn't have to do this */
2760*0Sstevel@tonic-gate 		if (odisp != NULL)
2761*0Sstevel@tonic-gate 			sigaction.sa_handler = (caddr32_t)odisp;
2762*0Sstevel@tonic-gate 		(void) printf(
2763*0Sstevel@tonic-gate 			"%s    %s: hand = 0x%.8X mask =%s flags = 0x%.4X\n",
2764*0Sstevel@tonic-gate 			pri->pname,
2765*0Sstevel@tonic-gate 			name,
2766*0Sstevel@tonic-gate 			sigaction.sa_handler,
2767*0Sstevel@tonic-gate 			sigset_string(pri, (sigset_t *)&sigaction.sa_mask),
2768*0Sstevel@tonic-gate 			sigaction.sa_flags);
2769*0Sstevel@tonic-gate 	}
2770*0Sstevel@tonic-gate }
2771*0Sstevel@tonic-gate #endif	/* _LP64 */
2772*0Sstevel@tonic-gate 
2773*0Sstevel@tonic-gate void
2774*0Sstevel@tonic-gate show_sigaction(private_t *pri, long offset, const char *name, long odisp)
2775*0Sstevel@tonic-gate {
2776*0Sstevel@tonic-gate 	struct sigaction sigaction;
2777*0Sstevel@tonic-gate 
2778*0Sstevel@tonic-gate #ifdef _LP64
2779*0Sstevel@tonic-gate 	if (data_model != PR_MODEL_LP64) {
2780*0Sstevel@tonic-gate 		show_sigaction32(pri, offset, name, odisp);
2781*0Sstevel@tonic-gate 		return;
2782*0Sstevel@tonic-gate 	}
2783*0Sstevel@tonic-gate #endif
2784*0Sstevel@tonic-gate 	if (offset != NULL &&
2785*0Sstevel@tonic-gate 	    Pread(Proc, &sigaction, sizeof (sigaction), offset) ==
2786*0Sstevel@tonic-gate 	    sizeof (sigaction)) {
2787*0Sstevel@tonic-gate 		/* This is stupid, we shouldn't have to do this */
2788*0Sstevel@tonic-gate 		if (odisp != NULL)
2789*0Sstevel@tonic-gate 			sigaction.sa_handler = (void (*)())odisp;
2790*0Sstevel@tonic-gate 		(void) printf(
2791*0Sstevel@tonic-gate 			"%s    %s: hand = 0x%.8lX mask =%s flags = 0x%.4X\n",
2792*0Sstevel@tonic-gate 			pri->pname,
2793*0Sstevel@tonic-gate 			name,
2794*0Sstevel@tonic-gate 			(long)sigaction.sa_handler,
2795*0Sstevel@tonic-gate 			sigset_string(pri, &sigaction.sa_mask),
2796*0Sstevel@tonic-gate 			sigaction.sa_flags);
2797*0Sstevel@tonic-gate 	}
2798*0Sstevel@tonic-gate }
2799*0Sstevel@tonic-gate 
2800*0Sstevel@tonic-gate #ifdef _LP64
2801*0Sstevel@tonic-gate void
2802*0Sstevel@tonic-gate print_siginfo32(private_t *pri, const siginfo32_t *sip)
2803*0Sstevel@tonic-gate {
2804*0Sstevel@tonic-gate 	const char *code = NULL;
2805*0Sstevel@tonic-gate 
2806*0Sstevel@tonic-gate 	(void) printf("%s      siginfo: %s", pri->pname,
2807*0Sstevel@tonic-gate 		signame(pri, sip->si_signo));
2808*0Sstevel@tonic-gate 
2809*0Sstevel@tonic-gate 	if (sip->si_signo != 0 && SI_FROMUSER(sip) && sip->si_pid != 0) {
2810*0Sstevel@tonic-gate 		(void) printf(" pid=%d uid=%d", sip->si_pid, sip->si_uid);
2811*0Sstevel@tonic-gate 		if (sip->si_code != 0)
2812*0Sstevel@tonic-gate 			(void) printf(" code=%d", sip->si_code);
2813*0Sstevel@tonic-gate 		(void) fputc('\n', stdout);
2814*0Sstevel@tonic-gate 		return;
2815*0Sstevel@tonic-gate 	}
2816*0Sstevel@tonic-gate 
2817*0Sstevel@tonic-gate 	switch (sip->si_signo) {
2818*0Sstevel@tonic-gate 	default:
2819*0Sstevel@tonic-gate 		(void) fputc('\n', stdout);
2820*0Sstevel@tonic-gate 		return;
2821*0Sstevel@tonic-gate 	case SIGILL:
2822*0Sstevel@tonic-gate 	case SIGTRAP:
2823*0Sstevel@tonic-gate 	case SIGFPE:
2824*0Sstevel@tonic-gate 	case SIGSEGV:
2825*0Sstevel@tonic-gate 	case SIGBUS:
2826*0Sstevel@tonic-gate 	case SIGEMT:
2827*0Sstevel@tonic-gate 	case SIGCLD:
2828*0Sstevel@tonic-gate 	case SIGPOLL:
2829*0Sstevel@tonic-gate 	case SIGXFSZ:
2830*0Sstevel@tonic-gate 		break;
2831*0Sstevel@tonic-gate 	}
2832*0Sstevel@tonic-gate 
2833*0Sstevel@tonic-gate 	switch (sip->si_signo) {
2834*0Sstevel@tonic-gate 	case SIGILL:
2835*0Sstevel@tonic-gate 		switch (sip->si_code) {
2836*0Sstevel@tonic-gate 		case ILL_ILLOPC:	code = "ILL_ILLOPC";	break;
2837*0Sstevel@tonic-gate 		case ILL_ILLOPN:	code = "ILL_ILLOPN";	break;
2838*0Sstevel@tonic-gate 		case ILL_ILLADR:	code = "ILL_ILLADR";	break;
2839*0Sstevel@tonic-gate 		case ILL_ILLTRP:	code = "ILL_ILLTRP";	break;
2840*0Sstevel@tonic-gate 		case ILL_PRVOPC:	code = "ILL_PRVOPC";	break;
2841*0Sstevel@tonic-gate 		case ILL_PRVREG:	code = "ILL_PRVREG";	break;
2842*0Sstevel@tonic-gate 		case ILL_COPROC:	code = "ILL_COPROC";	break;
2843*0Sstevel@tonic-gate 		case ILL_BADSTK:	code = "ILL_BADSTK";	break;
2844*0Sstevel@tonic-gate 		}
2845*0Sstevel@tonic-gate 		break;
2846*0Sstevel@tonic-gate 	case SIGTRAP:
2847*0Sstevel@tonic-gate 		switch (sip->si_code) {
2848*0Sstevel@tonic-gate 		case TRAP_BRKPT:	code = "TRAP_BRKPT";	break;
2849*0Sstevel@tonic-gate 		case TRAP_TRACE:	code = "TRAP_TRACE";	break;
2850*0Sstevel@tonic-gate 		case TRAP_RWATCH:	code = "TRAP_RWATCH";	break;
2851*0Sstevel@tonic-gate 		case TRAP_WWATCH:	code = "TRAP_WWATCH";	break;
2852*0Sstevel@tonic-gate 		case TRAP_XWATCH:	code = "TRAP_XWATCH";	break;
2853*0Sstevel@tonic-gate 		case TRAP_DTRACE:	code = "TRAP_DTRACE";	break;
2854*0Sstevel@tonic-gate 		}
2855*0Sstevel@tonic-gate 		break;
2856*0Sstevel@tonic-gate 	case SIGFPE:
2857*0Sstevel@tonic-gate 		switch (sip->si_code) {
2858*0Sstevel@tonic-gate 		case FPE_INTDIV:	code = "FPE_INTDIV";	break;
2859*0Sstevel@tonic-gate 		case FPE_INTOVF:	code = "FPE_INTOVF";	break;
2860*0Sstevel@tonic-gate 		case FPE_FLTDIV:	code = "FPE_FLTDIV";	break;
2861*0Sstevel@tonic-gate 		case FPE_FLTOVF:	code = "FPE_FLTOVF";	break;
2862*0Sstevel@tonic-gate 		case FPE_FLTUND:	code = "FPE_FLTUND";	break;
2863*0Sstevel@tonic-gate 		case FPE_FLTRES:	code = "FPE_FLTRES";	break;
2864*0Sstevel@tonic-gate 		case FPE_FLTINV:	code = "FPE_FLTINV";	break;
2865*0Sstevel@tonic-gate 		case FPE_FLTSUB:	code = "FPE_FLTSUB";	break;
2866*0Sstevel@tonic-gate #if defined(FPE_FLTDEN)
2867*0Sstevel@tonic-gate 		case FPE_FLTDEN:	code = "FPE_FLTDEN";	break;
2868*0Sstevel@tonic-gate #endif
2869*0Sstevel@tonic-gate 		}
2870*0Sstevel@tonic-gate 		break;
2871*0Sstevel@tonic-gate 	case SIGSEGV:
2872*0Sstevel@tonic-gate 		switch (sip->si_code) {
2873*0Sstevel@tonic-gate 		case SEGV_MAPERR:	code = "SEGV_MAPERR";	break;
2874*0Sstevel@tonic-gate 		case SEGV_ACCERR:	code = "SEGV_ACCERR";	break;
2875*0Sstevel@tonic-gate 		}
2876*0Sstevel@tonic-gate 		break;
2877*0Sstevel@tonic-gate 	case SIGEMT:
2878*0Sstevel@tonic-gate 		switch (sip->si_code) {
2879*0Sstevel@tonic-gate #ifdef EMT_TAGOVF
2880*0Sstevel@tonic-gate 		case EMT_TAGOVF:	code = "EMT_TAGOVF";	break;
2881*0Sstevel@tonic-gate #endif
2882*0Sstevel@tonic-gate 		case EMT_CPCOVF:	code = "EMT_CPCOVF";	break;
2883*0Sstevel@tonic-gate 		}
2884*0Sstevel@tonic-gate 		break;
2885*0Sstevel@tonic-gate 	case SIGBUS:
2886*0Sstevel@tonic-gate 		switch (sip->si_code) {
2887*0Sstevel@tonic-gate 		case BUS_ADRALN:	code = "BUS_ADRALN";	break;
2888*0Sstevel@tonic-gate 		case BUS_ADRERR:	code = "BUS_ADRERR";	break;
2889*0Sstevel@tonic-gate 		case BUS_OBJERR:	code = "BUS_OBJERR";	break;
2890*0Sstevel@tonic-gate 		}
2891*0Sstevel@tonic-gate 		break;
2892*0Sstevel@tonic-gate 	case SIGCLD:
2893*0Sstevel@tonic-gate 		switch (sip->si_code) {
2894*0Sstevel@tonic-gate 		case CLD_EXITED:	code = "CLD_EXITED";	break;
2895*0Sstevel@tonic-gate 		case CLD_KILLED:	code = "CLD_KILLED";	break;
2896*0Sstevel@tonic-gate 		case CLD_DUMPED:	code = "CLD_DUMPED";	break;
2897*0Sstevel@tonic-gate 		case CLD_TRAPPED:	code = "CLD_TRAPPED";	break;
2898*0Sstevel@tonic-gate 		case CLD_STOPPED:	code = "CLD_STOPPED";	break;
2899*0Sstevel@tonic-gate 		case CLD_CONTINUED:	code = "CLD_CONTINUED";	break;
2900*0Sstevel@tonic-gate 		}
2901*0Sstevel@tonic-gate 		break;
2902*0Sstevel@tonic-gate 	case SIGPOLL:
2903*0Sstevel@tonic-gate 		switch (sip->si_code) {
2904*0Sstevel@tonic-gate 		case POLL_IN:		code = "POLL_IN";	break;
2905*0Sstevel@tonic-gate 		case POLL_OUT:		code = "POLL_OUT";	break;
2906*0Sstevel@tonic-gate 		case POLL_MSG:		code = "POLL_MSG";	break;
2907*0Sstevel@tonic-gate 		case POLL_ERR:		code = "POLL_ERR";	break;
2908*0Sstevel@tonic-gate 		case POLL_PRI:		code = "POLL_PRI";	break;
2909*0Sstevel@tonic-gate 		case POLL_HUP:		code = "POLL_HUP";	break;
2910*0Sstevel@tonic-gate 		}
2911*0Sstevel@tonic-gate 		break;
2912*0Sstevel@tonic-gate 	}
2913*0Sstevel@tonic-gate 
2914*0Sstevel@tonic-gate 	if (code == NULL) {
2915*0Sstevel@tonic-gate 		(void) sprintf(pri->code_buf, "code=%d", sip->si_code);
2916*0Sstevel@tonic-gate 		code = (const char *)pri->code_buf;
2917*0Sstevel@tonic-gate 	}
2918*0Sstevel@tonic-gate 
2919*0Sstevel@tonic-gate 	switch (sip->si_signo) {
2920*0Sstevel@tonic-gate 	case SIGILL:
2921*0Sstevel@tonic-gate 	case SIGTRAP:
2922*0Sstevel@tonic-gate 	case SIGFPE:
2923*0Sstevel@tonic-gate 	case SIGSEGV:
2924*0Sstevel@tonic-gate 	case SIGBUS:
2925*0Sstevel@tonic-gate 	case SIGEMT:
2926*0Sstevel@tonic-gate 		(void) printf(" %s addr=0x%.8X",
2927*0Sstevel@tonic-gate 			code,
2928*0Sstevel@tonic-gate 			sip->si_addr);
2929*0Sstevel@tonic-gate 		break;
2930*0Sstevel@tonic-gate 	case SIGCLD:
2931*0Sstevel@tonic-gate 		(void) printf(" %s pid=%d status=0x%.4X",
2932*0Sstevel@tonic-gate 			code,
2933*0Sstevel@tonic-gate 			sip->si_pid,
2934*0Sstevel@tonic-gate 			sip->si_status);
2935*0Sstevel@tonic-gate 		break;
2936*0Sstevel@tonic-gate 	case SIGPOLL:
2937*0Sstevel@tonic-gate 	case SIGXFSZ:
2938*0Sstevel@tonic-gate 		(void) printf(" %s fd=%d band=%d",
2939*0Sstevel@tonic-gate 			code,
2940*0Sstevel@tonic-gate 			sip->si_fd,
2941*0Sstevel@tonic-gate 			sip->si_band);
2942*0Sstevel@tonic-gate 		break;
2943*0Sstevel@tonic-gate 	}
2944*0Sstevel@tonic-gate 
2945*0Sstevel@tonic-gate 	if (sip->si_errno != 0) {
2946*0Sstevel@tonic-gate 		const char *ename = errname(sip->si_errno);
2947*0Sstevel@tonic-gate 
2948*0Sstevel@tonic-gate 		(void) printf(" errno=%d", sip->si_errno);
2949*0Sstevel@tonic-gate 		if (ename != NULL)
2950*0Sstevel@tonic-gate 			(void) printf("(%s)", ename);
2951*0Sstevel@tonic-gate 	}
2952*0Sstevel@tonic-gate 
2953*0Sstevel@tonic-gate 	(void) fputc('\n', stdout);
2954*0Sstevel@tonic-gate }
2955*0Sstevel@tonic-gate #endif	/* _LP64 */
2956*0Sstevel@tonic-gate 
2957*0Sstevel@tonic-gate void
2958*0Sstevel@tonic-gate print_siginfo(private_t *pri, const siginfo_t *sip)
2959*0Sstevel@tonic-gate {
2960*0Sstevel@tonic-gate 	const char *code = NULL;
2961*0Sstevel@tonic-gate 
2962*0Sstevel@tonic-gate 	(void) printf("%s      siginfo: %s", pri->pname,
2963*0Sstevel@tonic-gate 		signame(pri, sip->si_signo));
2964*0Sstevel@tonic-gate 
2965*0Sstevel@tonic-gate 	if (sip->si_signo != 0 && SI_FROMUSER(sip) && sip->si_pid != 0) {
2966*0Sstevel@tonic-gate 		(void) printf(" pid=%d uid=%d",
2967*0Sstevel@tonic-gate 		    (int)sip->si_pid,
2968*0Sstevel@tonic-gate 		    (int)sip->si_uid);
2969*0Sstevel@tonic-gate 		if (sip->si_code != 0)
2970*0Sstevel@tonic-gate 			(void) printf(" code=%d", sip->si_code);
2971*0Sstevel@tonic-gate 		(void) fputc('\n', stdout);
2972*0Sstevel@tonic-gate 		return;
2973*0Sstevel@tonic-gate 	}
2974*0Sstevel@tonic-gate 
2975*0Sstevel@tonic-gate 	switch (sip->si_signo) {
2976*0Sstevel@tonic-gate 	default:
2977*0Sstevel@tonic-gate 		(void) fputc('\n', stdout);
2978*0Sstevel@tonic-gate 		return;
2979*0Sstevel@tonic-gate 	case SIGILL:
2980*0Sstevel@tonic-gate 	case SIGTRAP:
2981*0Sstevel@tonic-gate 	case SIGFPE:
2982*0Sstevel@tonic-gate 	case SIGSEGV:
2983*0Sstevel@tonic-gate 	case SIGBUS:
2984*0Sstevel@tonic-gate 	case SIGEMT:
2985*0Sstevel@tonic-gate 	case SIGCLD:
2986*0Sstevel@tonic-gate 	case SIGPOLL:
2987*0Sstevel@tonic-gate 	case SIGXFSZ:
2988*0Sstevel@tonic-gate 		break;
2989*0Sstevel@tonic-gate 	}
2990*0Sstevel@tonic-gate 
2991*0Sstevel@tonic-gate 	switch (sip->si_signo) {
2992*0Sstevel@tonic-gate 	case SIGILL:
2993*0Sstevel@tonic-gate 		switch (sip->si_code) {
2994*0Sstevel@tonic-gate 		case ILL_ILLOPC:	code = "ILL_ILLOPC";	break;
2995*0Sstevel@tonic-gate 		case ILL_ILLOPN:	code = "ILL_ILLOPN";	break;
2996*0Sstevel@tonic-gate 		case ILL_ILLADR:	code = "ILL_ILLADR";	break;
2997*0Sstevel@tonic-gate 		case ILL_ILLTRP:	code = "ILL_ILLTRP";	break;
2998*0Sstevel@tonic-gate 		case ILL_PRVOPC:	code = "ILL_PRVOPC";	break;
2999*0Sstevel@tonic-gate 		case ILL_PRVREG:	code = "ILL_PRVREG";	break;
3000*0Sstevel@tonic-gate 		case ILL_COPROC:	code = "ILL_COPROC";	break;
3001*0Sstevel@tonic-gate 		case ILL_BADSTK:	code = "ILL_BADSTK";	break;
3002*0Sstevel@tonic-gate 		}
3003*0Sstevel@tonic-gate 		break;
3004*0Sstevel@tonic-gate 	case SIGTRAP:
3005*0Sstevel@tonic-gate 		switch (sip->si_code) {
3006*0Sstevel@tonic-gate 		case TRAP_BRKPT:	code = "TRAP_BRKPT";	break;
3007*0Sstevel@tonic-gate 		case TRAP_TRACE:	code = "TRAP_TRACE";	break;
3008*0Sstevel@tonic-gate 		case TRAP_RWATCH:	code = "TRAP_RWATCH";	break;
3009*0Sstevel@tonic-gate 		case TRAP_WWATCH:	code = "TRAP_WWATCH";	break;
3010*0Sstevel@tonic-gate 		case TRAP_XWATCH:	code = "TRAP_XWATCH";	break;
3011*0Sstevel@tonic-gate 		case TRAP_DTRACE:	code = "TRAP_DTRACE";	break;
3012*0Sstevel@tonic-gate 		}
3013*0Sstevel@tonic-gate 		break;
3014*0Sstevel@tonic-gate 	case SIGFPE:
3015*0Sstevel@tonic-gate 		switch (sip->si_code) {
3016*0Sstevel@tonic-gate 		case FPE_INTDIV:	code = "FPE_INTDIV";	break;
3017*0Sstevel@tonic-gate 		case FPE_INTOVF:	code = "FPE_INTOVF";	break;
3018*0Sstevel@tonic-gate 		case FPE_FLTDIV:	code = "FPE_FLTDIV";	break;
3019*0Sstevel@tonic-gate 		case FPE_FLTOVF:	code = "FPE_FLTOVF";	break;
3020*0Sstevel@tonic-gate 		case FPE_FLTUND:	code = "FPE_FLTUND";	break;
3021*0Sstevel@tonic-gate 		case FPE_FLTRES:	code = "FPE_FLTRES";	break;
3022*0Sstevel@tonic-gate 		case FPE_FLTINV:	code = "FPE_FLTINV";	break;
3023*0Sstevel@tonic-gate 		case FPE_FLTSUB:	code = "FPE_FLTSUB";	break;
3024*0Sstevel@tonic-gate #if defined(FPE_FLTDEN)
3025*0Sstevel@tonic-gate 		case FPE_FLTDEN:	code = "FPE_FLTDEN";	break;
3026*0Sstevel@tonic-gate #endif
3027*0Sstevel@tonic-gate 		}
3028*0Sstevel@tonic-gate 		break;
3029*0Sstevel@tonic-gate 	case SIGSEGV:
3030*0Sstevel@tonic-gate 		switch (sip->si_code) {
3031*0Sstevel@tonic-gate 		case SEGV_MAPERR:	code = "SEGV_MAPERR";	break;
3032*0Sstevel@tonic-gate 		case SEGV_ACCERR:	code = "SEGV_ACCERR";	break;
3033*0Sstevel@tonic-gate 		}
3034*0Sstevel@tonic-gate 		break;
3035*0Sstevel@tonic-gate 	case SIGEMT:
3036*0Sstevel@tonic-gate 		switch (sip->si_code) {
3037*0Sstevel@tonic-gate #ifdef EMT_TAGOVF
3038*0Sstevel@tonic-gate 		case EMT_TAGOVF:	code = "EMT_TAGOVF";	break;
3039*0Sstevel@tonic-gate #endif
3040*0Sstevel@tonic-gate 		case EMT_CPCOVF:	code = "EMT_CPCOVF";	break;
3041*0Sstevel@tonic-gate 		}
3042*0Sstevel@tonic-gate 		break;
3043*0Sstevel@tonic-gate 	case SIGBUS:
3044*0Sstevel@tonic-gate 		switch (sip->si_code) {
3045*0Sstevel@tonic-gate 		case BUS_ADRALN:	code = "BUS_ADRALN";	break;
3046*0Sstevel@tonic-gate 		case BUS_ADRERR:	code = "BUS_ADRERR";	break;
3047*0Sstevel@tonic-gate 		case BUS_OBJERR:	code = "BUS_OBJERR";	break;
3048*0Sstevel@tonic-gate 		}
3049*0Sstevel@tonic-gate 		break;
3050*0Sstevel@tonic-gate 	case SIGCLD:
3051*0Sstevel@tonic-gate 		switch (sip->si_code) {
3052*0Sstevel@tonic-gate 		case CLD_EXITED:	code = "CLD_EXITED";	break;
3053*0Sstevel@tonic-gate 		case CLD_KILLED:	code = "CLD_KILLED";	break;
3054*0Sstevel@tonic-gate 		case CLD_DUMPED:	code = "CLD_DUMPED";	break;
3055*0Sstevel@tonic-gate 		case CLD_TRAPPED:	code = "CLD_TRAPPED";	break;
3056*0Sstevel@tonic-gate 		case CLD_STOPPED:	code = "CLD_STOPPED";	break;
3057*0Sstevel@tonic-gate 		case CLD_CONTINUED:	code = "CLD_CONTINUED";	break;
3058*0Sstevel@tonic-gate 		}
3059*0Sstevel@tonic-gate 		break;
3060*0Sstevel@tonic-gate 	case SIGPOLL:
3061*0Sstevel@tonic-gate 		switch (sip->si_code) {
3062*0Sstevel@tonic-gate 		case POLL_IN:		code = "POLL_IN";	break;
3063*0Sstevel@tonic-gate 		case POLL_OUT:		code = "POLL_OUT";	break;
3064*0Sstevel@tonic-gate 		case POLL_MSG:		code = "POLL_MSG";	break;
3065*0Sstevel@tonic-gate 		case POLL_ERR:		code = "POLL_ERR";	break;
3066*0Sstevel@tonic-gate 		case POLL_PRI:		code = "POLL_PRI";	break;
3067*0Sstevel@tonic-gate 		case POLL_HUP:		code = "POLL_HUP";	break;
3068*0Sstevel@tonic-gate 		}
3069*0Sstevel@tonic-gate 		break;
3070*0Sstevel@tonic-gate 	}
3071*0Sstevel@tonic-gate 
3072*0Sstevel@tonic-gate 	if (code == NULL) {
3073*0Sstevel@tonic-gate 		(void) sprintf(pri->code_buf, "code=%d", sip->si_code);
3074*0Sstevel@tonic-gate 		code = (const char *)pri->code_buf;
3075*0Sstevel@tonic-gate 	}
3076*0Sstevel@tonic-gate 
3077*0Sstevel@tonic-gate 	switch (sip->si_signo) {
3078*0Sstevel@tonic-gate 	case SIGILL:
3079*0Sstevel@tonic-gate 	case SIGTRAP:
3080*0Sstevel@tonic-gate 	case SIGFPE:
3081*0Sstevel@tonic-gate 	case SIGSEGV:
3082*0Sstevel@tonic-gate 	case SIGBUS:
3083*0Sstevel@tonic-gate 	case SIGEMT:
3084*0Sstevel@tonic-gate 		(void) printf(" %s addr=0x%.8lX",
3085*0Sstevel@tonic-gate 			code,
3086*0Sstevel@tonic-gate 			(long)sip->si_addr);
3087*0Sstevel@tonic-gate 		break;
3088*0Sstevel@tonic-gate 	case SIGCLD:
3089*0Sstevel@tonic-gate 		(void) printf(" %s pid=%d status=0x%.4X",
3090*0Sstevel@tonic-gate 			code,
3091*0Sstevel@tonic-gate 			(int)sip->si_pid,
3092*0Sstevel@tonic-gate 			sip->si_status);
3093*0Sstevel@tonic-gate 		break;
3094*0Sstevel@tonic-gate 	case SIGPOLL:
3095*0Sstevel@tonic-gate 	case SIGXFSZ:
3096*0Sstevel@tonic-gate 		(void) printf(" %s fd=%d band=%ld",
3097*0Sstevel@tonic-gate 			code,
3098*0Sstevel@tonic-gate 			sip->si_fd,
3099*0Sstevel@tonic-gate 			sip->si_band);
3100*0Sstevel@tonic-gate 		break;
3101*0Sstevel@tonic-gate 	}
3102*0Sstevel@tonic-gate 
3103*0Sstevel@tonic-gate 	if (sip->si_errno != 0) {
3104*0Sstevel@tonic-gate 		const char *ename = errname(sip->si_errno);
3105*0Sstevel@tonic-gate 
3106*0Sstevel@tonic-gate 		(void) printf(" errno=%d", sip->si_errno);
3107*0Sstevel@tonic-gate 		if (ename != NULL)
3108*0Sstevel@tonic-gate 			(void) printf("(%s)", ename);
3109*0Sstevel@tonic-gate 	}
3110*0Sstevel@tonic-gate 
3111*0Sstevel@tonic-gate 	(void) fputc('\n', stdout);
3112*0Sstevel@tonic-gate }
3113*0Sstevel@tonic-gate 
3114*0Sstevel@tonic-gate #ifdef _LP64
3115*0Sstevel@tonic-gate void
3116*0Sstevel@tonic-gate show_siginfo32(private_t *pri, long offset)
3117*0Sstevel@tonic-gate {
3118*0Sstevel@tonic-gate 	struct siginfo32 siginfo;
3119*0Sstevel@tonic-gate 
3120*0Sstevel@tonic-gate 	if (offset != NULL &&
3121*0Sstevel@tonic-gate 	    Pread(Proc, &siginfo, sizeof (siginfo), offset) == sizeof (siginfo))
3122*0Sstevel@tonic-gate 		print_siginfo32(pri, &siginfo);
3123*0Sstevel@tonic-gate }
3124*0Sstevel@tonic-gate #endif	/* _LP64 */
3125*0Sstevel@tonic-gate 
3126*0Sstevel@tonic-gate void
3127*0Sstevel@tonic-gate show_siginfo(private_t *pri, long offset)
3128*0Sstevel@tonic-gate {
3129*0Sstevel@tonic-gate 	struct siginfo siginfo;
3130*0Sstevel@tonic-gate 
3131*0Sstevel@tonic-gate #ifdef _LP64
3132*0Sstevel@tonic-gate 	if (data_model != PR_MODEL_LP64) {
3133*0Sstevel@tonic-gate 		show_siginfo32(pri, offset);
3134*0Sstevel@tonic-gate 		return;
3135*0Sstevel@tonic-gate 	}
3136*0Sstevel@tonic-gate #endif
3137*0Sstevel@tonic-gate 	if (offset != NULL &&
3138*0Sstevel@tonic-gate 	    Pread(Proc, &siginfo, sizeof (siginfo), offset) == sizeof (siginfo))
3139*0Sstevel@tonic-gate 		print_siginfo(pri, &siginfo);
3140*0Sstevel@tonic-gate }
3141*0Sstevel@tonic-gate 
3142*0Sstevel@tonic-gate void
3143*0Sstevel@tonic-gate show_bool(private_t *pri, long offset, int count)
3144*0Sstevel@tonic-gate {
3145*0Sstevel@tonic-gate 	int serial = (count > MYBUFSIZ / 4);
3146*0Sstevel@tonic-gate 
3147*0Sstevel@tonic-gate 	/* enter region of lengthy output */
3148*0Sstevel@tonic-gate 	if (serial)
3149*0Sstevel@tonic-gate 		Eserialize();
3150*0Sstevel@tonic-gate 
3151*0Sstevel@tonic-gate 	while (count > 0) {
3152*0Sstevel@tonic-gate 		char buf[32];
3153*0Sstevel@tonic-gate 		int nb = (count < 32)? count : 32;
3154*0Sstevel@tonic-gate 		int i;
3155*0Sstevel@tonic-gate 
3156*0Sstevel@tonic-gate 		if (Pread(Proc, buf, (size_t)nb, offset) != nb)
3157*0Sstevel@tonic-gate 			break;
3158*0Sstevel@tonic-gate 
3159*0Sstevel@tonic-gate 		(void) printf("%s   ", pri->pname);
3160*0Sstevel@tonic-gate 		for (i = 0; i < nb; i++)
3161*0Sstevel@tonic-gate 			(void) printf(" %d", buf[i]);
3162*0Sstevel@tonic-gate 		(void) fputc('\n', stdout);
3163*0Sstevel@tonic-gate 
3164*0Sstevel@tonic-gate 		count -= nb;
3165*0Sstevel@tonic-gate 		offset += nb;
3166*0Sstevel@tonic-gate 	}
3167*0Sstevel@tonic-gate 
3168*0Sstevel@tonic-gate 	/* exit region of lengthy output */
3169*0Sstevel@tonic-gate 	if (serial)
3170*0Sstevel@tonic-gate 		Xserialize();
3171*0Sstevel@tonic-gate }
3172*0Sstevel@tonic-gate 
3173*0Sstevel@tonic-gate #ifdef _LP64
3174*0Sstevel@tonic-gate void
3175*0Sstevel@tonic-gate show_iovec32(private_t *pri, long offset, int niov, int showbuf, long count)
3176*0Sstevel@tonic-gate {
3177*0Sstevel@tonic-gate 	iovec32_t iovec[16];
3178*0Sstevel@tonic-gate 	iovec32_t *ip;
3179*0Sstevel@tonic-gate 	long nb;
3180*0Sstevel@tonic-gate 	int serial = (count > MYBUFSIZ / 4 && showbuf);
3181*0Sstevel@tonic-gate 
3182*0Sstevel@tonic-gate 	if (niov > 16)		/* is this the real limit? */
3183*0Sstevel@tonic-gate 		niov = 16;
3184*0Sstevel@tonic-gate 
3185*0Sstevel@tonic-gate 	if (offset != NULL && niov > 0 &&
3186*0Sstevel@tonic-gate 	    Pread(Proc, &iovec[0], niov*sizeof (iovec32_t), offset)
3187*0Sstevel@tonic-gate 	    == niov*sizeof (iovec32_t)) {
3188*0Sstevel@tonic-gate 		/* enter region of lengthy output */
3189*0Sstevel@tonic-gate 		if (serial)
3190*0Sstevel@tonic-gate 			Eserialize();
3191*0Sstevel@tonic-gate 
3192*0Sstevel@tonic-gate 		for (ip = &iovec[0]; niov-- && !interrupt; ip++) {
3193*0Sstevel@tonic-gate 			(void) printf("%s\tiov_base = 0x%.8X  iov_len = %d\n",
3194*0Sstevel@tonic-gate 				pri->pname,
3195*0Sstevel@tonic-gate 				ip->iov_base,
3196*0Sstevel@tonic-gate 				ip->iov_len);
3197*0Sstevel@tonic-gate 			if ((nb = count) > 0) {
3198*0Sstevel@tonic-gate 				if (nb > ip->iov_len)
3199*0Sstevel@tonic-gate 					nb = ip->iov_len;
3200*0Sstevel@tonic-gate 				if (nb > 0)
3201*0Sstevel@tonic-gate 					count -= nb;
3202*0Sstevel@tonic-gate 			}
3203*0Sstevel@tonic-gate 			if (showbuf && nb > 0)
3204*0Sstevel@tonic-gate 				showbuffer(pri, (long)ip->iov_base, nb);
3205*0Sstevel@tonic-gate 		}
3206*0Sstevel@tonic-gate 
3207*0Sstevel@tonic-gate 		/* exit region of lengthy output */
3208*0Sstevel@tonic-gate 		if (serial)
3209*0Sstevel@tonic-gate 			Xserialize();
3210*0Sstevel@tonic-gate 	}
3211*0Sstevel@tonic-gate }
3212*0Sstevel@tonic-gate #endif	/* _LP64 */
3213*0Sstevel@tonic-gate 
3214*0Sstevel@tonic-gate void
3215*0Sstevel@tonic-gate show_iovec(private_t *pri, long offset, long niov, int showbuf, long count)
3216*0Sstevel@tonic-gate {
3217*0Sstevel@tonic-gate 	iovec_t iovec[16];
3218*0Sstevel@tonic-gate 	iovec_t *ip;
3219*0Sstevel@tonic-gate 	long nb;
3220*0Sstevel@tonic-gate 	int serial = (count > MYBUFSIZ / 4 && showbuf);
3221*0Sstevel@tonic-gate 
3222*0Sstevel@tonic-gate #ifdef _LP64
3223*0Sstevel@tonic-gate 	if (data_model != PR_MODEL_LP64) {
3224*0Sstevel@tonic-gate 		show_iovec32(pri, offset, niov, showbuf, count);
3225*0Sstevel@tonic-gate 		return;
3226*0Sstevel@tonic-gate 	}
3227*0Sstevel@tonic-gate #endif
3228*0Sstevel@tonic-gate 	if (niov > 16)		/* is this the real limit? */
3229*0Sstevel@tonic-gate 		niov = 16;
3230*0Sstevel@tonic-gate 
3231*0Sstevel@tonic-gate 	if (offset != NULL && niov > 0 &&
3232*0Sstevel@tonic-gate 	    Pread(Proc, &iovec[0], niov*sizeof (iovec_t), offset)
3233*0Sstevel@tonic-gate 	    == niov*sizeof (iovec_t)) {
3234*0Sstevel@tonic-gate 		/* enter region of lengthy output */
3235*0Sstevel@tonic-gate 		if (serial)
3236*0Sstevel@tonic-gate 			Eserialize();
3237*0Sstevel@tonic-gate 
3238*0Sstevel@tonic-gate 		for (ip = &iovec[0]; niov-- && !interrupt; ip++) {
3239*0Sstevel@tonic-gate 			(void) printf("%s\tiov_base = 0x%.8lX  iov_len = %lu\n",
3240*0Sstevel@tonic-gate 				pri->pname,
3241*0Sstevel@tonic-gate 				(long)ip->iov_base,
3242*0Sstevel@tonic-gate 				ip->iov_len);
3243*0Sstevel@tonic-gate 			if ((nb = count) > 0) {
3244*0Sstevel@tonic-gate 				if (nb > ip->iov_len)
3245*0Sstevel@tonic-gate 					nb = ip->iov_len;
3246*0Sstevel@tonic-gate 				if (nb > 0)
3247*0Sstevel@tonic-gate 					count -= nb;
3248*0Sstevel@tonic-gate 			}
3249*0Sstevel@tonic-gate 			if (showbuf && nb > 0)
3250*0Sstevel@tonic-gate 				showbuffer(pri, (long)ip->iov_base, nb);
3251*0Sstevel@tonic-gate 		}
3252*0Sstevel@tonic-gate 
3253*0Sstevel@tonic-gate 		/* exit region of lengthy output */
3254*0Sstevel@tonic-gate 		if (serial)
3255*0Sstevel@tonic-gate 			Xserialize();
3256*0Sstevel@tonic-gate 	}
3257*0Sstevel@tonic-gate }
3258*0Sstevel@tonic-gate 
3259*0Sstevel@tonic-gate void
3260*0Sstevel@tonic-gate show_dents32(private_t *pri, long offset, long count)
3261*0Sstevel@tonic-gate {
3262*0Sstevel@tonic-gate 	long buf[MYBUFSIZ / sizeof (long)];
3263*0Sstevel@tonic-gate 	struct dirent32 *dp;
3264*0Sstevel@tonic-gate 	int serial = (count > 100);
3265*0Sstevel@tonic-gate 
3266*0Sstevel@tonic-gate 	if (offset == NULL)
3267*0Sstevel@tonic-gate 		return;
3268*0Sstevel@tonic-gate 
3269*0Sstevel@tonic-gate 	/* enter region of lengthy output */
3270*0Sstevel@tonic-gate 	if (serial)
3271*0Sstevel@tonic-gate 		Eserialize();
3272*0Sstevel@tonic-gate 
3273*0Sstevel@tonic-gate 	while (count > 0 && !interrupt) {
3274*0Sstevel@tonic-gate 		int nb = count < MYBUFSIZ? (int)count : MYBUFSIZ;
3275*0Sstevel@tonic-gate 
3276*0Sstevel@tonic-gate 		if ((nb = Pread(Proc, &buf[0], (size_t)nb, offset)) <= 0)
3277*0Sstevel@tonic-gate 			break;
3278*0Sstevel@tonic-gate 
3279*0Sstevel@tonic-gate 		dp = (struct dirent32 *)&buf[0];
3280*0Sstevel@tonic-gate 		if (nb < (int)(dp->d_name - (char *)dp))
3281*0Sstevel@tonic-gate 			break;
3282*0Sstevel@tonic-gate 		if ((unsigned)nb < dp->d_reclen) {
3283*0Sstevel@tonic-gate 			/* getdents() error? */
3284*0Sstevel@tonic-gate 			(void) printf(
3285*0Sstevel@tonic-gate 			"%s    ino=%-5u off=%-4d rlen=%-3d\n",
3286*0Sstevel@tonic-gate 				pri->pname,
3287*0Sstevel@tonic-gate 				dp->d_ino,
3288*0Sstevel@tonic-gate 				dp->d_off,
3289*0Sstevel@tonic-gate 				dp->d_reclen);
3290*0Sstevel@tonic-gate 			break;
3291*0Sstevel@tonic-gate 		}
3292*0Sstevel@tonic-gate 
3293*0Sstevel@tonic-gate 		while (!interrupt &&
3294*0Sstevel@tonic-gate 		    nb >= (int)(dp->d_name - (char *)dp) &&
3295*0Sstevel@tonic-gate 		    (unsigned)nb >= dp->d_reclen) {
3296*0Sstevel@tonic-gate 			(void) printf(
3297*0Sstevel@tonic-gate 			"%s    ino=%-5u off=%-4d rlen=%-3d \"%.*s\"\n",
3298*0Sstevel@tonic-gate 				pri->pname,
3299*0Sstevel@tonic-gate 				dp->d_ino,
3300*0Sstevel@tonic-gate 				dp->d_off,
3301*0Sstevel@tonic-gate 				dp->d_reclen,
3302*0Sstevel@tonic-gate 				dp->d_reclen - (int)(dp->d_name - (char *)dp),
3303*0Sstevel@tonic-gate 				dp->d_name);
3304*0Sstevel@tonic-gate 			nb -= dp->d_reclen;
3305*0Sstevel@tonic-gate 			count -= dp->d_reclen;
3306*0Sstevel@tonic-gate 			offset += dp->d_reclen;
3307*0Sstevel@tonic-gate 			/* LINTED improper alignment */
3308*0Sstevel@tonic-gate 			dp = (struct dirent32 *)((char *)dp + dp->d_reclen);
3309*0Sstevel@tonic-gate 		}
3310*0Sstevel@tonic-gate 	}
3311*0Sstevel@tonic-gate 
3312*0Sstevel@tonic-gate 	/* exit region of lengthy output */
3313*0Sstevel@tonic-gate 	if (serial)
3314*0Sstevel@tonic-gate 		Xserialize();
3315*0Sstevel@tonic-gate }
3316*0Sstevel@tonic-gate 
3317*0Sstevel@tonic-gate void
3318*0Sstevel@tonic-gate show_dents64(private_t *pri, long offset, long count)
3319*0Sstevel@tonic-gate {
3320*0Sstevel@tonic-gate 	long long buf[MYBUFSIZ / sizeof (long long)];
3321*0Sstevel@tonic-gate 	struct dirent64 *dp;
3322*0Sstevel@tonic-gate 	int serial = (count > 100);
3323*0Sstevel@tonic-gate 
3324*0Sstevel@tonic-gate 	if (offset == NULL)
3325*0Sstevel@tonic-gate 		return;
3326*0Sstevel@tonic-gate 
3327*0Sstevel@tonic-gate 	/* enter region of lengthy output */
3328*0Sstevel@tonic-gate 	if (serial)
3329*0Sstevel@tonic-gate 		Eserialize();
3330*0Sstevel@tonic-gate 
3331*0Sstevel@tonic-gate 	while (count > 0 && !interrupt) {
3332*0Sstevel@tonic-gate 		int nb = count < MYBUFSIZ? (int)count : MYBUFSIZ;
3333*0Sstevel@tonic-gate 
3334*0Sstevel@tonic-gate 		if ((nb = Pread(Proc, &buf[0], (size_t)nb, offset)) <= 0)
3335*0Sstevel@tonic-gate 			break;
3336*0Sstevel@tonic-gate 
3337*0Sstevel@tonic-gate 		dp = (struct dirent64 *)&buf[0];
3338*0Sstevel@tonic-gate 		if (nb < (int)(dp->d_name - (char *)dp))
3339*0Sstevel@tonic-gate 			break;
3340*0Sstevel@tonic-gate 		if ((unsigned)nb < dp->d_reclen) {
3341*0Sstevel@tonic-gate 			/* getdents() error? */
3342*0Sstevel@tonic-gate 			(void) printf(
3343*0Sstevel@tonic-gate 			"%s    ino=%-5llu off=%-4lld rlen=%-3d\n",
3344*0Sstevel@tonic-gate 				pri->pname,
3345*0Sstevel@tonic-gate 				(long long)dp->d_ino,
3346*0Sstevel@tonic-gate 				(long long)dp->d_off,
3347*0Sstevel@tonic-gate 				dp->d_reclen);
3348*0Sstevel@tonic-gate 			break;
3349*0Sstevel@tonic-gate 		}
3350*0Sstevel@tonic-gate 
3351*0Sstevel@tonic-gate 		while (!interrupt &&
3352*0Sstevel@tonic-gate 		    nb >= (int)(dp->d_name - (char *)dp) &&
3353*0Sstevel@tonic-gate 		    (unsigned)nb >= dp->d_reclen) {
3354*0Sstevel@tonic-gate 			(void) printf(
3355*0Sstevel@tonic-gate 			"%s    ino=%-5llu off=%-4lld rlen=%-3d \"%.*s\"\n",
3356*0Sstevel@tonic-gate 				pri->pname,
3357*0Sstevel@tonic-gate 				(long long)dp->d_ino,
3358*0Sstevel@tonic-gate 				(long long)dp->d_off,
3359*0Sstevel@tonic-gate 				dp->d_reclen,
3360*0Sstevel@tonic-gate 				dp->d_reclen - (int)(dp->d_name - (char *)dp),
3361*0Sstevel@tonic-gate 				dp->d_name);
3362*0Sstevel@tonic-gate 			nb -= dp->d_reclen;
3363*0Sstevel@tonic-gate 			count -= dp->d_reclen;
3364*0Sstevel@tonic-gate 			offset += dp->d_reclen;
3365*0Sstevel@tonic-gate 			/* LINTED improper alignment */
3366*0Sstevel@tonic-gate 			dp = (struct dirent64 *)((char *)dp + dp->d_reclen);
3367*0Sstevel@tonic-gate 		}
3368*0Sstevel@tonic-gate 	}
3369*0Sstevel@tonic-gate 
3370*0Sstevel@tonic-gate 	/* exit region of lengthy output */
3371*0Sstevel@tonic-gate 	if (serial)
3372*0Sstevel@tonic-gate 		Xserialize();
3373*0Sstevel@tonic-gate }
3374*0Sstevel@tonic-gate 
3375*0Sstevel@tonic-gate void
3376*0Sstevel@tonic-gate show_rlimit32(private_t *pri, long offset)
3377*0Sstevel@tonic-gate {
3378*0Sstevel@tonic-gate 	struct rlimit32 rlimit;
3379*0Sstevel@tonic-gate 
3380*0Sstevel@tonic-gate 	if (offset != NULL &&
3381*0Sstevel@tonic-gate 	    Pread(Proc, &rlimit, sizeof (rlimit), offset) == sizeof (rlimit)) {
3382*0Sstevel@tonic-gate 		(void) printf("%s\t", pri->pname);
3383*0Sstevel@tonic-gate 		switch (rlimit.rlim_cur) {
3384*0Sstevel@tonic-gate 		case RLIM32_INFINITY:
3385*0Sstevel@tonic-gate 			(void) fputs("cur = RLIM_INFINITY", stdout);
3386*0Sstevel@tonic-gate 			break;
3387*0Sstevel@tonic-gate 		case RLIM32_SAVED_MAX:
3388*0Sstevel@tonic-gate 			(void) fputs("cur = RLIM_SAVED_MAX", stdout);
3389*0Sstevel@tonic-gate 			break;
3390*0Sstevel@tonic-gate 		case RLIM32_SAVED_CUR:
3391*0Sstevel@tonic-gate 			(void) fputs("cur = RLIM_SAVED_CUR", stdout);
3392*0Sstevel@tonic-gate 			break;
3393*0Sstevel@tonic-gate 		default:
3394*0Sstevel@tonic-gate 			(void) printf("cur = %lu", (long)rlimit.rlim_cur);
3395*0Sstevel@tonic-gate 			break;
3396*0Sstevel@tonic-gate 		}
3397*0Sstevel@tonic-gate 		switch (rlimit.rlim_max) {
3398*0Sstevel@tonic-gate 		case RLIM32_INFINITY:
3399*0Sstevel@tonic-gate 			(void) fputs("  max = RLIM_INFINITY\n", stdout);
3400*0Sstevel@tonic-gate 			break;
3401*0Sstevel@tonic-gate 		case RLIM32_SAVED_MAX:
3402*0Sstevel@tonic-gate 			(void) fputs("  max = RLIM_SAVED_MAX\n", stdout);
3403*0Sstevel@tonic-gate 			break;
3404*0Sstevel@tonic-gate 		case RLIM32_SAVED_CUR:
3405*0Sstevel@tonic-gate 			(void) fputs("  max = RLIM_SAVED_CUR\n", stdout);
3406*0Sstevel@tonic-gate 			break;
3407*0Sstevel@tonic-gate 		default:
3408*0Sstevel@tonic-gate 			(void) printf("  max = %lu\n", (long)rlimit.rlim_max);
3409*0Sstevel@tonic-gate 			break;
3410*0Sstevel@tonic-gate 		}
3411*0Sstevel@tonic-gate 	}
3412*0Sstevel@tonic-gate }
3413*0Sstevel@tonic-gate 
3414*0Sstevel@tonic-gate void
3415*0Sstevel@tonic-gate show_rlimit64(private_t *pri, long offset)
3416*0Sstevel@tonic-gate {
3417*0Sstevel@tonic-gate 	struct rlimit64 rlimit;
3418*0Sstevel@tonic-gate 
3419*0Sstevel@tonic-gate 	if (offset != NULL &&
3420*0Sstevel@tonic-gate 	    Pread(Proc, &rlimit, sizeof (rlimit), offset) == sizeof (rlimit)) {
3421*0Sstevel@tonic-gate 		(void) printf("%s\t", pri->pname);
3422*0Sstevel@tonic-gate 		switch (rlimit.rlim_cur) {
3423*0Sstevel@tonic-gate 		case RLIM64_INFINITY:
3424*0Sstevel@tonic-gate 			(void) fputs("cur = RLIM64_INFINITY", stdout);
3425*0Sstevel@tonic-gate 			break;
3426*0Sstevel@tonic-gate 		case RLIM64_SAVED_MAX:
3427*0Sstevel@tonic-gate 			(void) fputs("cur = RLIM64_SAVED_MAX", stdout);
3428*0Sstevel@tonic-gate 			break;
3429*0Sstevel@tonic-gate 		case RLIM64_SAVED_CUR:
3430*0Sstevel@tonic-gate 			(void) fputs("cur = RLIM64_SAVED_CUR", stdout);
3431*0Sstevel@tonic-gate 			break;
3432*0Sstevel@tonic-gate 		default:
3433*0Sstevel@tonic-gate 			(void) printf("cur = %llu",
3434*0Sstevel@tonic-gate 			    (unsigned long long)rlimit.rlim_cur);
3435*0Sstevel@tonic-gate 			break;
3436*0Sstevel@tonic-gate 		}
3437*0Sstevel@tonic-gate 		switch (rlimit.rlim_max) {
3438*0Sstevel@tonic-gate 		case RLIM64_INFINITY:
3439*0Sstevel@tonic-gate 			(void) fputs("  max = RLIM64_INFINITY\n", stdout);
3440*0Sstevel@tonic-gate 			break;
3441*0Sstevel@tonic-gate 		case RLIM64_SAVED_MAX:
3442*0Sstevel@tonic-gate 			(void) fputs("  max = RLIM64_SAVED_MAX\n", stdout);
3443*0Sstevel@tonic-gate 			break;
3444*0Sstevel@tonic-gate 		case RLIM64_SAVED_CUR:
3445*0Sstevel@tonic-gate 			(void) fputs("  max = RLIM64_SAVED_CUR\n", stdout);
3446*0Sstevel@tonic-gate 			break;
3447*0Sstevel@tonic-gate 		default:
3448*0Sstevel@tonic-gate 			(void) printf("  max = %llu\n",
3449*0Sstevel@tonic-gate 			    (unsigned long long)rlimit.rlim_max);
3450*0Sstevel@tonic-gate 			break;
3451*0Sstevel@tonic-gate 		}
3452*0Sstevel@tonic-gate 	}
3453*0Sstevel@tonic-gate }
3454*0Sstevel@tonic-gate 
3455*0Sstevel@tonic-gate void
3456*0Sstevel@tonic-gate show_nuname(private_t *pri, long offset)
3457*0Sstevel@tonic-gate {
3458*0Sstevel@tonic-gate 	struct utsname ubuf;
3459*0Sstevel@tonic-gate 
3460*0Sstevel@tonic-gate 	if (offset != NULL &&
3461*0Sstevel@tonic-gate 	    Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) {
3462*0Sstevel@tonic-gate 		(void) printf(
3463*0Sstevel@tonic-gate 		"%s\tsys=%s nod=%s rel=%s ver=%s mch=%s\n",
3464*0Sstevel@tonic-gate 			pri->pname,
3465*0Sstevel@tonic-gate 			ubuf.sysname,
3466*0Sstevel@tonic-gate 			ubuf.nodename,
3467*0Sstevel@tonic-gate 			ubuf.release,
3468*0Sstevel@tonic-gate 			ubuf.version,
3469*0Sstevel@tonic-gate 			ubuf.machine);
3470*0Sstevel@tonic-gate 	}
3471*0Sstevel@tonic-gate }
3472*0Sstevel@tonic-gate 
3473*0Sstevel@tonic-gate void
3474*0Sstevel@tonic-gate show_adjtime(private_t *pri, long off1, long off2)
3475*0Sstevel@tonic-gate {
3476*0Sstevel@tonic-gate 	show_timeval(pri, off1, "   delta");
3477*0Sstevel@tonic-gate 	show_timeval(pri, off2, "olddelta");
3478*0Sstevel@tonic-gate }
3479*0Sstevel@tonic-gate 
3480*0Sstevel@tonic-gate void
3481*0Sstevel@tonic-gate show_sockaddr(private_t *pri,
3482*0Sstevel@tonic-gate 	const char *str, long addroff, long lenoff, long len)
3483*0Sstevel@tonic-gate {
3484*0Sstevel@tonic-gate 	/*
3485*0Sstevel@tonic-gate 	 * A buffer large enough for PATH_MAX size AF_UNIX address, which is
3486*0Sstevel@tonic-gate 	 * also large enough to store a sockaddr_in or a sockaddr_in6.
3487*0Sstevel@tonic-gate 	 */
3488*0Sstevel@tonic-gate 	long buf[(sizeof (short) + PATH_MAX + sizeof (long) - 1)
3489*0Sstevel@tonic-gate 		/ sizeof (long)];
3490*0Sstevel@tonic-gate 	struct sockaddr *sa = (struct sockaddr *)buf;
3491*0Sstevel@tonic-gate 	struct sockaddr_in *sin = (struct sockaddr_in *)buf;
3492*0Sstevel@tonic-gate 	struct sockaddr_un *soun = (struct sockaddr_un *)buf;
3493*0Sstevel@tonic-gate 	struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)buf;
3494*0Sstevel@tonic-gate 	char addrbuf[INET6_ADDRSTRLEN];
3495*0Sstevel@tonic-gate 
3496*0Sstevel@tonic-gate 	if (lenoff != 0) {
3497*0Sstevel@tonic-gate 		uint_t ilen;
3498*0Sstevel@tonic-gate 		if (Pread(Proc, &ilen, sizeof (ilen), lenoff) != sizeof (ilen))
3499*0Sstevel@tonic-gate 			return;
3500*0Sstevel@tonic-gate 		len = ilen;
3501*0Sstevel@tonic-gate 	}
3502*0Sstevel@tonic-gate 
3503*0Sstevel@tonic-gate 	if (len >= sizeof (buf))	/* protect against ridiculous length */
3504*0Sstevel@tonic-gate 		len = sizeof (buf) - 1;
3505*0Sstevel@tonic-gate 	if (Pread(Proc, buf, len, addroff) != len)
3506*0Sstevel@tonic-gate 		return;
3507*0Sstevel@tonic-gate 
3508*0Sstevel@tonic-gate 	switch (sa->sa_family) {
3509*0Sstevel@tonic-gate 	case AF_INET6:
3510*0Sstevel@tonic-gate 		(void) printf("%s\tAF_INET6  %s = %s  port = %u\n",
3511*0Sstevel@tonic-gate 		    pri->pname, str,
3512*0Sstevel@tonic-gate 		    inet_ntop(AF_INET6, &sin6->sin6_addr, addrbuf,
3513*0Sstevel@tonic-gate 			sizeof (addrbuf)),
3514*0Sstevel@tonic-gate 		    ntohs(sin6->sin6_port));
3515*0Sstevel@tonic-gate 		(void) printf("%s\tscope id = %u  source id = 0x%x\n"
3516*0Sstevel@tonic-gate 		    "%s\tflow class = 0x%02x  flow label = 0x%05x\n",
3517*0Sstevel@tonic-gate 		    pri->pname, ntohl(sin6->sin6_scope_id),
3518*0Sstevel@tonic-gate 		    ntohl(sin6->__sin6_src_id),
3519*0Sstevel@tonic-gate 		    pri->pname,
3520*0Sstevel@tonic-gate 		    ntohl((sin6->sin6_flowinfo & IPV6_FLOWINFO_TCLASS) >> 20),
3521*0Sstevel@tonic-gate 		    ntohl(sin6->sin6_flowinfo & IPV6_FLOWINFO_FLOWLABEL));
3522*0Sstevel@tonic-gate 		break;
3523*0Sstevel@tonic-gate 	case AF_INET:
3524*0Sstevel@tonic-gate 	case AF_NCA:
3525*0Sstevel@tonic-gate 		(void) printf("%s\tAF_%s  %s = %s  port = %u\n",
3526*0Sstevel@tonic-gate 		    pri->pname, sa->sa_family == AF_INET ? "INET" : "NCA",
3527*0Sstevel@tonic-gate 		    str, inet_ntop(AF_INET, &sin->sin_addr, addrbuf,
3528*0Sstevel@tonic-gate 		    sizeof (addrbuf)), ntohs(sin->sin_port));
3529*0Sstevel@tonic-gate 		break;
3530*0Sstevel@tonic-gate 	case AF_UNIX:
3531*0Sstevel@tonic-gate 		len -= sizeof (soun->sun_family);
3532*0Sstevel@tonic-gate 		if (len >= 0) {
3533*0Sstevel@tonic-gate 			/* Null terminate */
3534*0Sstevel@tonic-gate 			soun->sun_path[len] = NULL;
3535*0Sstevel@tonic-gate 			(void) printf("%s\tAF_UNIX  %s = %s\n", pri->pname,
3536*0Sstevel@tonic-gate 				str, soun->sun_path);
3537*0Sstevel@tonic-gate 		}
3538*0Sstevel@tonic-gate 		break;
3539*0Sstevel@tonic-gate 	}
3540*0Sstevel@tonic-gate }
3541*0Sstevel@tonic-gate 
3542*0Sstevel@tonic-gate void
3543*0Sstevel@tonic-gate show_msghdr(private_t *pri, long offset)
3544*0Sstevel@tonic-gate {
3545*0Sstevel@tonic-gate 	struct msghdr msg;
3546*0Sstevel@tonic-gate 
3547*0Sstevel@tonic-gate 	if (Pread(Proc, &msg, sizeof (msg), offset) != sizeof (msg))
3548*0Sstevel@tonic-gate 		return;
3549*0Sstevel@tonic-gate 	if (msg.msg_name != NULL && msg.msg_namelen != 0)
3550*0Sstevel@tonic-gate 		show_sockaddr(pri, "msg_name",
3551*0Sstevel@tonic-gate 			(long)msg.msg_name, 0, (long)msg.msg_namelen);
3552*0Sstevel@tonic-gate 	/* XXX add msg_iov printing */
3553*0Sstevel@tonic-gate }
3554*0Sstevel@tonic-gate 
3555*0Sstevel@tonic-gate #ifdef _LP64
3556*0Sstevel@tonic-gate void
3557*0Sstevel@tonic-gate show_msghdr32(private_t *pri, long offset)
3558*0Sstevel@tonic-gate {
3559*0Sstevel@tonic-gate 	struct msghdr32 {
3560*0Sstevel@tonic-gate 		caddr32_t	msg_name;
3561*0Sstevel@tonic-gate 		int32_t		msg_namelen;
3562*0Sstevel@tonic-gate 	} msg;
3563*0Sstevel@tonic-gate 
3564*0Sstevel@tonic-gate 	if (Pread(Proc, &msg, sizeof (msg), offset) != sizeof (msg))
3565*0Sstevel@tonic-gate 		return;
3566*0Sstevel@tonic-gate 	if (msg.msg_name != NULL && msg.msg_namelen != 0)
3567*0Sstevel@tonic-gate 		show_sockaddr(pri, "msg_name",
3568*0Sstevel@tonic-gate 			(long)msg.msg_name, 0, (long)msg.msg_namelen);
3569*0Sstevel@tonic-gate 	/* XXX add msg_iov printing */
3570*0Sstevel@tonic-gate }
3571*0Sstevel@tonic-gate #endif	/* _LP64 */
3572*0Sstevel@tonic-gate 
3573*0Sstevel@tonic-gate static void
3574*0Sstevel@tonic-gate show_doorargs(private_t *pri, long offset)
3575*0Sstevel@tonic-gate {
3576*0Sstevel@tonic-gate 	door_arg_t args;
3577*0Sstevel@tonic-gate 
3578*0Sstevel@tonic-gate 	if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
3579*0Sstevel@tonic-gate 		(void) printf("%s\tdata_ptr=0x%lX data_size=%lu\n",
3580*0Sstevel@tonic-gate 		    pri->pname,
3581*0Sstevel@tonic-gate 		    (ulong_t)args.data_ptr,
3582*0Sstevel@tonic-gate 		    (ulong_t)args.data_size);
3583*0Sstevel@tonic-gate 		(void) printf("%s\tdesc_ptr=0x%lX desc_num=%u\n",
3584*0Sstevel@tonic-gate 		    pri->pname,
3585*0Sstevel@tonic-gate 		    (ulong_t)args.desc_ptr,
3586*0Sstevel@tonic-gate 		    args.desc_num);
3587*0Sstevel@tonic-gate 		(void) printf("%s\trbuf=0x%lX rsize=%lu\n",
3588*0Sstevel@tonic-gate 		    pri->pname,
3589*0Sstevel@tonic-gate 		    (ulong_t)args.rbuf,
3590*0Sstevel@tonic-gate 		    (ulong_t)args.rsize);
3591*0Sstevel@tonic-gate 	}
3592*0Sstevel@tonic-gate }
3593*0Sstevel@tonic-gate 
3594*0Sstevel@tonic-gate static void
3595*0Sstevel@tonic-gate show_ucred_privsets(private_t *pri, ucred_t *uc)
3596*0Sstevel@tonic-gate {
3597*0Sstevel@tonic-gate 	int i = 0;
3598*0Sstevel@tonic-gate 	const priv_set_t *s;
3599*0Sstevel@tonic-gate 	priv_ptype_t sn;
3600*0Sstevel@tonic-gate 	char *str;
3601*0Sstevel@tonic-gate 
3602*0Sstevel@tonic-gate 	while ((sn = priv_getsetbynum(i++)) != NULL) {
3603*0Sstevel@tonic-gate 		s = ucred_getprivset(uc, sn);
3604*0Sstevel@tonic-gate 
3605*0Sstevel@tonic-gate 		if (s == NULL)
3606*0Sstevel@tonic-gate 			continue;
3607*0Sstevel@tonic-gate 
3608*0Sstevel@tonic-gate 		(void) printf("%s\t%c: %s\n",
3609*0Sstevel@tonic-gate 		    pri->pname,
3610*0Sstevel@tonic-gate 		    *sn,
3611*0Sstevel@tonic-gate 		    str = priv_set_to_str(s, ',', PRIV_STR_SHORT));
3612*0Sstevel@tonic-gate 
3613*0Sstevel@tonic-gate 		free(str);
3614*0Sstevel@tonic-gate 	}
3615*0Sstevel@tonic-gate }
3616*0Sstevel@tonic-gate 
3617*0Sstevel@tonic-gate static void
3618*0Sstevel@tonic-gate show_ucred(private_t *pri, long offset)
3619*0Sstevel@tonic-gate {
3620*0Sstevel@tonic-gate 	ucred_t *uc = _ucred_alloc();
3621*0Sstevel@tonic-gate 	size_t sz;
3622*0Sstevel@tonic-gate 
3623*0Sstevel@tonic-gate 	if (uc == NULL)
3624*0Sstevel@tonic-gate 		return;
3625*0Sstevel@tonic-gate 
3626*0Sstevel@tonic-gate 	sz = Pread(Proc, uc, uc->uc_size, offset);
3627*0Sstevel@tonic-gate 
3628*0Sstevel@tonic-gate 	/*
3629*0Sstevel@tonic-gate 	 * A new uc_size is read, it could be smaller than the previously
3630*0Sstevel@tonic-gate 	 * value.  We accept short reads that fill the whole header.
3631*0Sstevel@tonic-gate 	 */
3632*0Sstevel@tonic-gate 	if (sz >= sizeof (ucred_t) && sz >= uc->uc_size) {
3633*0Sstevel@tonic-gate 		(void) printf("%s\teuid=%d egid=%d\n",
3634*0Sstevel@tonic-gate 		    pri->pname,
3635*0Sstevel@tonic-gate 		    (int)ucred_geteuid(uc),
3636*0Sstevel@tonic-gate 		    (int)ucred_getegid(uc));
3637*0Sstevel@tonic-gate 		(void) printf("%s\truid=%d rgid=%d\n",
3638*0Sstevel@tonic-gate 		    pri->pname,
3639*0Sstevel@tonic-gate 		    (int)ucred_getruid(uc),
3640*0Sstevel@tonic-gate 		    (int)ucred_getrgid(uc));
3641*0Sstevel@tonic-gate 		(void) printf("%s\tpid=%d zoneid=%d\n",
3642*0Sstevel@tonic-gate 		    pri->pname,
3643*0Sstevel@tonic-gate 		    (int)ucred_getpid(uc),
3644*0Sstevel@tonic-gate 		    (int)ucred_getzoneid(uc));
3645*0Sstevel@tonic-gate 		show_ucred_privsets(pri, uc);
3646*0Sstevel@tonic-gate 	}
3647*0Sstevel@tonic-gate 	ucred_free(uc);
3648*0Sstevel@tonic-gate }
3649*0Sstevel@tonic-gate 
3650*0Sstevel@tonic-gate static void
3651*0Sstevel@tonic-gate show_privset(private_t *pri, long offset, size_t size)
3652*0Sstevel@tonic-gate {
3653*0Sstevel@tonic-gate 	priv_set_t *tmp = priv_allocset();
3654*0Sstevel@tonic-gate 	size_t sz;
3655*0Sstevel@tonic-gate 
3656*0Sstevel@tonic-gate 	if (tmp == NULL)
3657*0Sstevel@tonic-gate 		return;
3658*0Sstevel@tonic-gate 
3659*0Sstevel@tonic-gate 	sz = Pread(Proc, tmp, size, offset);
3660*0Sstevel@tonic-gate 
3661*0Sstevel@tonic-gate 	if (sz == size) {
3662*0Sstevel@tonic-gate 		char *str = priv_set_to_str(tmp, ',', PRIV_STR_SHORT);
3663*0Sstevel@tonic-gate 		if (str != NULL) {
3664*0Sstevel@tonic-gate 			(void) printf("%s\t%s\n", pri->pname, str);
3665*0Sstevel@tonic-gate 			free(str);
3666*0Sstevel@tonic-gate 		}
3667*0Sstevel@tonic-gate 	}
3668*0Sstevel@tonic-gate 	priv_freeset(tmp);
3669*0Sstevel@tonic-gate }
3670*0Sstevel@tonic-gate 
3671*0Sstevel@tonic-gate static void
3672*0Sstevel@tonic-gate show_doorinfo(private_t *pri, long offset)
3673*0Sstevel@tonic-gate {
3674*0Sstevel@tonic-gate 	door_info_t info;
3675*0Sstevel@tonic-gate 	door_attr_t attr;
3676*0Sstevel@tonic-gate 
3677*0Sstevel@tonic-gate 	if (Pread(Proc, &info, sizeof (info), offset) != sizeof (info))
3678*0Sstevel@tonic-gate 		return;
3679*0Sstevel@tonic-gate 	(void) printf("%s\ttarget=%d proc=0x%llX data=0x%llX\n",
3680*0Sstevel@tonic-gate 	    pri->pname,
3681*0Sstevel@tonic-gate 	    (int)info.di_target,
3682*0Sstevel@tonic-gate 	    info.di_proc,
3683*0Sstevel@tonic-gate 	    info.di_data);
3684*0Sstevel@tonic-gate 	attr = info.di_attributes;
3685*0Sstevel@tonic-gate 	(void) printf("%s\tattributes=%s\n", pri->pname, door_flags(pri, attr));
3686*0Sstevel@tonic-gate 	(void) printf("%s\tuniquifier=%llu\n", pri->pname, info.di_uniquifier);
3687*0Sstevel@tonic-gate }
3688*0Sstevel@tonic-gate 
3689*0Sstevel@tonic-gate static void
3690*0Sstevel@tonic-gate show_doorparam(private_t *pri, long offset)
3691*0Sstevel@tonic-gate {
3692*0Sstevel@tonic-gate 	ulong_t val;
3693*0Sstevel@tonic-gate 
3694*0Sstevel@tonic-gate 	if (Pread(Proc, &val, sizeof (val), offset) == sizeof (val)) {
3695*0Sstevel@tonic-gate 		(void) printf("%s\tvalue=%lu\n",
3696*0Sstevel@tonic-gate 		    pri->pname,
3697*0Sstevel@tonic-gate 		    val);
3698*0Sstevel@tonic-gate 	}
3699*0Sstevel@tonic-gate }
3700*0Sstevel@tonic-gate 
3701*0Sstevel@tonic-gate #ifdef _LP64
3702*0Sstevel@tonic-gate 
3703*0Sstevel@tonic-gate static void
3704*0Sstevel@tonic-gate show_doorargs32(private_t *pri, long offset)
3705*0Sstevel@tonic-gate {
3706*0Sstevel@tonic-gate 	struct door_arg32 args;
3707*0Sstevel@tonic-gate 
3708*0Sstevel@tonic-gate 	if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
3709*0Sstevel@tonic-gate 		(void) printf("%s\tdata_ptr=%X data_size=%u\n",
3710*0Sstevel@tonic-gate 		    pri->pname,
3711*0Sstevel@tonic-gate 		    args.data_ptr,
3712*0Sstevel@tonic-gate 		    args.data_size);
3713*0Sstevel@tonic-gate 		(void) printf("%s\tdesc_ptr=0x%X desc_num=%u\n",
3714*0Sstevel@tonic-gate 		    pri->pname,
3715*0Sstevel@tonic-gate 		    args.desc_ptr,
3716*0Sstevel@tonic-gate 		    args.desc_num);
3717*0Sstevel@tonic-gate 		(void) printf("%s\trbuf=0x%X rsize=%u\n",
3718*0Sstevel@tonic-gate 		    pri->pname,
3719*0Sstevel@tonic-gate 		    args.rbuf,
3720*0Sstevel@tonic-gate 		    args.rsize);
3721*0Sstevel@tonic-gate 	}
3722*0Sstevel@tonic-gate }
3723*0Sstevel@tonic-gate 
3724*0Sstevel@tonic-gate static void
3725*0Sstevel@tonic-gate show_doorparam32(private_t *pri, long offset)
3726*0Sstevel@tonic-gate {
3727*0Sstevel@tonic-gate 	uint_t val;
3728*0Sstevel@tonic-gate 
3729*0Sstevel@tonic-gate 	if (Pread(Proc, &val, sizeof (val), offset) == sizeof (val)) {
3730*0Sstevel@tonic-gate 		(void) printf("%s\tvalue=%u\n",
3731*0Sstevel@tonic-gate 		    pri->pname,
3732*0Sstevel@tonic-gate 		    val);
3733*0Sstevel@tonic-gate 	}
3734*0Sstevel@tonic-gate }
3735*0Sstevel@tonic-gate 
3736*0Sstevel@tonic-gate #endif	/* _LP64 */
3737*0Sstevel@tonic-gate 
3738*0Sstevel@tonic-gate static void
3739*0Sstevel@tonic-gate show_doors(private_t *pri)
3740*0Sstevel@tonic-gate {
3741*0Sstevel@tonic-gate 	switch (pri->sys_args[5]) {
3742*0Sstevel@tonic-gate 	case DOOR_CALL:
3743*0Sstevel@tonic-gate #ifdef _LP64
3744*0Sstevel@tonic-gate 		if (data_model == PR_MODEL_LP64)
3745*0Sstevel@tonic-gate 			show_doorargs(pri, (long)pri->sys_args[1]);
3746*0Sstevel@tonic-gate 		else
3747*0Sstevel@tonic-gate 			show_doorargs32(pri, (long)pri->sys_args[1]);
3748*0Sstevel@tonic-gate #else
3749*0Sstevel@tonic-gate 		show_doorargs(pri, (long)pri->sys_args[1]);
3750*0Sstevel@tonic-gate #endif
3751*0Sstevel@tonic-gate 		break;
3752*0Sstevel@tonic-gate 	case DOOR_UCRED:
3753*0Sstevel@tonic-gate 		if (!pri->Errno)
3754*0Sstevel@tonic-gate 			show_ucred(pri, (long)pri->sys_args[0]);
3755*0Sstevel@tonic-gate 		break;
3756*0Sstevel@tonic-gate 	case DOOR_INFO:
3757*0Sstevel@tonic-gate 		if (!pri->Errno)
3758*0Sstevel@tonic-gate 			show_doorinfo(pri, (long)pri->sys_args[1]);
3759*0Sstevel@tonic-gate 		break;
3760*0Sstevel@tonic-gate 	case DOOR_GETPARAM:
3761*0Sstevel@tonic-gate 		if (!pri->Errno) {
3762*0Sstevel@tonic-gate #ifdef _LP64
3763*0Sstevel@tonic-gate 			if (data_model == PR_MODEL_LP64)
3764*0Sstevel@tonic-gate 				show_doorparam(pri, (long)pri->sys_args[2]);
3765*0Sstevel@tonic-gate 			else
3766*0Sstevel@tonic-gate 				show_doorparam32(pri, (long)pri->sys_args[2]);
3767*0Sstevel@tonic-gate #else
3768*0Sstevel@tonic-gate 			show_doorparam(pri, (long)pri->sys_args[2]);
3769*0Sstevel@tonic-gate #endif
3770*0Sstevel@tonic-gate 		}
3771*0Sstevel@tonic-gate 		break;
3772*0Sstevel@tonic-gate 	}
3773*0Sstevel@tonic-gate }
3774*0Sstevel@tonic-gate 
3775*0Sstevel@tonic-gate static void
3776*0Sstevel@tonic-gate show_portargs(private_t *pri, long offset)
3777*0Sstevel@tonic-gate {
3778*0Sstevel@tonic-gate 	port_event_t args;
3779*0Sstevel@tonic-gate 
3780*0Sstevel@tonic-gate 	if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
3781*0Sstevel@tonic-gate 		(void) printf("%s\tevents=0x%x source=%u\n",
3782*0Sstevel@tonic-gate 		    pri->pname,
3783*0Sstevel@tonic-gate 		    args.portev_events,
3784*0Sstevel@tonic-gate 		    args.portev_source);
3785*0Sstevel@tonic-gate 		(void) printf("%s\tobject=0x%p user=0x%p\n",
3786*0Sstevel@tonic-gate 		    pri->pname,
3787*0Sstevel@tonic-gate 		    (void *)args.portev_object,
3788*0Sstevel@tonic-gate 		    (void *)args.portev_user);
3789*0Sstevel@tonic-gate 	}
3790*0Sstevel@tonic-gate }
3791*0Sstevel@tonic-gate 
3792*0Sstevel@tonic-gate 
3793*0Sstevel@tonic-gate #ifdef _LP64
3794*0Sstevel@tonic-gate 
3795*0Sstevel@tonic-gate static void
3796*0Sstevel@tonic-gate show_portargs32(private_t *pri, long offset)
3797*0Sstevel@tonic-gate {
3798*0Sstevel@tonic-gate 	port_event32_t args;
3799*0Sstevel@tonic-gate 
3800*0Sstevel@tonic-gate 	if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
3801*0Sstevel@tonic-gate 		(void) printf("%s\tevents=0x%x source=%u\n",
3802*0Sstevel@tonic-gate 		    pri->pname,
3803*0Sstevel@tonic-gate 		    args.portev_events,
3804*0Sstevel@tonic-gate 		    args.portev_source);
3805*0Sstevel@tonic-gate 		(void) printf("%s\tobject=0x%x user=0x%x\n",
3806*0Sstevel@tonic-gate 		    pri->pname,
3807*0Sstevel@tonic-gate 		    args.portev_object,
3808*0Sstevel@tonic-gate 		    args.portev_user);
3809*0Sstevel@tonic-gate 	}
3810*0Sstevel@tonic-gate }
3811*0Sstevel@tonic-gate 
3812*0Sstevel@tonic-gate #endif	/* _LP64 */
3813*0Sstevel@tonic-gate 
3814*0Sstevel@tonic-gate static void
3815*0Sstevel@tonic-gate show_ports(private_t *pri)
3816*0Sstevel@tonic-gate {
3817*0Sstevel@tonic-gate 	switch (pri->sys_args[0]) {
3818*0Sstevel@tonic-gate 	case PORT_GET:
3819*0Sstevel@tonic-gate #ifdef _LP64
3820*0Sstevel@tonic-gate 		if (data_model == PR_MODEL_LP64)
3821*0Sstevel@tonic-gate 			show_portargs(pri, (long)pri->sys_args[2]);
3822*0Sstevel@tonic-gate 		else
3823*0Sstevel@tonic-gate 			show_portargs32(pri, (long)pri->sys_args[2]);
3824*0Sstevel@tonic-gate #else
3825*0Sstevel@tonic-gate 		show_portargs(pri, (long)pri->sys_args[2]);
3826*0Sstevel@tonic-gate #endif
3827*0Sstevel@tonic-gate 		break;
3828*0Sstevel@tonic-gate 	}
3829*0Sstevel@tonic-gate }
3830*0Sstevel@tonic-gate 
3831*0Sstevel@tonic-gate #define	MAX_SNDFL_PRD 16
3832*0Sstevel@tonic-gate 
3833*0Sstevel@tonic-gate #ifdef _LP64
3834*0Sstevel@tonic-gate 
3835*0Sstevel@tonic-gate static void
3836*0Sstevel@tonic-gate show_ksendfilevec32(private_t *pri, int fd,
3837*0Sstevel@tonic-gate     ksendfilevec32_t *sndvec, int sfvcnt)
3838*0Sstevel@tonic-gate {
3839*0Sstevel@tonic-gate 	ksendfilevec32_t *snd_ptr, snd[MAX_SNDFL_PRD];
3840*0Sstevel@tonic-gate 	size_t cpy_rqst;
3841*0Sstevel@tonic-gate 
3842*0Sstevel@tonic-gate 	Eserialize();
3843*0Sstevel@tonic-gate 	while (sfvcnt > 0) {
3844*0Sstevel@tonic-gate 		cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
3845*0Sstevel@tonic-gate 		sfvcnt -= cpy_rqst;
3846*0Sstevel@tonic-gate 		cpy_rqst *= sizeof (snd[0]);
3847*0Sstevel@tonic-gate 
3848*0Sstevel@tonic-gate 		if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
3849*0Sstevel@tonic-gate 			break;
3850*0Sstevel@tonic-gate 
3851*0Sstevel@tonic-gate 		snd_ptr = &snd[0];
3852*0Sstevel@tonic-gate 
3853*0Sstevel@tonic-gate 		while (cpy_rqst) {
3854*0Sstevel@tonic-gate 			(void) printf(
3855*0Sstevel@tonic-gate 			    "sfv_fd=%d\tsfv_flag=0x%x\t"
3856*0Sstevel@tonic-gate 			    "sfv_off=%d\tsfv_len=%u\n",
3857*0Sstevel@tonic-gate 			    snd_ptr->sfv_fd,
3858*0Sstevel@tonic-gate 			    snd_ptr->sfv_flag,
3859*0Sstevel@tonic-gate 			    snd_ptr->sfv_off,
3860*0Sstevel@tonic-gate 			    snd_ptr->sfv_len);
3861*0Sstevel@tonic-gate 
3862*0Sstevel@tonic-gate 			if (snd_ptr->sfv_fd == SFV_FD_SELF &&
3863*0Sstevel@tonic-gate 			    prismember(&writefd, fd)) {
3864*0Sstevel@tonic-gate 				showbuffer(pri,
3865*0Sstevel@tonic-gate 				    (long)snd_ptr->sfv_off & 0xffffffff,
3866*0Sstevel@tonic-gate 				    (long)snd_ptr->sfv_len);
3867*0Sstevel@tonic-gate 			}
3868*0Sstevel@tonic-gate 
3869*0Sstevel@tonic-gate 			cpy_rqst -= sizeof (snd[0]);
3870*0Sstevel@tonic-gate 			snd_ptr++;
3871*0Sstevel@tonic-gate 		}
3872*0Sstevel@tonic-gate 
3873*0Sstevel@tonic-gate 		sndvec += MAX_SNDFL_PRD;
3874*0Sstevel@tonic-gate 	}
3875*0Sstevel@tonic-gate 	Xserialize();
3876*0Sstevel@tonic-gate }
3877*0Sstevel@tonic-gate 
3878*0Sstevel@tonic-gate static void
3879*0Sstevel@tonic-gate show_ksendfilevec64(private_t *pri, int fd,
3880*0Sstevel@tonic-gate     ksendfilevec64_t *sndvec, int sfvcnt)
3881*0Sstevel@tonic-gate {
3882*0Sstevel@tonic-gate 	ksendfilevec64_t *snd_ptr, snd[MAX_SNDFL_PRD];
3883*0Sstevel@tonic-gate 	size_t cpy_rqst;
3884*0Sstevel@tonic-gate 
3885*0Sstevel@tonic-gate 	Eserialize();
3886*0Sstevel@tonic-gate 	while (sfvcnt > 0) {
3887*0Sstevel@tonic-gate 		cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
3888*0Sstevel@tonic-gate 		sfvcnt -= cpy_rqst;
3889*0Sstevel@tonic-gate 		cpy_rqst *= sizeof (snd[0]);
3890*0Sstevel@tonic-gate 
3891*0Sstevel@tonic-gate 		if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
3892*0Sstevel@tonic-gate 			break;
3893*0Sstevel@tonic-gate 
3894*0Sstevel@tonic-gate 		snd_ptr = &snd[0];
3895*0Sstevel@tonic-gate 
3896*0Sstevel@tonic-gate 		while (cpy_rqst) {
3897*0Sstevel@tonic-gate 			(void) printf(
3898*0Sstevel@tonic-gate 			    "sfv_fd=%d\tsfv_flag=0x%x\t"
3899*0Sstevel@tonic-gate 			    "sfv_off=%ld\tsfv_len=%u\n",
3900*0Sstevel@tonic-gate 			    snd_ptr->sfv_fd,
3901*0Sstevel@tonic-gate 			    snd_ptr->sfv_flag,
3902*0Sstevel@tonic-gate 			    snd_ptr->sfv_off,
3903*0Sstevel@tonic-gate 			    snd_ptr->sfv_len);
3904*0Sstevel@tonic-gate 
3905*0Sstevel@tonic-gate 			if (snd_ptr->sfv_fd == SFV_FD_SELF &&
3906*0Sstevel@tonic-gate 			    prismember(&writefd, fd)) {
3907*0Sstevel@tonic-gate 				showbuffer(pri,
3908*0Sstevel@tonic-gate 				    (long)snd_ptr->sfv_off & 0xffffffff,
3909*0Sstevel@tonic-gate 				    (long)snd_ptr->sfv_len);
3910*0Sstevel@tonic-gate 			}
3911*0Sstevel@tonic-gate 
3912*0Sstevel@tonic-gate 			cpy_rqst -= sizeof (snd[0]);
3913*0Sstevel@tonic-gate 			snd_ptr++;
3914*0Sstevel@tonic-gate 		}
3915*0Sstevel@tonic-gate 
3916*0Sstevel@tonic-gate 		sndvec += MAX_SNDFL_PRD;
3917*0Sstevel@tonic-gate 	}
3918*0Sstevel@tonic-gate 	Xserialize();
3919*0Sstevel@tonic-gate }
3920*0Sstevel@tonic-gate 
3921*0Sstevel@tonic-gate #endif /* _LP64 */
3922*0Sstevel@tonic-gate 
3923*0Sstevel@tonic-gate /*ARGSUSED*/
3924*0Sstevel@tonic-gate static void
3925*0Sstevel@tonic-gate show_sendfilevec(private_t *pri, int fd, sendfilevec_t *sndvec, int sfvcnt)
3926*0Sstevel@tonic-gate {
3927*0Sstevel@tonic-gate 	sendfilevec_t *snd_ptr, snd[MAX_SNDFL_PRD];
3928*0Sstevel@tonic-gate 	size_t cpy_rqst;
3929*0Sstevel@tonic-gate 
3930*0Sstevel@tonic-gate #ifdef _LP64
3931*0Sstevel@tonic-gate 	if (data_model != PR_MODEL_LP64) {
3932*0Sstevel@tonic-gate 		show_ksendfilevec32(pri, fd,
3933*0Sstevel@tonic-gate 		    (ksendfilevec32_t *)sndvec, sfvcnt);
3934*0Sstevel@tonic-gate 		return;
3935*0Sstevel@tonic-gate 	}
3936*0Sstevel@tonic-gate #endif
3937*0Sstevel@tonic-gate 	Eserialize();
3938*0Sstevel@tonic-gate 	while (sfvcnt > 0) {
3939*0Sstevel@tonic-gate 		cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
3940*0Sstevel@tonic-gate 		sfvcnt -= cpy_rqst;
3941*0Sstevel@tonic-gate 		cpy_rqst *= sizeof (snd[0]);
3942*0Sstevel@tonic-gate 
3943*0Sstevel@tonic-gate 		if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
3944*0Sstevel@tonic-gate 			break;
3945*0Sstevel@tonic-gate 
3946*0Sstevel@tonic-gate 		snd_ptr = &snd[0];
3947*0Sstevel@tonic-gate 
3948*0Sstevel@tonic-gate 		while (cpy_rqst) {
3949*0Sstevel@tonic-gate 			(void) printf(
3950*0Sstevel@tonic-gate 			    "sfv_fd=%d\tsfv_flag=0x%x\t"
3951*0Sstevel@tonic-gate 			    "sfv_off=%ld\tsfv_len=%lu\n",
3952*0Sstevel@tonic-gate 			    snd_ptr->sfv_fd,
3953*0Sstevel@tonic-gate 			    snd_ptr->sfv_flag,
3954*0Sstevel@tonic-gate 			    snd_ptr->sfv_off,
3955*0Sstevel@tonic-gate 			    (ulong_t)snd_ptr->sfv_len);
3956*0Sstevel@tonic-gate 
3957*0Sstevel@tonic-gate 			if (snd_ptr->sfv_fd == SFV_FD_SELF &&
3958*0Sstevel@tonic-gate 			    prismember(&writefd, fd)) {
3959*0Sstevel@tonic-gate 				showbuffer(pri, (long)snd_ptr->sfv_off,
3960*0Sstevel@tonic-gate 					    (long)snd_ptr->sfv_len);
3961*0Sstevel@tonic-gate 			}
3962*0Sstevel@tonic-gate 
3963*0Sstevel@tonic-gate 			cpy_rqst -= sizeof (snd[0]);
3964*0Sstevel@tonic-gate 			snd_ptr++;
3965*0Sstevel@tonic-gate 		}
3966*0Sstevel@tonic-gate 
3967*0Sstevel@tonic-gate 		sndvec += MAX_SNDFL_PRD;
3968*0Sstevel@tonic-gate 	}
3969*0Sstevel@tonic-gate 	Xserialize();
3970*0Sstevel@tonic-gate }
3971*0Sstevel@tonic-gate 
3972*0Sstevel@tonic-gate /*ARGSUSED*/
3973*0Sstevel@tonic-gate static void
3974*0Sstevel@tonic-gate show_sendfilevec64(private_t *pri, int fd, sendfilevec64_t *sndvec, int sfvcnt)
3975*0Sstevel@tonic-gate {
3976*0Sstevel@tonic-gate 	sendfilevec64_t *snd_ptr, snd[MAX_SNDFL_PRD];
3977*0Sstevel@tonic-gate 	size_t cpy_rqst;
3978*0Sstevel@tonic-gate 
3979*0Sstevel@tonic-gate #ifdef _LP64
3980*0Sstevel@tonic-gate 	if (data_model != PR_MODEL_LP64) {
3981*0Sstevel@tonic-gate 		show_ksendfilevec64(pri, fd,
3982*0Sstevel@tonic-gate 		    (ksendfilevec64_t *)sndvec, sfvcnt);
3983*0Sstevel@tonic-gate 		return;
3984*0Sstevel@tonic-gate 	}
3985*0Sstevel@tonic-gate #endif
3986*0Sstevel@tonic-gate 
3987*0Sstevel@tonic-gate 	Eserialize();
3988*0Sstevel@tonic-gate 	while (sfvcnt > 0) {
3989*0Sstevel@tonic-gate 		cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
3990*0Sstevel@tonic-gate 		sfvcnt -= cpy_rqst;
3991*0Sstevel@tonic-gate 		cpy_rqst *= sizeof (snd[0]);
3992*0Sstevel@tonic-gate 
3993*0Sstevel@tonic-gate 		if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
3994*0Sstevel@tonic-gate 			break;
3995*0Sstevel@tonic-gate 
3996*0Sstevel@tonic-gate 		snd_ptr = &snd[0];
3997*0Sstevel@tonic-gate 
3998*0Sstevel@tonic-gate 		while (cpy_rqst) {
3999*0Sstevel@tonic-gate 			(void) printf(
4000*0Sstevel@tonic-gate #ifdef _LP64
4001*0Sstevel@tonic-gate 			    "sfv_fd=%d\tsfv_flag=0x%x\t"
4002*0Sstevel@tonic-gate 			    "sfv_off=%ld\tsfv_len=%lu\n",
4003*0Sstevel@tonic-gate #else
4004*0Sstevel@tonic-gate 			    "sfv_fd=%d\tsfv_flag=0x%x\t"
4005*0Sstevel@tonic-gate 			    "sfv_off=%lld\tsfv_len=%lu\n",
4006*0Sstevel@tonic-gate #endif
4007*0Sstevel@tonic-gate 			    snd_ptr->sfv_fd,
4008*0Sstevel@tonic-gate 			    snd_ptr->sfv_flag,
4009*0Sstevel@tonic-gate 			    snd_ptr->sfv_off,
4010*0Sstevel@tonic-gate 			    (ulong_t)snd_ptr->sfv_len);
4011*0Sstevel@tonic-gate 
4012*0Sstevel@tonic-gate 			if (snd_ptr->sfv_fd == SFV_FD_SELF &&
4013*0Sstevel@tonic-gate 			    prismember(&writefd, fd)) {
4014*0Sstevel@tonic-gate 				showbuffer(pri, (long)snd_ptr->sfv_off,
4015*0Sstevel@tonic-gate 					    (long)snd_ptr->sfv_len);
4016*0Sstevel@tonic-gate 			}
4017*0Sstevel@tonic-gate 
4018*0Sstevel@tonic-gate 			cpy_rqst -= sizeof (snd[0]);
4019*0Sstevel@tonic-gate 			snd_ptr++;
4020*0Sstevel@tonic-gate 		}
4021*0Sstevel@tonic-gate 
4022*0Sstevel@tonic-gate 		sndvec += MAX_SNDFL_PRD;
4023*0Sstevel@tonic-gate 	}
4024*0Sstevel@tonic-gate 	Xserialize();
4025*0Sstevel@tonic-gate }
4026*0Sstevel@tonic-gate 
4027*0Sstevel@tonic-gate static void
4028*0Sstevel@tonic-gate show_memcntl_mha(private_t *pri, long offset)
4029*0Sstevel@tonic-gate {
4030*0Sstevel@tonic-gate 	struct memcntl_mha mha;
4031*0Sstevel@tonic-gate 	const char *s = NULL;
4032*0Sstevel@tonic-gate 
4033*0Sstevel@tonic-gate 	if (Pread(Proc, &mha, sizeof (mha), offset) == sizeof (mha)) {
4034*0Sstevel@tonic-gate 		switch (mha.mha_cmd) {
4035*0Sstevel@tonic-gate 		case MHA_MAPSIZE_VA:	    s = "MHA_MAPSIZE_VA";	break;
4036*0Sstevel@tonic-gate 		case MHA_MAPSIZE_BSSBRK:    s = "MHA_MAPSIZE_BSSBRK";	break;
4037*0Sstevel@tonic-gate 		case MHA_MAPSIZE_STACK:	    s = "MHA_MAPSIZE_STACK";	break;
4038*0Sstevel@tonic-gate 		}
4039*0Sstevel@tonic-gate 		if (s)
4040*0Sstevel@tonic-gate 			(void) printf("%s\tmha_cmd=%s mha_flags=0x%x"
4041*0Sstevel@tonic-gate 			    " mha_pagesize=%lu\n",
4042*0Sstevel@tonic-gate 			    pri->pname, s, mha.mha_flags,
4043*0Sstevel@tonic-gate 			    (ulong_t)mha.mha_pagesize);
4044*0Sstevel@tonic-gate 		else
4045*0Sstevel@tonic-gate 			(void) printf("%s\tmha_cmd=0x%.8x mha_flags=0x%x"
4046*0Sstevel@tonic-gate 			    " mha_pagesize=%lu\n",
4047*0Sstevel@tonic-gate 			    pri->pname, mha.mha_cmd, mha.mha_flags,
4048*0Sstevel@tonic-gate 			    (ulong_t)mha.mha_pagesize);
4049*0Sstevel@tonic-gate 	}
4050*0Sstevel@tonic-gate }
4051*0Sstevel@tonic-gate 
4052*0Sstevel@tonic-gate #ifdef _LP64
4053*0Sstevel@tonic-gate 
4054*0Sstevel@tonic-gate static void
4055*0Sstevel@tonic-gate show_memcntl_mha32(private_t *pri, long offset)
4056*0Sstevel@tonic-gate {
4057*0Sstevel@tonic-gate 	struct memcntl_mha32 mha32;
4058*0Sstevel@tonic-gate 	const char *s = NULL;
4059*0Sstevel@tonic-gate 
4060*0Sstevel@tonic-gate 	if (Pread(Proc, &mha32, sizeof (mha32), offset) ==
4061*0Sstevel@tonic-gate 	    sizeof (mha32)) {
4062*0Sstevel@tonic-gate 		switch (mha32.mha_cmd) {
4063*0Sstevel@tonic-gate 		case MHA_MAPSIZE_VA:	    s = "MHA_MAPSIZE_VA";	break;
4064*0Sstevel@tonic-gate 		case MHA_MAPSIZE_BSSBRK:    s = "MHA_MAPSIZE_BSSBRK";	break;
4065*0Sstevel@tonic-gate 		case MHA_MAPSIZE_STACK:	    s = "MHA_MAPSIZE_STACK";	break;
4066*0Sstevel@tonic-gate 		}
4067*0Sstevel@tonic-gate 		if (s)
4068*0Sstevel@tonic-gate 			(void) printf("%s\tmha_cmd=%s mha_flags=0x%x"
4069*0Sstevel@tonic-gate 			    " mha_pagesize=%u\n",
4070*0Sstevel@tonic-gate 			    pri->pname, s, mha32.mha_flags, mha32.mha_pagesize);
4071*0Sstevel@tonic-gate 		else
4072*0Sstevel@tonic-gate 			(void) printf("%s\tmha_cmd=0x%.8x mha_flags=0x%x"
4073*0Sstevel@tonic-gate 			    " mha_pagesize=%u\n",
4074*0Sstevel@tonic-gate 			    pri->pname, mha32.mha_cmd, mha32.mha_flags,
4075*0Sstevel@tonic-gate 			    mha32.mha_pagesize);
4076*0Sstevel@tonic-gate 	}
4077*0Sstevel@tonic-gate }
4078*0Sstevel@tonic-gate 
4079*0Sstevel@tonic-gate #endif	/* _LP64 */
4080*0Sstevel@tonic-gate 
4081*0Sstevel@tonic-gate static void
4082*0Sstevel@tonic-gate show_memcntl(private_t *pri)
4083*0Sstevel@tonic-gate {
4084*0Sstevel@tonic-gate 
4085*0Sstevel@tonic-gate 	if ((int)pri->sys_args[2] != MC_HAT_ADVISE)
4086*0Sstevel@tonic-gate 		return;
4087*0Sstevel@tonic-gate #ifdef _LP64
4088*0Sstevel@tonic-gate 	if (data_model == PR_MODEL_LP64)
4089*0Sstevel@tonic-gate 		show_memcntl_mha(pri, (long)pri->sys_args[3]);
4090*0Sstevel@tonic-gate 	else
4091*0Sstevel@tonic-gate 		show_memcntl_mha32(pri, (long)pri->sys_args[3]);
4092*0Sstevel@tonic-gate #else
4093*0Sstevel@tonic-gate 	show_memcntl_mha(pri, (long)pri->sys_args[3]);
4094*0Sstevel@tonic-gate #endif
4095*0Sstevel@tonic-gate }
4096*0Sstevel@tonic-gate 
4097*0Sstevel@tonic-gate void
4098*0Sstevel@tonic-gate show_ids(private_t *pri, long offset, int count)
4099*0Sstevel@tonic-gate {
4100*0Sstevel@tonic-gate 	id_t buf[MYBUFSIZ / sizeof (id_t)];
4101*0Sstevel@tonic-gate 	id_t *idp;
4102*0Sstevel@tonic-gate 	int serial = (count > MYBUFSIZ / 48);
4103*0Sstevel@tonic-gate 
4104*0Sstevel@tonic-gate 	if (offset == NULL)
4105*0Sstevel@tonic-gate 		return;
4106*0Sstevel@tonic-gate 
4107*0Sstevel@tonic-gate 	/* enter region of lengthy output */
4108*0Sstevel@tonic-gate 	if (serial)
4109*0Sstevel@tonic-gate 		Eserialize();
4110*0Sstevel@tonic-gate 
4111*0Sstevel@tonic-gate 	while (count > 0 && !interrupt) {
4112*0Sstevel@tonic-gate 		ssize_t nb = (count * sizeof (id_t) < MYBUFSIZ)?
4113*0Sstevel@tonic-gate 			count * sizeof (id_t) : MYBUFSIZ;
4114*0Sstevel@tonic-gate 
4115*0Sstevel@tonic-gate 		if ((nb = Pread(Proc, &buf[0], (size_t)nb, offset)) < 0 ||
4116*0Sstevel@tonic-gate 		    nb < sizeof (id_t))
4117*0Sstevel@tonic-gate 			break;
4118*0Sstevel@tonic-gate 
4119*0Sstevel@tonic-gate 		idp = buf;
4120*0Sstevel@tonic-gate 		while (!interrupt && nb >= sizeof (id_t)) {
4121*0Sstevel@tonic-gate 			(void) printf("%s\t%8d\n", pri->pname, (int)*idp);
4122*0Sstevel@tonic-gate 			offset += sizeof (id_t);
4123*0Sstevel@tonic-gate 			nb -= sizeof (id_t);
4124*0Sstevel@tonic-gate 			idp++;
4125*0Sstevel@tonic-gate 			count--;
4126*0Sstevel@tonic-gate 		}
4127*0Sstevel@tonic-gate 	}
4128*0Sstevel@tonic-gate 
4129*0Sstevel@tonic-gate 	/* exit region of lengthy output */
4130*0Sstevel@tonic-gate 	if (serial)
4131*0Sstevel@tonic-gate 		Xserialize();
4132*0Sstevel@tonic-gate }
4133*0Sstevel@tonic-gate 
4134*0Sstevel@tonic-gate void
4135*0Sstevel@tonic-gate show_ntp_gettime(private_t *pri)
4136*0Sstevel@tonic-gate {
4137*0Sstevel@tonic-gate 	struct ntptimeval ntv;
4138*0Sstevel@tonic-gate 	long offset;
4139*0Sstevel@tonic-gate 
4140*0Sstevel@tonic-gate 	if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == NULL)
4141*0Sstevel@tonic-gate 		return;
4142*0Sstevel@tonic-gate 
4143*0Sstevel@tonic-gate 	if (data_model == PR_MODEL_NATIVE) {
4144*0Sstevel@tonic-gate 		if (Pread(Proc, &ntv, sizeof (ntv), offset)
4145*0Sstevel@tonic-gate 		    != sizeof (ntv))
4146*0Sstevel@tonic-gate 			return;
4147*0Sstevel@tonic-gate 	} else {
4148*0Sstevel@tonic-gate 		struct ntptimeval32 ntv32;
4149*0Sstevel@tonic-gate 
4150*0Sstevel@tonic-gate 		if (Pread(Proc, &ntv32, sizeof (ntv32), offset)
4151*0Sstevel@tonic-gate 		    != sizeof (ntv32))
4152*0Sstevel@tonic-gate 			return;
4153*0Sstevel@tonic-gate 
4154*0Sstevel@tonic-gate 		TIMEVAL32_TO_TIMEVAL(&ntv.time, &ntv32.time);
4155*0Sstevel@tonic-gate 		ntv.maxerror = ntv32.maxerror;
4156*0Sstevel@tonic-gate 		ntv.esterror = ntv32.esterror;
4157*0Sstevel@tonic-gate 	}
4158*0Sstevel@tonic-gate 
4159*0Sstevel@tonic-gate 	(void) printf("\ttime:     %ld.%6.6ld sec\n",
4160*0Sstevel@tonic-gate 	    ntv.time.tv_sec, ntv.time.tv_usec);
4161*0Sstevel@tonic-gate 	(void) printf("\tmaxerror: %11d usec\n", ntv.maxerror);
4162*0Sstevel@tonic-gate 	(void) printf("\testerror: %11d usec\n", ntv.esterror);
4163*0Sstevel@tonic-gate }
4164*0Sstevel@tonic-gate 
4165*0Sstevel@tonic-gate static char *
4166*0Sstevel@tonic-gate get_timex_modes(private_t *pri, uint32_t val)
4167*0Sstevel@tonic-gate {
4168*0Sstevel@tonic-gate 	char *str = pri->code_buf;
4169*0Sstevel@tonic-gate 	size_t used = 0;
4170*0Sstevel@tonic-gate 
4171*0Sstevel@tonic-gate 	*str = '\0';
4172*0Sstevel@tonic-gate 	if (val & MOD_OFFSET)
4173*0Sstevel@tonic-gate 		used = strlcat(str, "|MOD_OFFSET", sizeof (pri->code_buf));
4174*0Sstevel@tonic-gate 	if (val & MOD_FREQUENCY)
4175*0Sstevel@tonic-gate 		used = strlcat(str, "|MOD_FREQUENCY", sizeof (pri->code_buf));
4176*0Sstevel@tonic-gate 	if (val & MOD_MAXERROR)
4177*0Sstevel@tonic-gate 		used = strlcat(str, "|MOD_MAXERROR", sizeof (pri->code_buf));
4178*0Sstevel@tonic-gate 	if (val & MOD_ESTERROR)
4179*0Sstevel@tonic-gate 		used = strlcat(str, "|MOD_ESTERROR", sizeof (pri->code_buf));
4180*0Sstevel@tonic-gate 	if (val & MOD_STATUS)
4181*0Sstevel@tonic-gate 		used = strlcat(str, "|MOD_STATUS", sizeof (pri->code_buf));
4182*0Sstevel@tonic-gate 	if (val & MOD_TIMECONST)
4183*0Sstevel@tonic-gate 		used = strlcat(str, "|MOD_TIMECONST", sizeof (pri->code_buf));
4184*0Sstevel@tonic-gate 	if (val & MOD_CLKB)
4185*0Sstevel@tonic-gate 		used = strlcat(str, "|MOD_CLKB", sizeof (pri->code_buf));
4186*0Sstevel@tonic-gate 	if (val & MOD_CLKA)
4187*0Sstevel@tonic-gate 		used = strlcat(str, "|MOD_CLKA", sizeof (pri->code_buf));
4188*0Sstevel@tonic-gate 
4189*0Sstevel@tonic-gate 	if (used == 0 || used >= sizeof (pri->code_buf))
4190*0Sstevel@tonic-gate 		(void) snprintf(str, sizeof (pri->code_buf), " 0x%.4x", val);
4191*0Sstevel@tonic-gate 
4192*0Sstevel@tonic-gate 	return (str + 1);
4193*0Sstevel@tonic-gate }
4194*0Sstevel@tonic-gate 
4195*0Sstevel@tonic-gate static char *
4196*0Sstevel@tonic-gate get_timex_status(private_t *pri, int32_t val)
4197*0Sstevel@tonic-gate {
4198*0Sstevel@tonic-gate 	char *str = pri->code_buf;
4199*0Sstevel@tonic-gate 	size_t used = 0;
4200*0Sstevel@tonic-gate 
4201*0Sstevel@tonic-gate 	*str = '\0';
4202*0Sstevel@tonic-gate 	if (val & STA_PLL)
4203*0Sstevel@tonic-gate 		used = strlcat(str, "|STA_PLL", sizeof (pri->code_buf));
4204*0Sstevel@tonic-gate 	if (val & STA_PPSFREQ)
4205*0Sstevel@tonic-gate 		used = strlcat(str, "|STA_PPSFREQ", sizeof (pri->code_buf));
4206*0Sstevel@tonic-gate 	if (val & STA_PPSTIME)
4207*0Sstevel@tonic-gate 		used = strlcat(str, "|STA_PPSTIME", sizeof (pri->code_buf));
4208*0Sstevel@tonic-gate 	if (val & STA_FLL)
4209*0Sstevel@tonic-gate 		used = strlcat(str, "|STA_FLL", sizeof (pri->code_buf));
4210*0Sstevel@tonic-gate 
4211*0Sstevel@tonic-gate 	if (val & STA_INS)
4212*0Sstevel@tonic-gate 		used = strlcat(str, "|STA_INS", sizeof (pri->code_buf));
4213*0Sstevel@tonic-gate 	if (val & STA_DEL)
4214*0Sstevel@tonic-gate 		used = strlcat(str, "|STA_DEL", sizeof (pri->code_buf));
4215*0Sstevel@tonic-gate 	if (val & STA_UNSYNC)
4216*0Sstevel@tonic-gate 		used = strlcat(str, "|STA_UNSYNC", sizeof (pri->code_buf));
4217*0Sstevel@tonic-gate 	if (val & STA_FREQHOLD)
4218*0Sstevel@tonic-gate 		used = strlcat(str, "|STA_FREQHOLD", sizeof (pri->code_buf));
4219*0Sstevel@tonic-gate 
4220*0Sstevel@tonic-gate 	if (val & STA_PPSSIGNAL)
4221*0Sstevel@tonic-gate 		used = strlcat(str, "|STA_PPSSIGNAL", sizeof (pri->code_buf));
4222*0Sstevel@tonic-gate 	if (val & STA_PPSJITTER)
4223*0Sstevel@tonic-gate 		used = strlcat(str, "|STA_PPSJITTER", sizeof (pri->code_buf));
4224*0Sstevel@tonic-gate 	if (val & STA_PPSWANDER)
4225*0Sstevel@tonic-gate 		used = strlcat(str, "|STA_PPSWANDER", sizeof (pri->code_buf));
4226*0Sstevel@tonic-gate 	if (val & STA_PPSERROR)
4227*0Sstevel@tonic-gate 		used = strlcat(str, "|STA_PPSERROR", sizeof (pri->code_buf));
4228*0Sstevel@tonic-gate 
4229*0Sstevel@tonic-gate 	if (val & STA_CLOCKERR)
4230*0Sstevel@tonic-gate 		used = strlcat(str, "|STA_CLOCKERR", sizeof (pri->code_buf));
4231*0Sstevel@tonic-gate 
4232*0Sstevel@tonic-gate 	if (used == 0 || used >= sizeof (pri->code_buf))
4233*0Sstevel@tonic-gate 		(void) snprintf(str, sizeof (pri->code_buf), " 0x%.4x", val);
4234*0Sstevel@tonic-gate 
4235*0Sstevel@tonic-gate 	return (str + 1);
4236*0Sstevel@tonic-gate }
4237*0Sstevel@tonic-gate 
4238*0Sstevel@tonic-gate void
4239*0Sstevel@tonic-gate show_ntp_adjtime(private_t *pri)
4240*0Sstevel@tonic-gate {
4241*0Sstevel@tonic-gate 	struct timex timex;
4242*0Sstevel@tonic-gate 	long offset;
4243*0Sstevel@tonic-gate 
4244*0Sstevel@tonic-gate 	if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == NULL)
4245*0Sstevel@tonic-gate 		return;
4246*0Sstevel@tonic-gate 
4247*0Sstevel@tonic-gate 	if (Pread(Proc, &timex, sizeof (timex), offset) != sizeof (timex))
4248*0Sstevel@tonic-gate 		return;
4249*0Sstevel@tonic-gate 
4250*0Sstevel@tonic-gate 	(void) printf("\tmodes:     %s\n", get_timex_modes(pri, timex.modes));
4251*0Sstevel@tonic-gate 	(void) printf("\toffset:    %11d usec\n", timex.offset);
4252*0Sstevel@tonic-gate 	(void) printf("\tfreq:      %11d scaled ppm\n", timex.freq);
4253*0Sstevel@tonic-gate 	(void) printf("\tmaxerror:  %11d usec\n", timex.maxerror);
4254*0Sstevel@tonic-gate 	(void) printf("\testerror:  %11d usec\n", timex.esterror);
4255*0Sstevel@tonic-gate 	(void) printf("\tstatus:    %s\n", get_timex_status(pri, timex.status));
4256*0Sstevel@tonic-gate 	(void) printf("\tconstant:  %11d\n", timex.constant);
4257*0Sstevel@tonic-gate 	(void) printf("\tprecision: %11d usec\n", timex.precision);
4258*0Sstevel@tonic-gate 	(void) printf("\ttolerance: %11d scaled ppm\n", timex.tolerance);
4259*0Sstevel@tonic-gate 	(void) printf("\tppsfreq:   %11d scaled ppm\n", timex.ppsfreq);
4260*0Sstevel@tonic-gate 	(void) printf("\tjitter:    %11d usec\n", timex.jitter);
4261*0Sstevel@tonic-gate 	(void) printf("\tshift:     %11d sec\n", timex.shift);
4262*0Sstevel@tonic-gate 	(void) printf("\tstabil:    %11d scaled ppm\n", timex.stabil);
4263*0Sstevel@tonic-gate 	(void) printf("\tjitcnt:    %11d\n", timex.jitcnt);
4264*0Sstevel@tonic-gate 	(void) printf("\tcalcnt:    %11d\n", timex.calcnt);
4265*0Sstevel@tonic-gate 	(void) printf("\terrcnt:    %11d\n", timex.errcnt);
4266*0Sstevel@tonic-gate 	(void) printf("\tstbcnt:    %11d\n", timex.stbcnt);
4267*0Sstevel@tonic-gate }
4268*0Sstevel@tonic-gate 
4269*0Sstevel@tonic-gate void
4270*0Sstevel@tonic-gate show_getrusage(long offset)
4271*0Sstevel@tonic-gate {
4272*0Sstevel@tonic-gate 	struct rusage r;
4273*0Sstevel@tonic-gate 	if (Pread(Proc, &r, sizeof (r), offset) != sizeof (r))
4274*0Sstevel@tonic-gate 		return;
4275*0Sstevel@tonic-gate 	(void) printf("\t       user time: %ld.%6.6ld sec\n",
4276*0Sstevel@tonic-gate 	    r.ru_utime.tv_sec,
4277*0Sstevel@tonic-gate 	    r.ru_utime.tv_usec);
4278*0Sstevel@tonic-gate 	(void) printf("\t     system time: %ld.%6.6ld sec\n",
4279*0Sstevel@tonic-gate 	    r.ru_stime.tv_sec,
4280*0Sstevel@tonic-gate 	    r.ru_stime.tv_usec);
4281*0Sstevel@tonic-gate 	(void) printf("\t         max rss: <unimpl> %ld\n",
4282*0Sstevel@tonic-gate 	    r.ru_maxrss);
4283*0Sstevel@tonic-gate 	(void) printf("\t     shared data: <unimpl> %ld\n",
4284*0Sstevel@tonic-gate 	    r.ru_ixrss);
4285*0Sstevel@tonic-gate 	(void) printf("\t   unshared data: <unimpl> %ld\n",
4286*0Sstevel@tonic-gate 	    r.ru_idrss);
4287*0Sstevel@tonic-gate 	(void) printf("\t  unshared stack: <unimpl> %ld\n",
4288*0Sstevel@tonic-gate 	    r.ru_isrss);
4289*0Sstevel@tonic-gate 	(void) printf("\t    minor faults: %ld\n",
4290*0Sstevel@tonic-gate 	    r.ru_minflt);
4291*0Sstevel@tonic-gate 	(void) printf("\t    major faults: %ld\n",
4292*0Sstevel@tonic-gate 	    r.ru_majflt);
4293*0Sstevel@tonic-gate 	(void) printf("\t      # of swaps: %ld\n",
4294*0Sstevel@tonic-gate 	    r.ru_nswap);
4295*0Sstevel@tonic-gate 	(void) printf("\t  blocked inputs: %ld\n",
4296*0Sstevel@tonic-gate 	    r.ru_inblock);
4297*0Sstevel@tonic-gate 	(void) printf("\t blocked outputs: %ld\n",
4298*0Sstevel@tonic-gate 	    r.ru_oublock);
4299*0Sstevel@tonic-gate 	(void) printf("\t       msgs sent: %ld\n",
4300*0Sstevel@tonic-gate 	    r.ru_msgsnd);
4301*0Sstevel@tonic-gate 	(void) printf("\t      msgs rcv'd: %ld\n",
4302*0Sstevel@tonic-gate 	    r.ru_msgrcv);
4303*0Sstevel@tonic-gate 	(void) printf("\t   signals rcv'd: %ld\n",
4304*0Sstevel@tonic-gate 	    r.ru_nsignals);
4305*0Sstevel@tonic-gate 	(void) printf("\tvol cntxt swtchs: %ld\n",
4306*0Sstevel@tonic-gate 	    r.ru_nvcsw);
4307*0Sstevel@tonic-gate 	(void) printf("\tinv cntxt swtchs: %ld\n",
4308*0Sstevel@tonic-gate 	    r.ru_nivcsw);
4309*0Sstevel@tonic-gate }
4310*0Sstevel@tonic-gate 
4311*0Sstevel@tonic-gate #ifdef _LP64
4312*0Sstevel@tonic-gate void
4313*0Sstevel@tonic-gate show_getrusage32(long offset)
4314*0Sstevel@tonic-gate {
4315*0Sstevel@tonic-gate 	struct rusage32 r;
4316*0Sstevel@tonic-gate 	if (Pread(Proc, &r, sizeof (r), offset) != sizeof (r))
4317*0Sstevel@tonic-gate 		return;
4318*0Sstevel@tonic-gate 	(void) printf("\t       user time: %d.%6.6d sec\n",
4319*0Sstevel@tonic-gate 	    r.ru_utime.tv_sec,
4320*0Sstevel@tonic-gate 	    r.ru_utime.tv_usec);
4321*0Sstevel@tonic-gate 	(void) printf("\t     system time: %d.%6.6d sec\n",
4322*0Sstevel@tonic-gate 	    r.ru_stime.tv_sec,
4323*0Sstevel@tonic-gate 	    r.ru_stime.tv_usec);
4324*0Sstevel@tonic-gate 	(void) printf("\t         max rss: <unimpl> %d\n",
4325*0Sstevel@tonic-gate 	    r.ru_maxrss);
4326*0Sstevel@tonic-gate 	(void) printf("\t     shared data: <unimpl> %d\n",
4327*0Sstevel@tonic-gate 	    r.ru_ixrss);
4328*0Sstevel@tonic-gate 	(void) printf("\t   unshared data: <unimpl> %d\n",
4329*0Sstevel@tonic-gate 	    r.ru_idrss);
4330*0Sstevel@tonic-gate 	(void) printf("\t  unshared stack: <unimpl> %d\n",
4331*0Sstevel@tonic-gate 	    r.ru_isrss);
4332*0Sstevel@tonic-gate 	(void) printf("\t    minor faults: %d\n",
4333*0Sstevel@tonic-gate 	    r.ru_minflt);
4334*0Sstevel@tonic-gate 	(void) printf("\t    major faults: %d\n",
4335*0Sstevel@tonic-gate 	    r.ru_majflt);
4336*0Sstevel@tonic-gate 	(void) printf("\t      # of swaps: %d\n",
4337*0Sstevel@tonic-gate 	    r.ru_nswap);
4338*0Sstevel@tonic-gate 	(void) printf("\t  blocked inputs: %d\n",
4339*0Sstevel@tonic-gate 	    r.ru_inblock);
4340*0Sstevel@tonic-gate 	(void) printf("\t blocked outputs: %d\n",
4341*0Sstevel@tonic-gate 	    r.ru_oublock);
4342*0Sstevel@tonic-gate 	(void) printf("\t       msgs sent: %d\n",
4343*0Sstevel@tonic-gate 	    r.ru_msgsnd);
4344*0Sstevel@tonic-gate 	(void) printf("\t      msgs rcv'd: %d\n",
4345*0Sstevel@tonic-gate 	    r.ru_msgrcv);
4346*0Sstevel@tonic-gate 	(void) printf("\t   signals rcv'd: %d\n",
4347*0Sstevel@tonic-gate 	    r.ru_nsignals);
4348*0Sstevel@tonic-gate 	(void) printf("\tvol cntxt swtchs: %d\n",
4349*0Sstevel@tonic-gate 	    r.ru_nvcsw);
4350*0Sstevel@tonic-gate 	(void) printf("\tinv cntxt swtchs: %d\n",
4351*0Sstevel@tonic-gate 	    r.ru_nivcsw);
4352*0Sstevel@tonic-gate }
4353*0Sstevel@tonic-gate #endif
4354*0Sstevel@tonic-gate 
4355*0Sstevel@tonic-gate /* expound verbosely upon syscall arguments */
4356*0Sstevel@tonic-gate /*ARGSUSED*/
4357*0Sstevel@tonic-gate void
4358*0Sstevel@tonic-gate expound(private_t *pri, long r0, int raw)
4359*0Sstevel@tonic-gate {
4360*0Sstevel@tonic-gate 	const lwpstatus_t *Lsp = pri->lwpstat;
4361*0Sstevel@tonic-gate 	int lp64 = (data_model == PR_MODEL_LP64);
4362*0Sstevel@tonic-gate 	int what = Lsp->pr_what;
4363*0Sstevel@tonic-gate 	int err = pri->Errno;		/* don't display output parameters */
4364*0Sstevel@tonic-gate 					/* for a failed system call */
4365*0Sstevel@tonic-gate #ifndef _LP64
4366*0Sstevel@tonic-gate 	/* We are a 32-bit truss; we can't grok a 64-bit process */
4367*0Sstevel@tonic-gate 	if (lp64)
4368*0Sstevel@tonic-gate 		return;
4369*0Sstevel@tonic-gate #endif
4370*0Sstevel@tonic-gate 	/* for reporting sleeping system calls */
4371*0Sstevel@tonic-gate 	if (what == 0 && (Lsp->pr_flags & (PR_ASLEEP|PR_VFORKP)))
4372*0Sstevel@tonic-gate 		what = Lsp->pr_syscall;
4373*0Sstevel@tonic-gate 
4374*0Sstevel@tonic-gate 	switch (what) {
4375*0Sstevel@tonic-gate 	case SYS_utime:
4376*0Sstevel@tonic-gate 		show_utime(pri);
4377*0Sstevel@tonic-gate 		break;
4378*0Sstevel@tonic-gate 	case SYS_utimes:
4379*0Sstevel@tonic-gate 		show_utimes(pri);
4380*0Sstevel@tonic-gate 		break;
4381*0Sstevel@tonic-gate 	case SYS_gettimeofday:
4382*0Sstevel@tonic-gate 		if (!err)
4383*0Sstevel@tonic-gate 			show_timeofday(pri);
4384*0Sstevel@tonic-gate 		break;
4385*0Sstevel@tonic-gate 	case SYS_getitimer:
4386*0Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 1)
4387*0Sstevel@tonic-gate 			show_itimerval(pri, (long)pri->sys_args[1],
4388*0Sstevel@tonic-gate 				" value");
4389*0Sstevel@tonic-gate 		break;
4390*0Sstevel@tonic-gate 	case SYS_setitimer:
4391*0Sstevel@tonic-gate 		if (pri->sys_nargs > 1)
4392*0Sstevel@tonic-gate 			show_itimerval(pri, (long)pri->sys_args[1],
4393*0Sstevel@tonic-gate 				" value");
4394*0Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 2)
4395*0Sstevel@tonic-gate 			show_itimerval(pri, (long)pri->sys_args[2],
4396*0Sstevel@tonic-gate 				"ovalue");
4397*0Sstevel@tonic-gate 		break;
4398*0Sstevel@tonic-gate 	case SYS_stime:
4399*0Sstevel@tonic-gate 		show_stime(pri);
4400*0Sstevel@tonic-gate 		break;
4401*0Sstevel@tonic-gate 	case SYS_times:
4402*0Sstevel@tonic-gate 		if (!err)
4403*0Sstevel@tonic-gate 			show_times(pri);
4404*0Sstevel@tonic-gate 		break;
4405*0Sstevel@tonic-gate 	case SYS_utssys:
4406*0Sstevel@tonic-gate 		if (err)
4407*0Sstevel@tonic-gate 			break;
4408*0Sstevel@tonic-gate #ifdef _LP64
4409*0Sstevel@tonic-gate 		if (lp64)
4410*0Sstevel@tonic-gate 			show_utssys(pri, r0);
4411*0Sstevel@tonic-gate 		else
4412*0Sstevel@tonic-gate 			show_utssys32(pri, r0);
4413*0Sstevel@tonic-gate #else
4414*0Sstevel@tonic-gate 		show_utssys(pri, r0);
4415*0Sstevel@tonic-gate #endif
4416*0Sstevel@tonic-gate 		break;
4417*0Sstevel@tonic-gate 	case SYS_ioctl:
4418*0Sstevel@tonic-gate 		if (pri->sys_nargs >= 3) /* each case must decide for itself */
4419*0Sstevel@tonic-gate 			show_ioctl(pri, pri->sys_args[1],
4420*0Sstevel@tonic-gate 				(long)pri->sys_args[2]);
4421*0Sstevel@tonic-gate 		break;
4422*0Sstevel@tonic-gate 	case SYS_stat:
4423*0Sstevel@tonic-gate 	case SYS_fstat:
4424*0Sstevel@tonic-gate 	case SYS_lstat:
4425*0Sstevel@tonic-gate 		if (!err && pri->sys_nargs >= 2)
4426*0Sstevel@tonic-gate 			show_stat(pri, (long)pri->sys_args[1]);
4427*0Sstevel@tonic-gate 		break;
4428*0Sstevel@tonic-gate 	case SYS_stat64:
4429*0Sstevel@tonic-gate 	case SYS_fstat64:
4430*0Sstevel@tonic-gate 	case SYS_lstat64:
4431*0Sstevel@tonic-gate 		if (!err && pri->sys_nargs >= 2)
4432*0Sstevel@tonic-gate 			show_stat64_32(pri, (long)pri->sys_args[1]);
4433*0Sstevel@tonic-gate 		break;
4434*0Sstevel@tonic-gate 	case SYS_fsat:
4435*0Sstevel@tonic-gate 		/*
4436*0Sstevel@tonic-gate 		 * subcodes for fstatat() and fstatat64().
4437*0Sstevel@tonic-gate 		 */
4438*0Sstevel@tonic-gate 		if (!err && pri->sys_nargs >= 4) {
4439*0Sstevel@tonic-gate 			if (pri->sys_args[0] == 3)
4440*0Sstevel@tonic-gate 				show_statat(pri, (long)pri->sys_args[3]);
4441*0Sstevel@tonic-gate 			else if (pri->sys_args[0] == 2)
4442*0Sstevel@tonic-gate 				show_stat64_32(pri, (long)pri->sys_args[3]);
4443*0Sstevel@tonic-gate 		}
4444*0Sstevel@tonic-gate 		break;
4445*0Sstevel@tonic-gate 	case SYS_xstat:
4446*0Sstevel@tonic-gate 	case SYS_fxstat:
4447*0Sstevel@tonic-gate 	case SYS_lxstat:
4448*0Sstevel@tonic-gate 		if (!err && pri->sys_nargs >= 3)
4449*0Sstevel@tonic-gate 			show_xstat(pri, (int)pri->sys_args[0],
4450*0Sstevel@tonic-gate 				(long)pri->sys_args[2]);
4451*0Sstevel@tonic-gate 		break;
4452*0Sstevel@tonic-gate 	case SYS_statvfs:
4453*0Sstevel@tonic-gate 	case SYS_fstatvfs:
4454*0Sstevel@tonic-gate 		if (err)
4455*0Sstevel@tonic-gate 			break;
4456*0Sstevel@tonic-gate #ifdef _LP64
4457*0Sstevel@tonic-gate 		if (!lp64) {
4458*0Sstevel@tonic-gate 			show_statvfs32(pri);
4459*0Sstevel@tonic-gate 			break;
4460*0Sstevel@tonic-gate 		}
4461*0Sstevel@tonic-gate #endif
4462*0Sstevel@tonic-gate 		show_statvfs(pri);
4463*0Sstevel@tonic-gate 		break;
4464*0Sstevel@tonic-gate 	case SYS_statvfs64:
4465*0Sstevel@tonic-gate 	case SYS_fstatvfs64:
4466*0Sstevel@tonic-gate 		if (err)
4467*0Sstevel@tonic-gate 			break;
4468*0Sstevel@tonic-gate 		show_statvfs64(pri);
4469*0Sstevel@tonic-gate 		break;
4470*0Sstevel@tonic-gate 	case SYS_statfs:
4471*0Sstevel@tonic-gate 	case SYS_fstatfs:
4472*0Sstevel@tonic-gate 		if (err)
4473*0Sstevel@tonic-gate 			break;
4474*0Sstevel@tonic-gate #ifdef _LP64
4475*0Sstevel@tonic-gate 		if (lp64)
4476*0Sstevel@tonic-gate 			show_statfs(pri);
4477*0Sstevel@tonic-gate 		else
4478*0Sstevel@tonic-gate 			show_statfs32(pri);
4479*0Sstevel@tonic-gate #else
4480*0Sstevel@tonic-gate 		show_statfs(pri);
4481*0Sstevel@tonic-gate #endif
4482*0Sstevel@tonic-gate 		break;
4483*0Sstevel@tonic-gate 	case SYS_fcntl:
4484*0Sstevel@tonic-gate 		show_fcntl(pri);
4485*0Sstevel@tonic-gate 		break;
4486*0Sstevel@tonic-gate 	case SYS_msgsys:
4487*0Sstevel@tonic-gate 		show_msgsys(pri, r0); /* each case must decide for itself */
4488*0Sstevel@tonic-gate 		break;
4489*0Sstevel@tonic-gate 	case SYS_semsys:
4490*0Sstevel@tonic-gate 		show_semsys(pri);	/* each case must decide for itself */
4491*0Sstevel@tonic-gate 		break;
4492*0Sstevel@tonic-gate 	case SYS_shmsys:
4493*0Sstevel@tonic-gate 		show_shmsys(pri);	/* each case must decide for itself */
4494*0Sstevel@tonic-gate 		break;
4495*0Sstevel@tonic-gate 	case SYS_getdents:
4496*0Sstevel@tonic-gate 		if (err || pri->sys_nargs <= 1 || r0 <= 0)
4497*0Sstevel@tonic-gate 			break;
4498*0Sstevel@tonic-gate #ifdef _LP64
4499*0Sstevel@tonic-gate 		if (!lp64) {
4500*0Sstevel@tonic-gate 			show_dents32(pri, (long)pri->sys_args[1], r0);
4501*0Sstevel@tonic-gate 			break;
4502*0Sstevel@tonic-gate 		}
4503*0Sstevel@tonic-gate 		/* FALLTHROUGH */
4504*0Sstevel@tonic-gate #else
4505*0Sstevel@tonic-gate 		show_dents32(pri, (long)pri->sys_args[1], r0);
4506*0Sstevel@tonic-gate 		break;
4507*0Sstevel@tonic-gate #endif
4508*0Sstevel@tonic-gate 	case SYS_getdents64:
4509*0Sstevel@tonic-gate 		if (err || pri->sys_nargs <= 1 || r0 <= 0)
4510*0Sstevel@tonic-gate 			break;
4511*0Sstevel@tonic-gate 		show_dents64(pri, (long)pri->sys_args[1], r0);
4512*0Sstevel@tonic-gate 		break;
4513*0Sstevel@tonic-gate 	case SYS_getmsg:
4514*0Sstevel@tonic-gate 		show_gp_msg(pri, what);
4515*0Sstevel@tonic-gate 		if (pri->sys_nargs > 3)
4516*0Sstevel@tonic-gate 			show_hhex_int(pri, (long)pri->sys_args[3], "flags");
4517*0Sstevel@tonic-gate 		break;
4518*0Sstevel@tonic-gate 	case SYS_getpmsg:
4519*0Sstevel@tonic-gate 		show_gp_msg(pri, what);
4520*0Sstevel@tonic-gate 		if (pri->sys_nargs > 3)
4521*0Sstevel@tonic-gate 			show_hhex_int(pri, (long)pri->sys_args[3], "band");
4522*0Sstevel@tonic-gate 		if (pri->sys_nargs > 4)
4523*0Sstevel@tonic-gate 			show_hhex_int(pri, (long)pri->sys_args[4], "flags");
4524*0Sstevel@tonic-gate 		break;
4525*0Sstevel@tonic-gate 	case SYS_putmsg:
4526*0Sstevel@tonic-gate 	case SYS_putpmsg:
4527*0Sstevel@tonic-gate 		show_gp_msg(pri, what);
4528*0Sstevel@tonic-gate 		break;
4529*0Sstevel@tonic-gate 	case SYS_poll:
4530*0Sstevel@tonic-gate 		show_poll(pri);
4531*0Sstevel@tonic-gate 		break;
4532*0Sstevel@tonic-gate 	case SYS_pollsys:
4533*0Sstevel@tonic-gate 		show_pollsys(pri);
4534*0Sstevel@tonic-gate 		break;
4535*0Sstevel@tonic-gate 	case SYS_setgroups:
4536*0Sstevel@tonic-gate 		if (pri->sys_nargs > 1 && (r0 = pri->sys_args[0]) > 0)
4537*0Sstevel@tonic-gate 			show_groups(pri, (long)pri->sys_args[1], r0);
4538*0Sstevel@tonic-gate 		break;
4539*0Sstevel@tonic-gate 	case SYS_getgroups:
4540*0Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 1 && pri->sys_args[0] > 0)
4541*0Sstevel@tonic-gate 			show_groups(pri, (long)pri->sys_args[1], r0);
4542*0Sstevel@tonic-gate 		break;
4543*0Sstevel@tonic-gate 	case SYS_sigprocmask:
4544*0Sstevel@tonic-gate 		if (pri->sys_nargs > 1)
4545*0Sstevel@tonic-gate 			show_sigset(pri, (long)pri->sys_args[1], " set");
4546*0Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 2)
4547*0Sstevel@tonic-gate 			show_sigset(pri, (long)pri->sys_args[2], "oset");
4548*0Sstevel@tonic-gate 		break;
4549*0Sstevel@tonic-gate 	case SYS_sigsuspend:
4550*0Sstevel@tonic-gate 	case SYS_sigtimedwait:
4551*0Sstevel@tonic-gate 		if (pri->sys_nargs > 0)
4552*0Sstevel@tonic-gate 			show_sigset(pri, (long)pri->sys_args[0], "sigmask");
4553*0Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 1)
4554*0Sstevel@tonic-gate 			show_siginfo(pri, (long)pri->sys_args[1]);
4555*0Sstevel@tonic-gate 		if (pri->sys_nargs > 2)
4556*0Sstevel@tonic-gate 			show_timestruc(pri, (long)pri->sys_args[2], "timeout");
4557*0Sstevel@tonic-gate 		break;
4558*0Sstevel@tonic-gate 	case SYS_sigaltstack:
4559*0Sstevel@tonic-gate 		if (pri->sys_nargs > 0)
4560*0Sstevel@tonic-gate 			show_sigaltstack(pri, (long)pri->sys_args[0],
4561*0Sstevel@tonic-gate 				"new");
4562*0Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 1)
4563*0Sstevel@tonic-gate 			show_sigaltstack(pri, (long)pri->sys_args[1],
4564*0Sstevel@tonic-gate 				"old");
4565*0Sstevel@tonic-gate 		break;
4566*0Sstevel@tonic-gate 	case SYS_sigaction:
4567*0Sstevel@tonic-gate 		if (pri->sys_nargs > 1)
4568*0Sstevel@tonic-gate 			show_sigaction(pri, (long)pri->sys_args[1],
4569*0Sstevel@tonic-gate 				"new", NULL);
4570*0Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 2)
4571*0Sstevel@tonic-gate 			show_sigaction(pri, (long)pri->sys_args[2],
4572*0Sstevel@tonic-gate 				"old", r0);
4573*0Sstevel@tonic-gate 		break;
4574*0Sstevel@tonic-gate 	case SYS_sigpending:
4575*0Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 1)
4576*0Sstevel@tonic-gate 			show_sigset(pri, (long)pri->sys_args[1], "sigmask");
4577*0Sstevel@tonic-gate 		break;
4578*0Sstevel@tonic-gate 	case SYS_waitsys:
4579*0Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 2)
4580*0Sstevel@tonic-gate 			show_siginfo(pri, (long)pri->sys_args[2]);
4581*0Sstevel@tonic-gate 		break;
4582*0Sstevel@tonic-gate 	case SYS_sigsendsys:
4583*0Sstevel@tonic-gate 		if (pri->sys_nargs > 0)
4584*0Sstevel@tonic-gate 			show_procset(pri, (long)pri->sys_args[0]);
4585*0Sstevel@tonic-gate 		break;
4586*0Sstevel@tonic-gate 	case SYS_priocntlsys:
4587*0Sstevel@tonic-gate 		if (pri->sys_nargs > 1)
4588*0Sstevel@tonic-gate 			show_procset(pri, (long)pri->sys_args[1]);
4589*0Sstevel@tonic-gate 		break;
4590*0Sstevel@tonic-gate 	case SYS_mincore:
4591*0Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 2)
4592*0Sstevel@tonic-gate 			show_bool(pri, (long)pri->sys_args[2],
4593*0Sstevel@tonic-gate 				(pri->sys_args[1] + pagesize - 1) / pagesize);
4594*0Sstevel@tonic-gate 		break;
4595*0Sstevel@tonic-gate 	case SYS_readv:
4596*0Sstevel@tonic-gate 	case SYS_writev:
4597*0Sstevel@tonic-gate 		if (pri->sys_nargs > 2) {
4598*0Sstevel@tonic-gate 			int i = pri->sys_args[0]+1;
4599*0Sstevel@tonic-gate 			int showbuf = FALSE;
4600*0Sstevel@tonic-gate 			long nb = (what == SYS_readv)? r0 : 32*1024;
4601*0Sstevel@tonic-gate 
4602*0Sstevel@tonic-gate 			if ((what == SYS_readv && !err &&
4603*0Sstevel@tonic-gate 			    prismember(&readfd, i)) ||
4604*0Sstevel@tonic-gate 			    (what == SYS_writev &&
4605*0Sstevel@tonic-gate 			    prismember(&writefd, i)))
4606*0Sstevel@tonic-gate 				showbuf = TRUE;
4607*0Sstevel@tonic-gate 			show_iovec(pri, (long)pri->sys_args[1],
4608*0Sstevel@tonic-gate 				pri->sys_args[2], showbuf, nb);
4609*0Sstevel@tonic-gate 		}
4610*0Sstevel@tonic-gate 		break;
4611*0Sstevel@tonic-gate 	case SYS_getrlimit:
4612*0Sstevel@tonic-gate 		if (err)
4613*0Sstevel@tonic-gate 			break;
4614*0Sstevel@tonic-gate 		/*FALLTHROUGH*/
4615*0Sstevel@tonic-gate 	case SYS_setrlimit:
4616*0Sstevel@tonic-gate 		if (pri->sys_nargs <= 1)
4617*0Sstevel@tonic-gate 			break;
4618*0Sstevel@tonic-gate #ifdef _LP64
4619*0Sstevel@tonic-gate 		if (lp64)
4620*0Sstevel@tonic-gate 			show_rlimit64(pri, (long)pri->sys_args[1]);
4621*0Sstevel@tonic-gate 		else
4622*0Sstevel@tonic-gate 			show_rlimit32(pri, (long)pri->sys_args[1]);
4623*0Sstevel@tonic-gate #else
4624*0Sstevel@tonic-gate 		show_rlimit32(pri, (long)pri->sys_args[1]);
4625*0Sstevel@tonic-gate #endif
4626*0Sstevel@tonic-gate 		break;
4627*0Sstevel@tonic-gate 	case SYS_getrlimit64:
4628*0Sstevel@tonic-gate 		if (err)
4629*0Sstevel@tonic-gate 			break;
4630*0Sstevel@tonic-gate 		/*FALLTHROUGH*/
4631*0Sstevel@tonic-gate 	case SYS_setrlimit64:
4632*0Sstevel@tonic-gate 		if (pri->sys_nargs <= 1)
4633*0Sstevel@tonic-gate 			break;
4634*0Sstevel@tonic-gate 		show_rlimit64(pri, (long)pri->sys_args[1]);
4635*0Sstevel@tonic-gate 		break;
4636*0Sstevel@tonic-gate 	case SYS_uname:
4637*0Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 0)
4638*0Sstevel@tonic-gate 			show_nuname(pri, (long)pri->sys_args[0]);
4639*0Sstevel@tonic-gate 		break;
4640*0Sstevel@tonic-gate 	case SYS_adjtime:
4641*0Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 1)
4642*0Sstevel@tonic-gate 			show_adjtime(pri, (long)pri->sys_args[0],
4643*0Sstevel@tonic-gate 				(long)pri->sys_args[1]);
4644*0Sstevel@tonic-gate 		break;
4645*0Sstevel@tonic-gate 	case SYS_lwp_info:
4646*0Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 0)
4647*0Sstevel@tonic-gate 			show_timestruc(pri, (long)pri->sys_args[0], "cpu time");
4648*0Sstevel@tonic-gate 		break;
4649*0Sstevel@tonic-gate 	case SYS_lwp_wait:
4650*0Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 1)
4651*0Sstevel@tonic-gate 			show_int(pri, (long)pri->sys_args[1], "lwpid");
4652*0Sstevel@tonic-gate 		break;
4653*0Sstevel@tonic-gate 	case SYS_lwp_mutex_wakeup:
4654*0Sstevel@tonic-gate 	case SYS_lwp_mutex_lock:
4655*0Sstevel@tonic-gate 	case SYS_lwp_mutex_unlock:
4656*0Sstevel@tonic-gate 	case SYS_lwp_mutex_trylock:
4657*0Sstevel@tonic-gate 	case SYS_lwp_mutex_init:
4658*0Sstevel@tonic-gate 		if (pri->sys_nargs > 0)
4659*0Sstevel@tonic-gate 			show_mutex(pri, (long)pri->sys_args[0]);
4660*0Sstevel@tonic-gate 		break;
4661*0Sstevel@tonic-gate 	case SYS_lwp_mutex_timedlock:
4662*0Sstevel@tonic-gate 		if (pri->sys_nargs > 0)
4663*0Sstevel@tonic-gate 			show_mutex(pri, (long)pri->sys_args[0]);
4664*0Sstevel@tonic-gate 		if (pri->sys_nargs > 1)
4665*0Sstevel@tonic-gate 			show_timestruc(pri, (long)pri->sys_args[1], "timeout");
4666*0Sstevel@tonic-gate 		break;
4667*0Sstevel@tonic-gate 	case SYS_lwp_cond_wait:
4668*0Sstevel@tonic-gate 		if (pri->sys_nargs > 0)
4669*0Sstevel@tonic-gate 			show_condvar(pri, (long)pri->sys_args[0]);
4670*0Sstevel@tonic-gate 		if (pri->sys_nargs > 1)
4671*0Sstevel@tonic-gate 			show_mutex(pri, (long)pri->sys_args[1]);
4672*0Sstevel@tonic-gate 		if (pri->sys_nargs > 2)
4673*0Sstevel@tonic-gate 			show_timestruc(pri, (long)pri->sys_args[2], "timeout");
4674*0Sstevel@tonic-gate 		break;
4675*0Sstevel@tonic-gate 	case SYS_lwp_cond_signal:
4676*0Sstevel@tonic-gate 	case SYS_lwp_cond_broadcast:
4677*0Sstevel@tonic-gate 		if (pri->sys_nargs > 0)
4678*0Sstevel@tonic-gate 			show_condvar(pri, (long)pri->sys_args[0]);
4679*0Sstevel@tonic-gate 		break;
4680*0Sstevel@tonic-gate 	case SYS_lwp_sema_wait:
4681*0Sstevel@tonic-gate 	case SYS_lwp_sema_trywait:
4682*0Sstevel@tonic-gate 	case SYS_lwp_sema_post:
4683*0Sstevel@tonic-gate 		if (pri->sys_nargs > 0)
4684*0Sstevel@tonic-gate 			show_sema(pri, (long)pri->sys_args[0]);
4685*0Sstevel@tonic-gate 		break;
4686*0Sstevel@tonic-gate 	case SYS_lwp_sema_timedwait:
4687*0Sstevel@tonic-gate 		if (pri->sys_nargs > 0)
4688*0Sstevel@tonic-gate 			show_sema(pri, (long)pri->sys_args[0]);
4689*0Sstevel@tonic-gate 		if (pri->sys_nargs > 1)
4690*0Sstevel@tonic-gate 			show_timestruc(pri, (long)pri->sys_args[1], "timeout");
4691*0Sstevel@tonic-gate 		break;
4692*0Sstevel@tonic-gate 	case SYS_lwp_rwlock_sys:
4693*0Sstevel@tonic-gate 		if (pri->sys_nargs > 1)
4694*0Sstevel@tonic-gate 			show_rwlock(pri, (long)pri->sys_args[1]);
4695*0Sstevel@tonic-gate 		if (pri->sys_nargs > 2 &&
4696*0Sstevel@tonic-gate 		    (pri->sys_args[0] == 0 || pri->sys_args[0] == 1))
4697*0Sstevel@tonic-gate 			show_timestruc(pri, (long)pri->sys_args[2], "timeout");
4698*0Sstevel@tonic-gate 		break;
4699*0Sstevel@tonic-gate 	case SYS_lwp_create:
4700*0Sstevel@tonic-gate 		/* XXX print some values in ucontext ??? */
4701*0Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 2)
4702*0Sstevel@tonic-gate 			show_int(pri, (long)pri->sys_args[2], "lwpid");
4703*0Sstevel@tonic-gate 		break;
4704*0Sstevel@tonic-gate 	case SYS_kaio:
4705*0Sstevel@tonic-gate 		if (pri->sys_args[0] == AIOWAIT && !err && pri->sys_nargs > 1)
4706*0Sstevel@tonic-gate 			show_timeval(pri, (long)pri->sys_args[1], "timeout");
4707*0Sstevel@tonic-gate 		break;
4708*0Sstevel@tonic-gate 	case SYS_nanosleep:
4709*0Sstevel@tonic-gate 		if (pri->sys_nargs > 0)
4710*0Sstevel@tonic-gate 			show_timestruc(pri, (long)pri->sys_args[0], "tmout");
4711*0Sstevel@tonic-gate 		if (pri->sys_nargs > 1 && (err == 0 || err == EINTR))
4712*0Sstevel@tonic-gate 			show_timestruc(pri, (long)pri->sys_args[1], "resid");
4713*0Sstevel@tonic-gate 		break;
4714*0Sstevel@tonic-gate 	case SYS_privsys:
4715*0Sstevel@tonic-gate 		switch (pri->sys_args[0]) {
4716*0Sstevel@tonic-gate 		case PRIVSYS_SETPPRIV:
4717*0Sstevel@tonic-gate 		case PRIVSYS_GETPPRIV:
4718*0Sstevel@tonic-gate 			if (!err)
4719*0Sstevel@tonic-gate 				show_privset(pri, (long)pri->sys_args[3],
4720*0Sstevel@tonic-gate 					(size_t)pri->sys_args[4]);
4721*0Sstevel@tonic-gate 		}
4722*0Sstevel@tonic-gate 		break;
4723*0Sstevel@tonic-gate 	case SYS_ucredsys:
4724*0Sstevel@tonic-gate 		switch (pri->sys_args[0]) {
4725*0Sstevel@tonic-gate 		case UCREDSYS_UCREDGET:
4726*0Sstevel@tonic-gate 		case UCREDSYS_GETPEERUCRED:
4727*0Sstevel@tonic-gate 			if (err == 0)
4728*0Sstevel@tonic-gate 				show_ucred(pri, (long)pri->sys_args[2]);
4729*0Sstevel@tonic-gate 			break;
4730*0Sstevel@tonic-gate 		}
4731*0Sstevel@tonic-gate 		break;
4732*0Sstevel@tonic-gate 	case SYS_bind:
4733*0Sstevel@tonic-gate 	case SYS_connect:
4734*0Sstevel@tonic-gate 		if (pri->sys_nargs > 2)
4735*0Sstevel@tonic-gate 			show_sockaddr(pri, "name", (long)pri->sys_args[1],
4736*0Sstevel@tonic-gate 				0, (long)pri->sys_args[2]);
4737*0Sstevel@tonic-gate 		break;
4738*0Sstevel@tonic-gate 	case SYS_sendto:
4739*0Sstevel@tonic-gate 		if (pri->sys_nargs > 5)
4740*0Sstevel@tonic-gate 			show_sockaddr(pri, "to", (long)pri->sys_args[4], 0,
4741*0Sstevel@tonic-gate 				pri->sys_args[5]);
4742*0Sstevel@tonic-gate 		break;
4743*0Sstevel@tonic-gate 	case SYS_accept:
4744*0Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 2)
4745*0Sstevel@tonic-gate 			show_sockaddr(pri, "name", (long)pri->sys_args[1],
4746*0Sstevel@tonic-gate 				(long)pri->sys_args[2], 0);
4747*0Sstevel@tonic-gate 		break;
4748*0Sstevel@tonic-gate 	case SYS_getsockname:
4749*0Sstevel@tonic-gate 	case SYS_getpeername:
4750*0Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 2)
4751*0Sstevel@tonic-gate 			show_sockaddr(pri, "name", (long)pri->sys_args[1],
4752*0Sstevel@tonic-gate 				(long)pri->sys_args[2], 0);
4753*0Sstevel@tonic-gate 		break;
4754*0Sstevel@tonic-gate 	case SYS_cladm:
4755*0Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 2)
4756*0Sstevel@tonic-gate 			show_cladm(pri, pri->sys_args[0], pri->sys_args[1],
4757*0Sstevel@tonic-gate 			    (long)pri->sys_args[2]);
4758*0Sstevel@tonic-gate 		break;
4759*0Sstevel@tonic-gate 	case SYS_recvfrom:
4760*0Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 5)
4761*0Sstevel@tonic-gate 			show_sockaddr(pri, "from", (long)pri->sys_args[4],
4762*0Sstevel@tonic-gate 				(long)pri->sys_args[5], 0);
4763*0Sstevel@tonic-gate 		break;
4764*0Sstevel@tonic-gate 	case SYS_recvmsg:
4765*0Sstevel@tonic-gate 		if (err)
4766*0Sstevel@tonic-gate 			break;
4767*0Sstevel@tonic-gate 		/* FALLTHROUGH */
4768*0Sstevel@tonic-gate 	case SYS_sendmsg:
4769*0Sstevel@tonic-gate 		if (pri->sys_nargs <= 1)
4770*0Sstevel@tonic-gate 			break;
4771*0Sstevel@tonic-gate #ifdef _LP64
4772*0Sstevel@tonic-gate 		if (lp64)
4773*0Sstevel@tonic-gate 			show_msghdr(pri, pri->sys_args[1]);
4774*0Sstevel@tonic-gate 		else
4775*0Sstevel@tonic-gate 			show_msghdr32(pri, pri->sys_args[1]);
4776*0Sstevel@tonic-gate #else
4777*0Sstevel@tonic-gate 		show_msghdr(pri, pri->sys_args[1]);
4778*0Sstevel@tonic-gate #endif
4779*0Sstevel@tonic-gate 		break;
4780*0Sstevel@tonic-gate 	case SYS_door:
4781*0Sstevel@tonic-gate 		show_doors(pri);
4782*0Sstevel@tonic-gate 		break;
4783*0Sstevel@tonic-gate 	case SYS_sendfilev:
4784*0Sstevel@tonic-gate 		if (pri->sys_nargs != 5)
4785*0Sstevel@tonic-gate 			break;
4786*0Sstevel@tonic-gate 
4787*0Sstevel@tonic-gate 		if (pri->sys_args[0] == SENDFILEV) {
4788*0Sstevel@tonic-gate 			show_sendfilevec(pri, (int)pri->sys_args[1],
4789*0Sstevel@tonic-gate 				(sendfilevec_t *)pri->sys_args[2],
4790*0Sstevel@tonic-gate 				(int)pri->sys_args[3]);
4791*0Sstevel@tonic-gate 		} else if (pri->sys_args[0] == SENDFILEV64) {
4792*0Sstevel@tonic-gate 			show_sendfilevec64(pri, (int)pri->sys_args[1],
4793*0Sstevel@tonic-gate 				(sendfilevec64_t *)pri->sys_args[2],
4794*0Sstevel@tonic-gate 				(int)pri->sys_args[3]);
4795*0Sstevel@tonic-gate 		}
4796*0Sstevel@tonic-gate 		break;
4797*0Sstevel@tonic-gate 	case SYS_memcntl:
4798*0Sstevel@tonic-gate 		show_memcntl(pri);
4799*0Sstevel@tonic-gate 		break;
4800*0Sstevel@tonic-gate 	case SYS_lwp_park:
4801*0Sstevel@tonic-gate 		/* subcode 0: lwp_park(timespec_t *, id_t) */
4802*0Sstevel@tonic-gate 		if (pri->sys_nargs > 1 && pri->sys_args[0] == 0)
4803*0Sstevel@tonic-gate 			show_timestruc(pri, (long)pri->sys_args[1], "timeout");
4804*0Sstevel@tonic-gate 		/* subcode 2: lwp_unpark_all(id_t *, int) */
4805*0Sstevel@tonic-gate 		if (pri->sys_nargs > 2 && pri->sys_args[0] == 2)
4806*0Sstevel@tonic-gate 			show_ids(pri, (long)pri->sys_args[1],
4807*0Sstevel@tonic-gate 				(int)pri->sys_args[2]);
4808*0Sstevel@tonic-gate 		break;
4809*0Sstevel@tonic-gate 	case SYS_ntp_gettime:
4810*0Sstevel@tonic-gate 		if (!err)
4811*0Sstevel@tonic-gate 			show_ntp_gettime(pri);
4812*0Sstevel@tonic-gate 		break;
4813*0Sstevel@tonic-gate 	case SYS_ntp_adjtime:
4814*0Sstevel@tonic-gate 		if (!err)
4815*0Sstevel@tonic-gate 			show_ntp_adjtime(pri);
4816*0Sstevel@tonic-gate 		break;
4817*0Sstevel@tonic-gate 	case SYS_rusagesys:
4818*0Sstevel@tonic-gate 		if (!err)
4819*0Sstevel@tonic-gate 			if (pri->sys_args[0] == _RUSAGESYS_GETRUSAGE) {
4820*0Sstevel@tonic-gate #ifdef _LP64
4821*0Sstevel@tonic-gate 				if (!lp64)
4822*0Sstevel@tonic-gate 				    show_getrusage32(pri->sys_args[1]);
4823*0Sstevel@tonic-gate 				else
4824*0Sstevel@tonic-gate #endif
4825*0Sstevel@tonic-gate 				    show_getrusage(pri->sys_args[1]);
4826*0Sstevel@tonic-gate 			}
4827*0Sstevel@tonic-gate 		break;
4828*0Sstevel@tonic-gate 	case SYS_port:
4829*0Sstevel@tonic-gate 		show_ports(pri);
4830*0Sstevel@tonic-gate 		break;
4831*0Sstevel@tonic-gate 	}
4832*0Sstevel@tonic-gate }
4833