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