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