xref: /titanic_51/usr/src/cmd/truss/print.c (revision 3d5869cc80c26887ee2c78b0f35e58f574e97192)
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  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
27 /*	  All Rights Reserved  	*/
28 
29 #define	_SYSCALL32	/* make 32-bit compat headers visible */
30 
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <unistd.h>
34 #include <string.h>
35 #include <signal.h>
36 #include <termio.h>
37 #include <stddef.h>
38 #include <limits.h>
39 #include <fcntl.h>
40 #include <ctype.h>
41 #include <sys/types.h>
42 #include <sys/mman.h>
43 #include <sys/resource.h>
44 #include <sys/ulimit.h>
45 #include <sys/utsname.h>
46 #include <sys/kstat.h>
47 #include <sys/modctl.h>
48 #include <sys/acl.h>
49 #include <stropts.h>
50 #include <sys/isa_defs.h>
51 #include <sys/systeminfo.h>
52 #include <sys/cladm.h>
53 #include <sys/lwp.h>
54 #include <bsm/audit.h>
55 #include <libproc.h>
56 #include <priv.h>
57 #include <sys/aio.h>
58 #include <sys/aiocb.h>
59 #include <sys/corectl.h>
60 #include <sys/cpc_impl.h>
61 #include <sys/priocntl.h>
62 #include <sys/tspriocntl.h>
63 #include <sys/iapriocntl.h>
64 #include <sys/rtpriocntl.h>
65 #include <sys/fsspriocntl.h>
66 #include <sys/fxpriocntl.h>
67 #include <netdb.h>
68 #include <nss_dbdefs.h>
69 #include <sys/socketvar.h>
70 #include <netinet/in.h>
71 #include <netinet/tcp.h>
72 #include <netinet/udp.h>
73 #include <netinet/sctp.h>
74 #include <net/route.h>
75 #include <sys/utrap.h>
76 #include <sys/lgrp_user.h>
77 #include <sys/door.h>
78 #include <sys/tsol/tndb.h>
79 #include <sys/rctl.h>
80 #include <sys/rctl_impl.h>
81 #include <sys/fork.h>
82 #include <sys/task.h>
83 #include "ramdata.h"
84 #include "print.h"
85 #include "proto.h"
86 #include "systable.h"
87 
88 void grow(private_t *, int nbyte);
89 
90 #define	GROW(nb) if (pri->sys_leng + (nb) >= pri->sys_ssize) grow(pri, (nb))
91 
92 
93 /*ARGSUSED*/
94 void
95 prt_nov(private_t *pri, int raw, long val)	/* print nothing */
96 {
97 }
98 
99 /*ARGSUSED*/
100 void
101 prt_dec(private_t *pri, int raw, long val)	/* print as decimal */
102 {
103 	GROW(24);
104 	if (data_model == PR_MODEL_ILP32)
105 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
106 		    "%d", (int)val);
107 	else
108 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
109 		    "%ld", val);
110 }
111 
112 /*ARGSUSED*/
113 void
114 prt_uns(private_t *pri, int raw, long val)	/* print as unsigned decimal */
115 {
116 	GROW(24);
117 	if (data_model == PR_MODEL_ILP32)
118 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
119 		    "%u", (int)val);
120 	else
121 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
122 		    "%lu", val);
123 }
124 
125 /* print as unsigned decimal, except for -1 */
126 void
127 prt_un1(private_t *pri, int raw, long val)
128 {
129 	if ((int)val == -1)
130 		prt_dec(pri, raw, val);
131 	else
132 		prt_uns(pri, raw, val);
133 }
134 
135 /*ARGSUSED*/
136 void
137 prt_oct(private_t *pri, int raw, long val)	/* print as octal */
138 {
139 	GROW(24);
140 	if (data_model == PR_MODEL_ILP32)
141 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
142 		    "%#o", (int)val);
143 	else
144 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
145 		    "%#lo", val);
146 }
147 
148 /*ARGSUSED*/
149 void
150 prt_hex(private_t *pri, int raw, long val)	/* print as hexadecimal */
151 {
152 	GROW(20);
153 	if (data_model == PR_MODEL_ILP32)
154 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
155 		    "0x%.8X", (int)val);
156 	else
157 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
158 		    "0x%.8lX", val);
159 }
160 
161 /* print as hexadecimal (half size) */
162 /*ARGSUSED*/
163 void
164 prt_hhx(private_t *pri, int raw, long val)
165 {
166 	GROW(20);
167 	if (data_model == PR_MODEL_ILP32)
168 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
169 		    "0x%.4X", (int)val);
170 	else
171 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
172 		    "0x%.4lX", val);
173 }
174 
175 /* print as decimal if small, else hexadecimal */
176 /*ARGSUSED*/
177 void
178 prt_dex(private_t *pri, int raw, long val)
179 {
180 	if (val & 0xff000000)
181 		prt_hex(pri, 0, val);
182 	else
183 		prt_dec(pri, 0, val);
184 }
185 
186 /* print long long offset */
187 /*ARGSUSED*/
188 void
189 prt_llo(private_t *pri, int raw, long val1, long val2)
190 {
191 	int hival;
192 	int loval;
193 
194 #ifdef	_LONG_LONG_LTOH
195 	hival = (int)val2;
196 	loval = (int)val1;
197 #else
198 	hival = (int)val1;
199 	loval = (int)val2;
200 #endif
201 
202 	if (hival == 0) {
203 		prt_dex(pri, 0, loval);
204 	} else {
205 		GROW(18);
206 		pri->sys_leng +=
207 		    sprintf(pri->sys_string + pri->sys_leng, "0x%.8X%.8X",
208 		    hival, loval);
209 	}
210 }
211 
212 void
213 escape_string(private_t *pri, const char *s)
214 {
215 	/*
216 	 * We want to avoid outputting unprintable characters that may
217 	 * destroy the user's terminal.  So we do one pass to find any
218 	 * unprintable characters, size the array appropriately, and
219 	 * then walk each character by hand.  Those that are unprintable
220 	 * are replaced by a hex escape (\xNN).  We also escape quotes for
221 	 * completeness.
222 	 */
223 	int i, unprintable, quotes;
224 	size_t len = strlen(s);
225 	for (i = 0, unprintable = 0, quotes = 0; i < len; i++) {
226 		if (!isprint(s[i]))
227 			unprintable++;
228 		if (s[i] == '"')
229 			quotes++;
230 	}
231 
232 	GROW(len + 3 * unprintable + quotes + 2);
233 
234 	pri->sys_string[pri->sys_leng++] = '"';
235 	for (i = 0; i < len; i++) {
236 		if (s[i] == '"')
237 			pri->sys_string[pri->sys_leng++] = '\\';
238 
239 		if (isprint(s[i])) {
240 			pri->sys_string[pri->sys_leng++] = s[i];
241 		} else {
242 			pri->sys_leng += sprintf(pri->sys_string +
243 			    pri->sys_leng, "\\x%02x", (uint8_t)s[i]);
244 		}
245 	}
246 	pri->sys_string[pri->sys_leng++] = '"';
247 }
248 
249 void
250 prt_stg(private_t *pri, int raw, long val)	/* print as string */
251 {
252 	char *s = raw? NULL : fetchstring(pri, (long)val, PATH_MAX);
253 
254 	if (s == NULL)
255 		prt_hex(pri, 0, val);
256 	else
257 		escape_string(pri, s);
258 }
259 
260 /* print as string returned from syscall */
261 void
262 prt_rst(private_t *pri, int raw, long val)
263 {
264 	char *s = (raw || pri->Errno)? NULL :
265 	    fetchstring(pri, (long)val, PATH_MAX);
266 
267 	if (s == NULL)
268 		prt_hex(pri, 0, val);
269 	else {
270 		GROW((int)strlen(s) + 2);
271 		pri->sys_leng += snprintf(pri->sys_string + pri->sys_leng,
272 		    pri->sys_ssize - pri->sys_leng, "\"%s\"", s);
273 	}
274 }
275 
276 /* print contents of readlink() buffer */
277 void
278 prt_rlk(private_t *pri, int raw, long val)
279 {
280 	char *s = (raw || pri->Errno || pri->Rval1 <= 0)? NULL :
281 	    fetchstring(pri, (long)val,
282 	    (pri->Rval1 > PATH_MAX)? PATH_MAX : (int)pri->Rval1);
283 
284 	if (s == NULL)
285 		prt_hex(pri, 0, val);
286 	else {
287 		GROW((int)strlen(s) + 2);
288 		pri->sys_leng += snprintf(pri->sys_string + pri->sys_leng,
289 		    pri->sys_ssize - pri->sys_leng, "\"%s\"", s);
290 	}
291 }
292 
293 void
294 prt_ioc(private_t *pri, int raw, long val)	/* print ioctl code */
295 {
296 	const char *s = raw? NULL : ioctlname(pri, (int)val);
297 
298 	if (s == NULL)
299 		prt_hex(pri, 0, val);
300 	else
301 		outstring(pri, s);
302 }
303 
304 void
305 prt_ioa(private_t *pri, int raw, long val)	/* print ioctl argument */
306 {
307 	const char *s;
308 
309 	/* cheating -- look at the ioctl() code */
310 	switch (pri->sys_args[1]) {
311 
312 	/* kstat ioctl()s */
313 	case KSTAT_IOC_READ:
314 	case KSTAT_IOC_WRITE:
315 #ifdef _LP64
316 		if (data_model == PR_MODEL_ILP32)
317 			prt_stg(pri, raw,
318 			    val + offsetof(kstat32_t, ks_name[0]));
319 		else
320 #endif
321 			prt_stg(pri, raw,
322 			    val + offsetof(kstat_t, ks_name[0]));
323 		break;
324 
325 	/* streams ioctl()s */
326 	case I_LOOK:
327 		prt_rst(pri, raw, val);
328 		break;
329 	case I_PUSH:
330 	case I_FIND:
331 		prt_stg(pri, raw, val);
332 		break;
333 	case I_LINK:
334 	case I_UNLINK:
335 	case I_SENDFD:
336 		prt_dec(pri, 0, val);
337 		break;
338 	case I_SRDOPT:
339 		if (raw || (s = strrdopt(val)) == NULL)
340 			prt_dec(pri, 0, val);
341 		else
342 			outstring(pri, s);
343 		break;
344 	case I_SETSIG:
345 		if (raw || (s = strevents(pri, val)) == NULL)
346 			prt_hex(pri, 0, val);
347 		else
348 			outstring(pri, s);
349 		break;
350 	case I_FLUSH:
351 		if (raw || (s = strflush(val)) == NULL)
352 			prt_dec(pri, 0, val);
353 		else
354 			outstring(pri, s);
355 		break;
356 
357 	/* tty ioctl()s */
358 	case TCSBRK:
359 	case TCXONC:
360 	case TCFLSH:
361 	case TCDSET:
362 		prt_dec(pri, 0, val);
363 		break;
364 
365 	default:
366 		prt_hex(pri, 0, val);
367 		break;
368 	}
369 }
370 
371 void
372 prt_fcn(private_t *pri, int raw, long val)	/* print fcntl code */
373 {
374 	const char *s = raw? NULL : fcntlname(val);
375 
376 	if (s == NULL)
377 		prt_dec(pri, 0, val);
378 	else
379 		outstring(pri, s);
380 }
381 
382 void
383 prt_s86(private_t *pri, int raw, long val)	/* print sysi86 code */
384 {
385 
386 	const char *s = raw? NULL : si86name(val);
387 
388 	if (s == NULL)
389 		prt_dec(pri, 0, val);
390 	else
391 		outstring(pri, s);
392 }
393 
394 void
395 prt_uts(private_t *pri, int raw, long val)	/* print utssys code */
396 {
397 	const char *s = raw? NULL : utscode(val);
398 
399 	if (s == NULL)
400 		prt_dec(pri, 0, val);
401 	else
402 		outstring(pri, s);
403 }
404 
405 void
406 prt_msc(private_t *pri, int raw, long val)	/* print msgsys command */
407 {
408 	const char *s = raw? NULL : msgcmd(val);
409 
410 	if (s == NULL)
411 		prt_dec(pri, 0, val);
412 	else
413 		outstring(pri, s);
414 }
415 
416 void
417 prt_msf(private_t *pri, int raw, long val)	/* print msgsys flags */
418 {
419 	const char *s = raw? NULL : msgflags(pri, (int)val);
420 
421 	if (s == NULL)
422 		prt_oct(pri, 0, val);
423 	else
424 		outstring(pri, s);
425 }
426 
427 void
428 prt_smc(private_t *pri, int raw, long val)	/* print semsys command */
429 {
430 	const char *s = raw? NULL : semcmd(val);
431 
432 	if (s == NULL)
433 		prt_dec(pri, 0, val);
434 	else
435 		outstring(pri, s);
436 }
437 
438 void
439 prt_sef(private_t *pri, int raw, long val)	/* print semsys flags */
440 {
441 	const char *s = raw? NULL : semflags(pri, (int)val);
442 
443 	if (s == NULL)
444 		prt_oct(pri, 0, val);
445 	else
446 		outstring(pri, s);
447 }
448 
449 void
450 prt_shc(private_t *pri, int raw, long val)	/* print shmsys command */
451 {
452 	const char *s = raw? NULL : shmcmd(val);
453 
454 	if (s == NULL)
455 		prt_dec(pri, 0, val);
456 	else
457 		outstring(pri, s);
458 }
459 
460 void
461 prt_shf(private_t *pri, int raw, long val)	/* print shmsys flags */
462 {
463 	const char *s = raw? NULL : shmflags(pri, (int)val);
464 
465 	if (s == NULL)
466 		prt_oct(pri, 0, val);
467 	else
468 		outstring(pri, s);
469 }
470 
471 void
472 prt_sfs(private_t *pri, int raw, long val)	/* print sysfs code */
473 {
474 	const char *s = raw? NULL : sfsname(val);
475 
476 	if (s == NULL)
477 		prt_dec(pri, 0, val);
478 	else
479 		outstring(pri, s);
480 }
481 
482 void
483 prt_opn(private_t *pri, int raw, long val)	/* print open code */
484 {
485 	const char *s = raw? NULL : openarg(pri, val);
486 
487 	if (s == NULL)
488 		prt_oct(pri, 0, val);
489 	else
490 		outstring(pri, s);
491 }
492 
493 void
494 prt_sig(private_t *pri, int raw, long val)	/* print signal name */
495 {
496 	const char *s = raw? NULL : signame(pri, (int)val);
497 
498 	if (s == NULL)
499 		prt_hex(pri, 0, val);
500 	else
501 		outstring(pri, s);
502 }
503 
504 void
505 prt_smf(private_t *pri, int raw, long val) /* print streams message flags */
506 {
507 	switch (val) {
508 	case 0:
509 		prt_dec(pri, 0, val);
510 		break;
511 	case RS_HIPRI:
512 		if (raw)
513 			prt_hhx(pri, 0, val);
514 		else
515 			outstring(pri, "RS_HIPRI");
516 		break;
517 	default:
518 		prt_hhx(pri, 0, val);
519 		break;
520 	}
521 }
522 
523 void
524 prt_plk(private_t *pri, int raw, long val)	/* print plock code */
525 {
526 	const char *s = raw? NULL : plockname(val);
527 
528 	if (s == NULL)
529 		prt_dec(pri, 0, val);
530 	else
531 		outstring(pri, s);
532 }
533 
534 void
535 prt_mtf(private_t *pri, int raw, long val)	/* print mount flags */
536 {
537 	const char *s = raw? NULL : mountflags(pri, val);
538 
539 	if (s == NULL)
540 		prt_hex(pri, 0, val);
541 	else
542 		outstring(pri, s);
543 }
544 
545 void
546 prt_mft(private_t *pri, int raw, long val) /* print mount file system type */
547 {
548 	if (val >= 0 && val < 256)
549 		prt_dec(pri, 0, val);
550 	else if (raw)
551 		prt_hex(pri, 0, val);
552 	else
553 		prt_stg(pri, raw, val);
554 }
555 
556 #define	ISREAD(code) \
557 	((code) == SYS_read || (code) == SYS_pread || (code) == SYS_pread64 || \
558 	(code) == SYS_recv || (code) == SYS_recvfrom)
559 #define	ISWRITE(code) \
560 	((code) == SYS_write || (code) == SYS_pwrite || \
561 	(code) == SYS_pwrite64 || (code) == SYS_send || (code) == SYS_sendto)
562 
563 /* print contents of read() or write() I/O buffer */
564 void
565 prt_iob(private_t *pri, int raw, long val)
566 {
567 	const lwpstatus_t *Lsp = pri->lwpstat;
568 	int syscall = Lsp->pr_what;
569 	int fdp1 = pri->sys_args[0] + 1;
570 	ssize_t nbyte = ISWRITE(syscall)? pri->sys_args[2] :
571 	    (pri->Errno? 0 : pri->Rval1);
572 	int elsewhere = FALSE;		/* TRUE iff dumped elsewhere */
573 	char buffer[IOBSIZE];
574 
575 	pri->iob_buf[0] = '\0';
576 
577 	if (Lsp->pr_why == PR_SYSEXIT && nbyte > IOBSIZE) {
578 		if (ISREAD(syscall))
579 			elsewhere = prismember(&readfd, fdp1);
580 		else
581 			elsewhere = prismember(&writefd, fdp1);
582 	}
583 
584 	if (nbyte <= 0 || elsewhere)
585 		prt_hex(pri, 0, val);
586 	else {
587 		int nb = nbyte > IOBSIZE? IOBSIZE : (int)nbyte;
588 
589 		if (Pread(Proc, buffer, (size_t)nb, (long)val) != nb)
590 			prt_hex(pri, 0, val);
591 		else {
592 			pri->iob_buf[0] = '"';
593 			showbytes(buffer, nb, pri->iob_buf + 1);
594 			(void) strlcat(pri->iob_buf,
595 			    (nb == nbyte)?
596 			    (const char *)"\"" : (const char *)"\"..",
597 			    sizeof (pri->iob_buf));
598 			if (raw)
599 				prt_hex(pri, 0, val);
600 			else
601 				outstring(pri, pri->iob_buf);
602 		}
603 	}
604 }
605 #undef	ISREAD
606 #undef	ISWRITE
607 
608 void
609 prt_idt(private_t *pri, int raw, long val) /* print idtype_t, waitid() arg */
610 {
611 	const char *s = raw? NULL : idtype_enum(pri, val);
612 
613 	if (s == NULL)
614 		prt_dec(pri, 0, val);
615 	else
616 		outstring(pri, s);
617 }
618 
619 void
620 prt_wop(private_t *pri, int raw, long val)	/* print waitid() options */
621 {
622 	const char *s = raw? NULL : woptions(pri, (int)val);
623 
624 	if (s == NULL)
625 		prt_oct(pri, 0, val);
626 	else
627 		outstring(pri, s);
628 }
629 
630 void
631 prt_whn(private_t *pri, int raw, long val) /* print lseek() whence argument */
632 {
633 	const char *s = raw? NULL : whencearg(val);
634 
635 	if (s == NULL)
636 		prt_dec(pri, 0, val);
637 	else
638 		outstring(pri, s);
639 }
640 
641 /*ARGSUSED*/
642 void
643 prt_spm(private_t *pri, int raw, long val)	/* print sigprocmask argument */
644 {
645 	const char *s = NULL;
646 
647 	if (!raw) {
648 		switch (val) {
649 		case SIG_BLOCK:		s = "SIG_BLOCK";	break;
650 		case SIG_UNBLOCK:	s = "SIG_UNBLOCK";	break;
651 		case SIG_SETMASK:	s = "SIG_SETMASK";	break;
652 		}
653 	}
654 
655 	if (s == NULL)
656 		prt_dec(pri, 0, val);
657 	else
658 		outstring(pri, s);
659 }
660 
661 const char *
662 mmap_protect(private_t *pri, long arg)
663 {
664 	char *str = pri->code_buf;
665 
666 	if (arg & ~(PROT_READ|PROT_WRITE|PROT_EXEC))
667 		return ((char *)NULL);
668 
669 	if (arg == PROT_NONE)
670 		return ("PROT_NONE");
671 
672 	*str = '\0';
673 	if (arg & PROT_READ)
674 		(void) strlcat(str, "|PROT_READ", sizeof (pri->code_buf));
675 	if (arg & PROT_WRITE)
676 		(void) strlcat(str, "|PROT_WRITE", sizeof (pri->code_buf));
677 	if (arg & PROT_EXEC)
678 		(void) strlcat(str, "|PROT_EXEC", sizeof (pri->code_buf));
679 	return ((const char *)(str + 1));
680 }
681 
682 const char *
683 mmap_type(private_t *pri, long arg)
684 {
685 	char *str = pri->code_buf;
686 	size_t used;
687 
688 #define	CBSIZE	sizeof (pri->code_buf)
689 	switch (arg & MAP_TYPE) {
690 	case MAP_SHARED:
691 		used = strlcpy(str, "MAP_SHARED", CBSIZE);
692 		break;
693 	case MAP_PRIVATE:
694 		used = strlcpy(str, "MAP_PRIVATE", CBSIZE);
695 		break;
696 	default:
697 		used = snprintf(str, CBSIZE, "%ld", arg&MAP_TYPE);
698 		break;
699 	}
700 
701 	arg &= ~(_MAP_NEW|MAP_TYPE);
702 
703 	if (arg & ~(MAP_FIXED|MAP_RENAME|MAP_NORESERVE|MAP_ANON|MAP_ALIGN|
704 	    MAP_TEXT|MAP_INITDATA))
705 		(void) snprintf(str + used, sizeof (pri->code_buf) - used,
706 		    "|0x%lX", arg);
707 	else {
708 		if (arg & MAP_FIXED)
709 			(void) strlcat(str, "|MAP_FIXED", CBSIZE);
710 		if (arg & MAP_RENAME)
711 			(void) strlcat(str, "|MAP_RENAME", CBSIZE);
712 		if (arg & MAP_NORESERVE)
713 			(void) strlcat(str, "|MAP_NORESERVE", CBSIZE);
714 		if (arg & MAP_ANON)
715 			(void) strlcat(str, "|MAP_ANON", CBSIZE);
716 		if (arg & MAP_ALIGN)
717 			(void) strlcat(str, "|MAP_ALIGN", CBSIZE);
718 		if (arg & MAP_TEXT)
719 			(void) strlcat(str, "|MAP_TEXT", CBSIZE);
720 		if (arg & MAP_INITDATA)
721 			(void) strlcat(str, "|MAP_INITDATA", CBSIZE);
722 	}
723 
724 	return ((const char *)str);
725 #undef CBSIZE
726 }
727 
728 void
729 prt_mpr(private_t *pri, int raw, long val) /* print mmap()/mprotect() flags */
730 {
731 	const char *s = raw? NULL : mmap_protect(pri, val);
732 
733 	if (s == NULL)
734 		prt_hhx(pri, 0, val);
735 	else
736 		outstring(pri, s);
737 }
738 
739 void
740 prt_mty(private_t *pri, int raw, long val) /* print mmap() mapping type flags */
741 {
742 	const char *s = raw? NULL : mmap_type(pri, val);
743 
744 	if (s == NULL)
745 		prt_hhx(pri, 0, val);
746 	else
747 		outstring(pri, s);
748 }
749 
750 void
751 prt_mob(private_t *pri, int raw, long val) /* print mmapobj() flags */
752 {
753 	if (val == 0)
754 		prt_dec(pri, 0, val);
755 	else if (raw || (val & ~(MMOBJ_PADDING|MMOBJ_INTERPRET)) != 0)
756 		prt_hhx(pri, 0, val);
757 	else {
758 #define	CBSIZE	sizeof (pri->code_buf)
759 		char *s = pri->code_buf;
760 
761 		*s = '\0';
762 		if (val & MMOBJ_PADDING)
763 			(void) strlcat(s, "|MMOBJ_PADDING", CBSIZE);
764 		if (val & MMOBJ_INTERPRET)
765 			(void) strlcat(s, "|MMOBJ_INTERPRET", CBSIZE);
766 		outstring(pri, s + 1);
767 #undef CBSIZE
768 	}
769 }
770 
771 /*ARGSUSED*/
772 void
773 prt_mcf(private_t *pri, int raw, long val)	/* print memcntl() function */
774 {
775 	const char *s = NULL;
776 
777 	if (!raw) {
778 		switch (val) {
779 		case MC_SYNC:		s = "MC_SYNC";		break;
780 		case MC_LOCK:		s = "MC_LOCK";		break;
781 		case MC_UNLOCK:		s = "MC_UNLOCK";	break;
782 		case MC_ADVISE:		s = "MC_ADVISE";	break;
783 		case MC_LOCKAS:		s = "MC_LOCKAS";	break;
784 		case MC_UNLOCKAS:	s = "MC_UNLOCKAS";	break;
785 		case MC_HAT_ADVISE:	s = "MC_HAT_ADVISE";	break;
786 		}
787 	}
788 
789 	if (s == NULL)
790 		prt_dec(pri, 0, val);
791 	else
792 		outstring(pri, s);
793 }
794 
795 void
796 prt_mad(private_t *pri, int raw, long val)	/* print madvise() argument */
797 {
798 	const char *s = NULL;
799 
800 	if (!raw) {
801 		switch (val) {
802 		case MADV_NORMAL:	s = "MADV_NORMAL";	break;
803 		case MADV_RANDOM:	s = "MADV_RANDOM";	break;
804 		case MADV_SEQUENTIAL:	s = "MADV_SEQUENTIAL";	break;
805 		case MADV_WILLNEED:	s = "MADV_WILLNEED";	break;
806 		case MADV_DONTNEED:	s = "MADV_DONTNEED";	break;
807 		case MADV_FREE:		s = "MADV_FREE";	break;
808 		case MADV_ACCESS_DEFAULT: s = "MADV_ACCESS_DEFAULT";	break;
809 		case MADV_ACCESS_LWP:	s = "MADV_ACCESS_LWP";	break;
810 		case MADV_ACCESS_MANY:	s = "MADV_ACCESS_MANY";	break;
811 		}
812 	}
813 
814 	if (s == NULL)
815 		prt_dec(pri, 0, val);
816 	else
817 		outstring(pri, s);
818 }
819 
820 void
821 prt_mc4(private_t *pri, int raw, long val) /* print memcntl() (4th) argument */
822 {
823 	if (val == 0)
824 		prt_dec(pri, 0, val);
825 	else if (raw)
826 		prt_hhx(pri, 0, val);
827 	else {
828 		char *s = NULL;
829 
830 #define	CBSIZE	sizeof (pri->code_buf)
831 		/* cheating -- look at memcntl func */
832 		switch (pri->sys_args[2]) {
833 		case MC_ADVISE:
834 			prt_mad(pri, 0, val);
835 			return;
836 
837 		case MC_SYNC:
838 			if ((val & ~(MS_SYNC|MS_ASYNC|MS_INVALIDATE)) == 0) {
839 				*(s = pri->code_buf) = '\0';
840 				if (val & MS_SYNC)
841 					(void) strlcat(s, "|MS_SYNC", CBSIZE);
842 				if (val & MS_ASYNC)
843 					(void) strlcat(s, "|MS_ASYNC", CBSIZE);
844 				if (val & MS_INVALIDATE)
845 					(void) strlcat(s, "|MS_INVALIDATE",
846 					    CBSIZE);
847 			}
848 			break;
849 
850 		case MC_LOCKAS:
851 		case MC_UNLOCKAS:
852 			if ((val & ~(MCL_CURRENT|MCL_FUTURE)) == 0) {
853 				*(s = pri->code_buf) = '\0';
854 				if (val & MCL_CURRENT)
855 					(void) strlcat(s, "|MCL_CURRENT",
856 					    CBSIZE);
857 				if (val & MCL_FUTURE)
858 					(void) strlcat(s, "|MCL_FUTURE",
859 					    CBSIZE);
860 			}
861 			break;
862 		}
863 #undef CBSIZE
864 
865 		if (s == NULL || *s == '\0')
866 			prt_hhx(pri, 0, val);
867 		else
868 			outstring(pri, ++s);
869 	}
870 }
871 
872 void
873 prt_mc5(private_t *pri, int raw, long val) /* print memcntl() (5th) argument */
874 {
875 	char *s;
876 
877 #define	CBSIZE	sizeof (pri->code_buf)
878 	if (val == 0)
879 		prt_dec(pri, 0, val);
880 	else if (raw || (val & ~VALID_ATTR))
881 		prt_hhx(pri, 0, val);
882 	else {
883 		s = pri->code_buf;
884 		*s = '\0';
885 		if (val & SHARED)
886 			(void) strlcat(s, "|SHARED", CBSIZE);
887 		if (val & PRIVATE)
888 			(void) strlcat(s, "|PRIVATE", CBSIZE);
889 		if (val & PROT_READ)
890 			(void) strlcat(s, "|PROT_READ", CBSIZE);
891 		if (val & PROT_WRITE)
892 			(void) strlcat(s, "|PROT_WRITE", CBSIZE);
893 		if (val & PROT_EXEC)
894 			(void) strlcat(s, "|PROT_EXEC", CBSIZE);
895 		if (*s == '\0')
896 			prt_hhx(pri, 0, val);
897 		else
898 			outstring(pri, ++s);
899 	}
900 #undef CBSIZE
901 }
902 
903 void
904 prt_ulm(private_t *pri, int raw, long val)	/* print ulimit() argument */
905 {
906 	const char *s = NULL;
907 
908 	if (!raw) {
909 		switch (val) {
910 		case UL_GFILLIM:	s = "UL_GFILLIM";	break;
911 		case UL_SFILLIM:	s = "UL_SFILLIM";	break;
912 		case UL_GMEMLIM:	s = "UL_GMEMLIM";	break;
913 		case UL_GDESLIM:	s = "UL_GDESLIM";	break;
914 		}
915 	}
916 
917 	if (s == NULL)
918 		prt_dec(pri, 0, val);
919 	else
920 		outstring(pri, s);
921 }
922 
923 void
924 prt_rlm(private_t *pri, int raw, long val) /* print get/setrlimit() argument */
925 {
926 	const char *s = NULL;
927 
928 	if (!raw) {
929 		switch (val) {
930 		case RLIMIT_CPU:	s = "RLIMIT_CPU";	break;
931 		case RLIMIT_FSIZE:	s = "RLIMIT_FSIZE";	break;
932 		case RLIMIT_DATA:	s = "RLIMIT_DATA";	break;
933 		case RLIMIT_STACK:	s = "RLIMIT_STACK";	break;
934 		case RLIMIT_CORE:	s = "RLIMIT_CORE";	break;
935 		case RLIMIT_NOFILE:	s = "RLIMIT_NOFILE";	break;
936 		case RLIMIT_VMEM:	s = "RLIMIT_VMEM";	break;
937 		}
938 	}
939 
940 	if (s == NULL)
941 		prt_dec(pri, 0, val);
942 	else
943 		outstring(pri, s);
944 }
945 
946 void
947 prt_cnf(private_t *pri, int raw, long val)	/* print sysconfig code */
948 {
949 	const char *s = raw? NULL : sconfname(val);
950 
951 	if (s == NULL)
952 		prt_dec(pri, 0, val);
953 	else
954 		outstring(pri, s);
955 }
956 
957 void
958 prt_inf(private_t *pri, int raw, long val)	/* print sysinfo code */
959 {
960 	const char *s = NULL;
961 
962 	if (!raw) {
963 		switch (val) {
964 		case SI_SYSNAME:	s = "SI_SYSNAME";	break;
965 		case SI_HOSTNAME:	s = "SI_HOSTNAME";	break;
966 		case SI_RELEASE:	s = "SI_RELEASE";	break;
967 		case SI_VERSION:	s = "SI_VERSION";	break;
968 		case SI_MACHINE:	s = "SI_MACHINE";	break;
969 		case SI_ARCHITECTURE:	s = "SI_ARCHITECTURE";	break;
970 		case SI_ARCHITECTURE_32:s = "SI_ARCHITECTURE_32"; break;
971 		case SI_ARCHITECTURE_64:s = "SI_ARCHITECTURE_64"; break;
972 		case SI_ARCHITECTURE_K:	s = "SI_ARCHITECTURE_K"; break;
973 		case SI_HW_SERIAL:	s = "SI_HW_SERIAL";	break;
974 		case SI_HW_PROVIDER:	s = "SI_HW_PROVIDER";	break;
975 		case SI_SRPC_DOMAIN:	s = "SI_SRPC_DOMAIN";	break;
976 		case SI_SET_HOSTNAME:	s = "SI_SET_HOSTNAME";	break;
977 		case SI_SET_SRPC_DOMAIN: s = "SI_SET_SRPC_DOMAIN"; break;
978 		case SI_PLATFORM:	s = "SI_PLATFORM";	break;
979 		case SI_ISALIST:	s = "SI_ISALIST";	break;
980 		case SI_DHCP_CACHE:	s = "SI_DHCP_CACHE";	break;
981 		}
982 	}
983 
984 	if (s == NULL)
985 		prt_dec(pri, 0, val);
986 	else
987 		outstring(pri, s);
988 }
989 
990 void
991 prt_ptc(private_t *pri, int raw, long val)	/* print pathconf code */
992 {
993 	const char *s = raw? NULL : pathconfname(val);
994 
995 	if (s == NULL)
996 		prt_dec(pri, 0, val);
997 	else
998 		outstring(pri, s);
999 }
1000 
1001 void
1002 prt_fui(private_t *pri, int raw, long val) /* print fusers() input argument */
1003 {
1004 	const char *s = raw? NULL : fuiname(val);
1005 
1006 	if (s == NULL)
1007 		prt_hhx(pri, 0, val);
1008 	else
1009 		outstring(pri, s);
1010 }
1011 
1012 void
1013 prt_lwf(private_t *pri, int raw, long val)	/* print lwp_create() flags */
1014 {
1015 	char *s;
1016 
1017 	if (val == 0)
1018 		prt_dec(pri, 0, val);
1019 	else if (raw ||
1020 	    (val & ~(LWP_DAEMON|LWP_DETACHED|LWP_SUSPENDED)))
1021 		prt_hhx(pri, 0, val);
1022 	else {
1023 #define	CBSIZE	sizeof (pri->code_buf)
1024 		s = pri->code_buf;
1025 		*s = '\0';
1026 		if (val & LWP_DAEMON)
1027 			(void) strlcat(s, "|LWP_DAEMON", CBSIZE);
1028 		if (val & LWP_DETACHED)
1029 			(void) strlcat(s, "|LWP_DETACHED", CBSIZE);
1030 		if (val & LWP_SUSPENDED)
1031 			(void) strlcat(s, "|LWP_SUSPENDED", CBSIZE);
1032 		outstring(pri, ++s);
1033 #undef CBSIZE
1034 	}
1035 }
1036 
1037 void
1038 prt_itm(private_t *pri, int raw, long val) /* print [get|set]itimer() arg */
1039 {
1040 	const char *s = NULL;
1041 
1042 	if (!raw) {
1043 		switch (val) {
1044 		case ITIMER_REAL:	s = "ITIMER_REAL";	break;
1045 		case ITIMER_VIRTUAL:	s = "ITIMER_VIRTUAL";	break;
1046 		case ITIMER_PROF:	s = "ITIMER_PROF";	break;
1047 #ifdef ITIMER_REALPROF
1048 		case ITIMER_REALPROF:	s = "ITIMER_REALPROF";	break;
1049 #endif
1050 		}
1051 	}
1052 
1053 	if (s == NULL)
1054 		prt_dec(pri, 0, val);
1055 	else
1056 		outstring(pri, s);
1057 }
1058 
1059 void
1060 prt_mod(private_t *pri, int raw, long val)	/* print modctl() code */
1061 {
1062 	const char *s = NULL;
1063 
1064 	if (!raw) {
1065 		switch (val) {
1066 		case MODLOAD:		s = "MODLOAD";		break;
1067 		case MODUNLOAD:		s = "MODUNLOAD";	break;
1068 		case MODINFO:		s = "MODINFO";		break;
1069 		case MODRESERVED:	s = "MODRESERVED";	break;
1070 		case MODSETMINIROOT:	s = "MODSETMINIROOT";	break;
1071 		case MODADDMAJBIND:	s = "MODADDMAJBIND";	break;
1072 		case MODGETPATH:	s = "MODGETPATH";	break;
1073 		case MODGETPATHLEN:	s = "MODGETPATHLEN";	break;
1074 		case MODREADSYSBIND:	s = "MODREADSYSBIND";	break;
1075 		case MODGETMAJBIND:	s = "MODGETMAJBIND";	break;
1076 		case MODGETNAME:	s = "MODGETNAME";	break;
1077 		case MODSIZEOF_DEVID:	s = "MODSIZEOF_DEVID";	break;
1078 		case MODGETDEVID:	s = "MODGETDEVID";	break;
1079 		case MODSIZEOF_MINORNAME: s = "MODSIZEOF_MINORNAME"; break;
1080 		case MODGETMINORNAME:	s = "MODGETMINORNAME";	break;
1081 		case MODGETFBNAME:	s = "MODGETFBNAME";	break;
1082 		case MODEVENTS:		s = "MODEVENTS";	break;
1083 		case MODREREADDACF:	s = "MODREREADDACF";	break;
1084 		case MODLOADDRVCONF:	s = "MODLOADDRVCONF";	break;
1085 		case MODUNLOADDRVCONF:	s = "MODUNLOADDRVCONF";	break;
1086 		case MODREMMAJBIND:	s = "MODREMMAJBIND";	break;
1087 		case MODDEVT2INSTANCE:	s = "MODDEVT2INSTANCE";	break;
1088 		case MODGETDEVFSPATH_LEN: s = "MODGETDEVFSPATH_LEN"; break;
1089 		case MODGETDEVFSPATH:	s = "MODGETDEVFSPATH";	break;
1090 		case MODDEVID2PATHS:	s = "MODDEVID2PATHS";	break;
1091 		case MODSETDEVPOLICY:	s = "MODSETDEVPOLICY";	break;
1092 		case MODGETDEVPOLICY:	s = "MODGETDEVPOLICY";	break;
1093 		case MODALLOCPRIV:	s = "MODALLOCPRIV";	break;
1094 		case MODGETDEVPOLICYBYNAME:
1095 					s = "MODGETDEVPOLICYBYNAME"; break;
1096 		case MODLOADMINORPERM:	s = "MODLOADMINORPERM"; break;
1097 		case MODADDMINORPERM:	s = "MODADDMINORPERM"; break;
1098 		case MODREMMINORPERM:	s = "MODREMMINORPERM"; break;
1099 		case MODREMDRVCLEANUP:	s = "MODREMDRVCLEANUP"; break;
1100 		case MODDEVEXISTS:	s = "MODDEVEXISTS"; break;
1101 		case MODDEVREADDIR:	s = "MODDEVREADDIR"; break;
1102 		case MODDEVEMPTYDIR:	s = "MODDEVEMPTYDIR"; break;
1103 		case MODDEVNAME:	s = "MODDEVNAME"; break;
1104 		case MODGETDEVFSPATH_MI_LEN:
1105 					s = "MODGETDEVFSPATH_MI_LEN"; break;
1106 		case MODGETDEVFSPATH_MI:
1107 					s = "MODGETDEVFSPATH_MI"; break;
1108 		case MODREMDRVALIAS:	s = "MODREMDRVALIAS"; break;
1109 		case MODHPOPS:	s = "MODHPOPS"; break;
1110 		}
1111 	}
1112 
1113 	if (s == NULL)
1114 		prt_dec(pri, 0, val);
1115 	else
1116 		outstring(pri, s);
1117 }
1118 
1119 void
1120 prt_acl(private_t *pri, int raw, long val)	/* print acl() code */
1121 {
1122 	const char *s = NULL;
1123 
1124 	if (!raw) {
1125 		switch (val) {
1126 		case GETACL:		s = "GETACL";		break;
1127 		case SETACL:		s = "SETACL";		break;
1128 		case GETACLCNT:		s = "GETACLCNT";	break;
1129 		case ACE_GETACL:	s = "ACE_GETACL";	break;
1130 		case ACE_SETACL:	s = "ACE_SETACL";	break;
1131 		case ACE_GETACLCNT:	s = "ACE_GETACLCNT";	break;
1132 		}
1133 	}
1134 
1135 	if (s == NULL)
1136 		prt_dec(pri, 0, val);
1137 	else
1138 		outstring(pri, s);
1139 }
1140 
1141 void
1142 prt_aio(private_t *pri, int raw, long val)	/* print kaio() code */
1143 {
1144 	const char *s = NULL;
1145 	char buf[32];
1146 
1147 	if (!raw) {
1148 		switch (val & ~AIO_POLL_BIT) {
1149 		case AIOREAD:		s = "AIOREAD";		break;
1150 		case AIOWRITE:		s = "AIOWRITE";		break;
1151 		case AIOWAIT:		s = "AIOWAIT";		break;
1152 		case AIOCANCEL:		s = "AIOCANCEL";	break;
1153 		case AIONOTIFY:		s = "AIONOTIFY";	break;
1154 		case AIOINIT:		s = "AIOINIT";		break;
1155 		case AIOSTART:		s = "AIOSTART";		break;
1156 		case AIOLIO:		s = "AIOLIO";		break;
1157 		case AIOSUSPEND:	s = "AIOSUSPEND";	break;
1158 		case AIOERROR:		s = "AIOERROR";		break;
1159 		case AIOLIOWAIT:	s = "AIOLIOWAIT";	break;
1160 		case AIOAREAD:		s = "AIOAREAD";		break;
1161 		case AIOAWRITE:		s = "AIOAWRITE";	break;
1162 		/*
1163 		 * We have to hardcode the values for the 64-bit versions of
1164 		 * these calls, because <sys/aio.h> defines them to be identical
1165 		 * when compiled 64-bit.  If our target is 32-bit, we still need
1166 		 * to decode them correctly.
1167 		 */
1168 		case 13:		s = "AIOLIO64";		break;
1169 		case 14:		s = "AIOSUSPEND64";	break;
1170 		case 15:		s = "AUIOERROR64";	break;
1171 		case 16:		s = "AIOLIOWAIT64";	break;
1172 		case 17:		s = "AIOAREAD64";	break;
1173 		case 18:		s = "AIOAWRITE64";	break;
1174 		case 19:		s = "AIOCANCEL64";	break;
1175 
1176 		/*
1177 		 * AIOFSYNC doesn't correspond to a syscall.
1178 		 */
1179 		case AIOWAITN:		s = "AIOWAITN";		break;
1180 		}
1181 		if (s != NULL && (val & AIO_POLL_BIT)) {
1182 			(void) strlcpy(buf, s, sizeof (buf));
1183 			(void) strlcat(buf, "|AIO_POLL_BIT", sizeof (buf));
1184 			s = (const char *)buf;
1185 		}
1186 	}
1187 
1188 	if (s == NULL)
1189 		prt_dec(pri, 0, val);
1190 	else
1191 		outstring(pri, s);
1192 }
1193 
1194 void
1195 prt_aud(private_t *pri, int raw, long val)	/* print auditsys() code */
1196 {
1197 	const char *s = NULL;
1198 
1199 	if (!raw) {
1200 		switch (val) {
1201 		case BSM_GETAUID:	s = "BSM_GETAUID";	break;
1202 		case BSM_SETAUID:	s = "BSM_SETAUID";	break;
1203 		case BSM_GETAUDIT:	s = "BSM_GETAUDIT";	break;
1204 		case BSM_SETAUDIT:	s = "BSM_SETAUDIT";	break;
1205 		case BSM_AUDIT:		s = "BSM_AUDIT";	break;
1206 		case BSM_AUDITCTL:	s = "BSM_AUDITCTL";	break;
1207 		case BSM_GETAUDIT_ADDR:	s = "BSM_GETAUDIT_ADDR"; break;
1208 		case BSM_SETAUDIT_ADDR:	s = "BSM_SETAUDIT_ADDR"; break;
1209 		}
1210 	}
1211 
1212 	if (s == NULL)
1213 		prt_dec(pri, 0, val);
1214 	else
1215 		outstring(pri, s);
1216 }
1217 
1218 void
1219 prt_cor(private_t *pri, int raw, long val)	/* print corectl() subcode */
1220 {
1221 	const char *s = NULL;
1222 
1223 	if (!raw) {
1224 		switch (val) {
1225 		case CC_SET_OPTIONS:
1226 			s = "CC_SET_OPTIONS";		break;
1227 		case CC_GET_OPTIONS:
1228 			s = "CC_GET_OPTIONS";		break;
1229 		case CC_SET_GLOBAL_PATH:
1230 			s = "CC_SET_GLOBAL_PATH";	break;
1231 		case CC_GET_GLOBAL_PATH:
1232 			s = "CC_GET_GLOBAL_PATH";	break;
1233 		case CC_SET_PROCESS_PATH:
1234 			s = "CC_SET_PROCESS_PATH";	break;
1235 		case CC_GET_PROCESS_PATH:
1236 			s = "CC_GET_PROCESS_PATH";	break;
1237 		case CC_SET_GLOBAL_CONTENT:
1238 			s = "CC_SET_GLOBAL_CONTENT";	break;
1239 		case CC_GET_GLOBAL_CONTENT:
1240 			s = "CC_GET_GLOBAL_CONTENT";	break;
1241 		case CC_SET_PROCESS_CONTENT:
1242 			s = "CC_SET_PROCESS_CONTENT";	break;
1243 		case CC_GET_PROCESS_CONTENT:
1244 			s = "CC_GET_PROCESS_CONTENT";	break;
1245 		case CC_SET_DEFAULT_PATH:
1246 			s = "CC_SET_DEFAULT_PATH";	break;
1247 		case CC_GET_DEFAULT_PATH:
1248 			s = "CC_GET_DEFAULT_PATH";	break;
1249 		case CC_SET_DEFAULT_CONTENT:
1250 			s = "CC_SET_DEFAULT_CONTENT";	break;
1251 		case CC_GET_DEFAULT_CONTENT:
1252 			s = "CC_GET_DEFAULT_CONTENT";	break;
1253 		}
1254 	}
1255 
1256 	if (s == NULL)
1257 		prt_dec(pri, 0, val);
1258 	else
1259 		outstring(pri, s);
1260 }
1261 
1262 void
1263 prt_cco(private_t *pri, int raw, long val)	/* print corectl() options */
1264 {
1265 	char *s;
1266 
1267 	if (val == 0)
1268 		prt_dec(pri, 0, val);
1269 	else if (raw || (val & ~CC_OPTIONS))
1270 		prt_hhx(pri, 0, val);
1271 	else {
1272 #define	CBSIZE	sizeof (pri->code_buf)
1273 		s = pri->code_buf;
1274 		*s = '\0';
1275 		if (val & CC_GLOBAL_PATH)
1276 			(void) strlcat(s, "|CC_GLOBAL_PATH", CBSIZE);
1277 		if (val & CC_PROCESS_PATH)
1278 			(void) strlcat(s, "|CC_PROCESS_PATH", CBSIZE);
1279 		if (val & CC_GLOBAL_SETID)
1280 			(void) strlcat(s, "|CC_GLOBAL_SETID", CBSIZE);
1281 		if (val & CC_PROCESS_SETID)
1282 			(void) strlcat(s, "|CC_PROCESS_SETID", CBSIZE);
1283 		if (val & CC_GLOBAL_LOG)
1284 			(void) strlcat(s, "|CC_GLOBAL_LOG", CBSIZE);
1285 		if (*s == '\0')
1286 			prt_hhx(pri, 0, val);
1287 		else
1288 			outstring(pri, ++s);
1289 #undef CBSIZE
1290 	}
1291 }
1292 
1293 void
1294 prt_ccc(private_t *pri, int raw, long val)	/* print corectl() content */
1295 {
1296 	core_content_t ccc;
1297 
1298 	if (Pread(Proc, &ccc, sizeof (ccc), val) != sizeof (ccc))
1299 		prt_hex(pri, 0, val);
1300 	else if (!raw && proc_content2str(ccc, pri->code_buf,
1301 	    sizeof (pri->code_buf)) >= 0)
1302 		outstring(pri, pri->code_buf);
1303 	else
1304 		prt_hhx(pri, 0, (long)ccc);
1305 }
1306 
1307 void
1308 prt_rcc(private_t *pri, int raw, long val)	/* print corectl() ret. cont. */
1309 {
1310 	core_content_t ccc;
1311 
1312 	if (pri->Errno || Pread(Proc, &ccc, sizeof (ccc), val) != sizeof (ccc))
1313 		prt_hex(pri, 0, val);
1314 	else if (!raw && proc_content2str(ccc, pri->code_buf,
1315 	    sizeof (pri->code_buf)) >= 0)
1316 		outstring(pri, pri->code_buf);
1317 	else
1318 		prt_hhx(pri, 0, (long)ccc);
1319 }
1320 
1321 void
1322 prt_cpc(private_t *pri, int raw, long val)	/* print cpc() subcode */
1323 {
1324 	const char *s = NULL;
1325 
1326 	if (!raw) {
1327 		switch (val) {
1328 		case CPC_BIND:		s = "CPC_BIND";		break;
1329 		case CPC_SAMPLE:	s = "CPC_SAMPLE";	break;
1330 		case CPC_INVALIDATE:	s = "CPC_INVALIDATE";	break;
1331 		case CPC_RELE:		s = "CPC_RELE";		break;
1332 		case CPC_EVLIST_SIZE:	s = "CPC_EVLIST_SIZE";	break;
1333 		case CPC_LIST_EVENTS:	s = "CPC_LIST_EVENTS";	break;
1334 		case CPC_ATTRLIST_SIZE:	s = "CPC_ATTRLIST_SIZE"; break;
1335 		case CPC_LIST_ATTRS:	s = "CPC_LIST_ATTRS";	break;
1336 		case CPC_IMPL_NAME:	s = "CPC_IMPL_NAME";	break;
1337 		case CPC_CPUREF:	s = "CPC_CPUREF";	break;
1338 		case CPC_USR_EVENTS:	s = "CPC_USR_EVENTS";	break;
1339 		case CPC_SYS_EVENTS:	s = "CPC_SYS_EVENTS";	break;
1340 		case CPC_NPIC:		s = "CPC_NPIC";		break;
1341 		case CPC_CAPS:		s = "CPC_CAPS";		break;
1342 		case CPC_ENABLE:	s = "CPC_ENABLE";	break;
1343 		case CPC_DISABLE:	s = "CPC_DISABLE";	break;
1344 		}
1345 	}
1346 
1347 	if (s == NULL)
1348 		prt_dec(pri, 0, val);
1349 	else
1350 		outstring(pri, s);
1351 }
1352 
1353 void
1354 outstring(private_t *pri, const char *s)
1355 {
1356 	int len = strlen(s);
1357 
1358 	GROW(len);
1359 	(void) strcpy(pri->sys_string + pri->sys_leng, s);
1360 	pri->sys_leng += len;
1361 }
1362 
1363 void
1364 grow(private_t *pri, int nbyte)	/* reallocate format buffer if necessary */
1365 {
1366 	while (pri->sys_leng + nbyte >= pri->sys_ssize)
1367 		pri->sys_string = my_realloc(pri->sys_string,
1368 		    pri->sys_ssize *= 2, "format buffer");
1369 }
1370 
1371 void
1372 prt_clc(private_t *pri, int raw, long val)
1373 {
1374 	const char *s = NULL;
1375 
1376 	if (!raw) {
1377 		switch (val) {
1378 		case CL_INITIALIZE:	s = "CL_INITIALIZE";	break;
1379 		case CL_CONFIG:		s = "CL_CONFIG";	break;
1380 		}
1381 	}
1382 
1383 	if (s == NULL)
1384 		prt_dec(pri, 0, val);
1385 	else
1386 		outstring(pri, s);
1387 }
1388 
1389 void
1390 prt_clf(private_t *pri, int raw, long val)
1391 {
1392 	const char *s = NULL;
1393 
1394 	if (!raw) {
1395 		switch (pri->sys_args[0]) {
1396 		case CL_CONFIG:
1397 			switch (pri->sys_args[1]) {
1398 			case CL_NODEID:
1399 				s = "CL_NODEID";		break;
1400 			case CL_HIGHEST_NODEID:
1401 				s = "CL_HIGHEST_NODEID";	break;
1402 			}
1403 			break;
1404 		case CL_INITIALIZE:
1405 			switch (pri->sys_args[1]) {
1406 			case CL_GET_BOOTFLAG:
1407 				s = "CL_GET_BOOTFLAG";		break;
1408 			}
1409 			break;
1410 		}
1411 	}
1412 
1413 	if (s == NULL)
1414 		prt_dec(pri, 0, val);
1415 	else
1416 		outstring(pri, s);
1417 }
1418 
1419 void
1420 prt_sqc(private_t *pri, int raw, long val)	/* print sigqueue() si_code */
1421 {
1422 	const char *s = NULL;
1423 
1424 	if (!raw) {
1425 		switch ((int)val) {
1426 		case SI_QUEUE:		s = "SI_QUEUE";		break;
1427 		case SI_TIMER:		s = "SI_TIMER";		break;
1428 		case SI_ASYNCIO:	s = "SI_ASYNCIO";	break;
1429 		case SI_MESGQ:		s = "SI_MESGQ";		break;
1430 		}
1431 	}
1432 
1433 	if (s == NULL)
1434 		prt_dec(pri, 0, val);
1435 	else
1436 		outstring(pri, s);
1437 }
1438 
1439 /*
1440  * print priocntlsys() (key, value) pair key.
1441  */
1442 void
1443 print_pck(private_t *pri, int raw, long val)
1444 {
1445 	const char	*s = NULL;
1446 	char		clname[PC_CLNMSZ];
1447 
1448 	if ((pri->sys_args[2] != PC_GETXPARMS &&
1449 	    pri->sys_args[2] != PC_SETXPARMS) || val == 0 || raw) {
1450 		prt_dec(pri, 0, val);
1451 		return;
1452 	}
1453 
1454 	if (pri->sys_args[3] == NULL) {
1455 		if (val == PC_KY_CLNAME) {
1456 			s = "PC_KY_CLNAME";
1457 			outstring(pri, s);
1458 		} else
1459 			prt_dec(pri, 0, val);
1460 		return;
1461 	}
1462 
1463 	if (Pread(Proc, &clname, PC_CLNMSZ, pri->sys_args[3]) != PC_CLNMSZ) {
1464 		prt_dec(pri, 0, val);
1465 		return;
1466 	}
1467 
1468 	if (strcmp(clname, "TS") == 0) {
1469 		switch (val) {
1470 		case TS_KY_UPRILIM: 	s = "TS_KY_UPRILIM";	break;
1471 		case TS_KY_UPRI:	s = "TS_KY_UPRI";	break;
1472 		default:					break;
1473 		}
1474 	} else if (strcmp(clname, "IA") == 0) {
1475 		switch (val) {
1476 		case IA_KY_UPRILIM: 	s = "IA_KY_UPRILIM";	break;
1477 		case IA_KY_UPRI:	s = "IA_KY_UPRI";	break;
1478 		case IA_KY_MODE:	s = "IA_KY_MODE";	break;
1479 		default:					break;
1480 		}
1481 	} else if (strcmp(clname, "RT") == 0) {
1482 		switch (val) {
1483 		case RT_KY_PRI: 	s = "RT_KY_PRI";	break;
1484 		case RT_KY_TQSECS:	s = "RT_KY_TQSECS";	break;
1485 		case RT_KY_TQNSECS:	s = "RT_KY_TQNSECS";	break;
1486 		case RT_KY_TQSIG:	s = "RT_KY_TQSIG";	break;
1487 		default:					break;
1488 		}
1489 	} else if (strcmp(clname, "FSS") == 0) {
1490 		switch (val) {
1491 		case FSS_KY_UPRILIM: 	s = "FSS_KY_UPRILIM";	break;
1492 		case FSS_KY_UPRI:	s = "FSS_KY_UPRI";	break;
1493 		default:					break;
1494 		}
1495 	} else if (strcmp(clname, "FX") == 0) {
1496 		switch (val) {
1497 		case FX_KY_UPRILIM: 	s = "FX_KY_UPRILIM";	break;
1498 		case FX_KY_UPRI:	s = "FX_KY_UPRI";	break;
1499 		case FX_KY_TQSECS:	s = "FX_KY_TQSECS";	break;
1500 		case FX_KY_TQNSECS:	s = "FX_KY_TQNSECS";	break;
1501 		default:					break;
1502 		}
1503 	}
1504 
1505 	if (s == NULL)
1506 		prt_dec(pri, 0, val);
1507 	else
1508 		outstring(pri, s);
1509 }
1510 
1511 /*
1512  * print priocntlsys() fourth argument.
1513  */
1514 /*ARGSUSED*/
1515 void
1516 prt_pc4(private_t *pri, int raw, long val)
1517 {
1518 	/* look at pricntlsys function */
1519 	if ((pri->sys_args[2] != PC_GETXPARMS &&
1520 	    pri->sys_args[2] != PC_SETXPARMS))
1521 		prt_hex(pri, 0, val);
1522 	else if (val)
1523 		prt_stg(pri, 0, val);
1524 	else
1525 		prt_dec(pri, 0, val);
1526 }
1527 
1528 /*
1529  * print priocntlsys() (key, value) pairs (5th argument).
1530  */
1531 /*ARGSUSED*/
1532 void
1533 prt_pc5(private_t *pri, int raw, long val)
1534 {
1535 	pc_vaparms_t	prms;
1536 	pc_vaparm_t	*vpp = &prms.pc_parms[0];
1537 	uint_t		cnt;
1538 
1539 
1540 	/* look at pricntlsys function */
1541 	if ((pri->sys_args[2] != PC_GETXPARMS &&
1542 	    pri->sys_args[2] != PC_SETXPARMS) || val == 0) {
1543 		prt_dec(pri, 0, 0);
1544 		return;
1545 	}
1546 
1547 	if (Pread(Proc, &prms, sizeof (prms), val) != sizeof (prms)) {
1548 		prt_hex(pri, 0, val);
1549 		return;
1550 	}
1551 
1552 	if ((cnt = prms.pc_vaparmscnt) > PC_VAPARMCNT)
1553 		return;
1554 
1555 	for (; cnt--; vpp++) {
1556 		print_pck(pri, 0, vpp->pc_key);
1557 		outstring(pri, ", ");
1558 		prt_hex(pri, 0, (long)vpp->pc_parm);
1559 		outstring(pri, ", ");
1560 	}
1561 
1562 	prt_dec(pri, 0, PC_KY_NULL);
1563 }
1564 
1565 /*
1566  * Print processor set id, including logical expansion of "special" ids.
1567  */
1568 void
1569 prt_pst(private_t *pri, int raw, long val)
1570 {
1571 	const char *s = NULL;
1572 
1573 	if (!raw) {
1574 		switch ((psetid_t)val) {
1575 		case PS_NONE:		s = "PS_NONE";		break;
1576 		case PS_QUERY:		s = "PS_QUERY";		break;
1577 		case PS_MYID:		s = "PS_MYID";		break;
1578 		}
1579 	}
1580 
1581 	if (s == NULL)
1582 		prt_dec(pri, 0, val);
1583 	else
1584 		outstring(pri, s);
1585 }
1586 
1587 /*
1588  * Print meminfo() argument.
1589  */
1590 /*ARGSUSED*/
1591 void
1592 prt_mif(private_t *pri, int raw, long val)
1593 {
1594 	struct meminfo	minfo;
1595 
1596 #ifdef _LP64
1597 	if (data_model == PR_MODEL_ILP32) {
1598 		struct meminfo32 minfo32;
1599 
1600 		if (Pread(Proc, &minfo32, sizeof (struct meminfo32), val) !=
1601 			sizeof (struct meminfo32)) {
1602 			prt_dec(pri, 0, pri->sys_args[1]);	/* addr_count */
1603 			outstring(pri, ", ");
1604 			prt_hex(pri, 0, val);
1605 			return;
1606 		}
1607 		/*
1608 		 * arrange the arguments in the order that user calls with
1609 		 */
1610 		prt_hex(pri, 0, minfo32.mi_inaddr);
1611 		outstring(pri, ", ");
1612 		prt_dec(pri, 0, pri->sys_args[1]);	/* addr_count */
1613 		outstring(pri, ", ");
1614 		prt_hex(pri, 0, minfo32.mi_info_req);
1615 		outstring(pri, ", ");
1616 		prt_dec(pri, 0, minfo32.mi_info_count);
1617 		outstring(pri, ", ");
1618 		prt_hex(pri, 0, minfo32.mi_outdata);
1619 		outstring(pri, ", ");
1620 		prt_hex(pri, 0, minfo32.mi_validity);
1621 		return;
1622 	}
1623 #endif
1624 	if (Pread(Proc, &minfo, sizeof (struct meminfo), val) !=
1625 		sizeof (struct meminfo)) {
1626 		prt_dec(pri, 0, pri->sys_args[1]);	/* addr_count */
1627 		outstring(pri, ", ");
1628 		prt_hex(pri, 0, val);
1629 		return;
1630 	}
1631 	/*
1632 	 * arrange the arguments in the order that user calls with
1633 	 */
1634 	prt_hex(pri, 0, (long)minfo.mi_inaddr);
1635 	outstring(pri, ", ");
1636 	prt_dec(pri, 0, pri->sys_args[1]);	/* addr_count */
1637 	outstring(pri, ", ");
1638 	prt_hex(pri, 0, (long)minfo.mi_info_req);
1639 	outstring(pri, ", ");
1640 	prt_dec(pri, 0, minfo.mi_info_count);
1641 	outstring(pri, ", ");
1642 	prt_hex(pri, 0, (long)minfo.mi_outdata);
1643 	outstring(pri, ", ");
1644 	prt_hex(pri, 0, (long)minfo.mi_validity);
1645 }
1646 
1647 
1648 /*
1649  * Print so_socket() 1st argument.
1650  */
1651 /*ARGSUSED*/
1652 void
1653 prt_pfm(private_t *pri, int raw, long val)
1654 {
1655 	/* Protocol Families have same names as Address Families */
1656 	if ((ulong_t)val < MAX_AFCODES) {
1657 		outstring(pri, "PF_");
1658 		outstring(pri, afcodes[val]);
1659 	} else {
1660 		prt_dec(pri, 0, val);
1661 	}
1662 }
1663 
1664 
1665 /*
1666  * Print so_socket() 2nd argument.
1667  */
1668 /*ARGSUSED*/
1669 void
1670 prt_skt(private_t *pri, int raw, long val)
1671 {
1672 	const char *s;
1673 
1674 	if ((ulong_t)val <= MAX_SOCKTYPES && (s = socktype_codes[val]) != NULL)
1675 		outstring(pri, s);
1676 	else
1677 		prt_dec(pri, 0, val);
1678 }
1679 
1680 
1681 /*
1682  * Print so_socket() 3rd argument.
1683  */
1684 /*ARGSUSED*/
1685 void
1686 prt_skp(private_t *pri, int raw, long val)
1687 {
1688 	const char *s;
1689 
1690 	/* cheating -- look at the protocol-family */
1691 	switch (pri->sys_args[0]) {
1692 	case PF_INET6:
1693 	case PF_INET:
1694 	case PF_NCA:	if ((s = ipprotos((int)val)) != NULL) {
1695 				outstring(pri, s);
1696 				break;
1697 			}
1698 			/* FALLTHROUGH */
1699 	default:	prt_dec(pri, 0, val);
1700 			break;
1701 	}
1702 }
1703 
1704 
1705 /*
1706  * Print so_socket() 5th argument.
1707  */
1708 /*ARGSUSED*/
1709 void
1710 prt_skv(private_t *pri, int raw, long val)
1711 {
1712 	switch (val) {
1713 	case SOV_STREAM:	outstring(pri, "SOV_STREAM");	break;
1714 	case SOV_DEFAULT:	outstring(pri, "SOV_DEFAULT");	break;
1715 	case SOV_SOCKSTREAM:	outstring(pri, "SOV_SOCKSTREAM");	break;
1716 	case SOV_SOCKBSD:	outstring(pri, "SOV_SOCKBSD");	break;
1717 	case SOV_XPG4_2:	outstring(pri, "SOV_XPG4_2");	break;
1718 	default:		prt_dec(pri, 0, val);		break;
1719 	}
1720 }
1721 
1722 
1723 /*
1724  * Print setsockopt()/getsockopt() 2nd argument.
1725  */
1726 /*ARGSUSED*/
1727 void
1728 prt_sol(private_t *pri, int raw, long val)
1729 {
1730 	if (val == SOL_SOCKET) {
1731 		outstring(pri, "SOL_SOCKET");
1732 	} else if (val == SOL_ROUTE) {
1733 		outstring(pri, "SOL_ROUTE");
1734 	} else {
1735 		const struct protoent *p;
1736 		struct protoent res;
1737 		char buf[NSS_BUFLEN_PROTOCOLS];
1738 
1739 		if ((p = getprotobynumber_r(val, &res,
1740 		    (char *)buf, sizeof (buf))) != NULL)
1741 			outstring(pri, p->p_name);
1742 		else
1743 			prt_dec(pri, 0, val);
1744 	}
1745 }
1746 
1747 
1748 const char *
1749 sol_optname(private_t *pri, long val)
1750 {
1751 #define	CBSIZE	sizeof (pri->code_buf)
1752 	if (val >= SO_SNDBUF) {
1753 		switch (val) {
1754 		case SO_SNDBUF:		return ("SO_SNDBUF");
1755 		case SO_RCVBUF:		return ("SO_RCVBUF");
1756 		case SO_SNDLOWAT:	return ("SO_SNDLOWAT");
1757 		case SO_RCVLOWAT:	return ("SO_RCVLOWAT");
1758 		case SO_SNDTIMEO:	return ("SO_SNDTIMEO");
1759 		case SO_RCVTIMEO:	return ("SO_RCVTIMEO");
1760 		case SO_ERROR:		return ("SO_ERROR");
1761 		case SO_TYPE:		return ("SO_TYPE");
1762 		case SO_PROTOTYPE:	return ("SO_PROTOTYPE");
1763 		case SO_ANON_MLP:	return ("SO_ANON_MLP");
1764 		case SO_MAC_EXEMPT:	return ("SO_MAC_EXEMPT");
1765 		case SO_ALLZONES:	return ("SO_ALLZONES");
1766 		case SO_MAC_IMPLICIT:	return ("SO_MAC_IMPLICIT");
1767 		case SO_VRRP:		return ("SO_VRRP");
1768 		case SO_EXCLBIND:	return ("SO_EXCLBIND");
1769 		case SO_DOMAIN:		return ("SO_DOMAIN");
1770 
1771 		default:		(void) snprintf(pri->code_buf, CBSIZE,
1772 					    "0x%lx", val);
1773 					return (pri->code_buf);
1774 		}
1775 	} else {
1776 		char *s = pri->code_buf;
1777 		size_t used = 1;
1778 		long val2;
1779 
1780 		*s = '\0';
1781 		val2 = val & ~(SO_DEBUG|SO_ACCEPTCONN|SO_REUSEADDR|SO_KEEPALIVE|
1782 		    SO_DONTROUTE|SO_BROADCAST|SO_USELOOPBACK|SO_LINGER|
1783 		    SO_OOBINLINE|SO_DGRAM_ERRIND|SO_RECVUCRED);
1784 		if (val2)
1785 			used = snprintf(s, CBSIZE, "|0x%lx", val2);
1786 		if (val & SO_DEBUG)
1787 			used = strlcat(s, "|SO_DEBUG", CBSIZE);
1788 		if (val & SO_ACCEPTCONN)
1789 			used = strlcat(s, "|SO_ACCEPTCONN", CBSIZE);
1790 		if (val & SO_REUSEADDR)
1791 			used = strlcat(s, "|SO_REUSEADDR", CBSIZE);
1792 		if (val & SO_KEEPALIVE)
1793 			used = strlcat(s, "|SO_KEEPALIVE", CBSIZE);
1794 		if (val & SO_DONTROUTE)
1795 			used = strlcat(s, "|SO_DONTROUTE", CBSIZE);
1796 		if (val & SO_BROADCAST)
1797 			used = strlcat(s, "|SO_BROADCAST", CBSIZE);
1798 		if (val & SO_USELOOPBACK)
1799 			used = strlcat(s, "|SO_USELOOPBACK", CBSIZE);
1800 		if (val & SO_LINGER)
1801 			used = strlcat(s, "|SO_LINGER", CBSIZE);
1802 		if (val & SO_OOBINLINE)
1803 			used = strlcat(s, "|SO_OOBINLINE", CBSIZE);
1804 		if (val & SO_DGRAM_ERRIND)
1805 			used = strlcat(s, "|SO_DGRAM_ERRIND", CBSIZE);
1806 		if (val & SO_RECVUCRED)
1807 			used = strlcat(s, "|SO_RECVUCRED", CBSIZE);
1808 		if (used >= CBSIZE || val == 0)
1809 			(void) snprintf(s + 1, CBSIZE-1, "0x%lx", val);
1810 		return ((const char *)(s + 1));
1811 	}
1812 #undef CBSIZE
1813 }
1814 
1815 const char *
1816 route_optname(private_t *pri, long val)
1817 {
1818 	switch (val) {
1819 	case RT_AWARE:
1820 		return ("RT_AWARE");
1821 	default:
1822 		(void) snprintf(pri->code_buf, sizeof (pri->code_buf),
1823 		    "0x%lx", val);
1824 		return (pri->code_buf);
1825 	}
1826 }
1827 
1828 const char *
1829 tcp_optname(private_t *pri, long val)
1830 {
1831 	switch (val) {
1832 	case TCP_NODELAY:		return ("TCP_NODELAY");
1833 	case TCP_MAXSEG:		return ("TCP_MAXSEG");
1834 	case TCP_KEEPALIVE:		return ("TCP_KEEPALIVE");
1835 	case TCP_NOTIFY_THRESHOLD:	return ("TCP_NOTIFY_THRESHOLD");
1836 	case TCP_ABORT_THRESHOLD:	return ("TCP_ABORT_THRESHOLD");
1837 	case TCP_CONN_NOTIFY_THRESHOLD:	return ("TCP_CONN_NOTIFY_THRESHOLD");
1838 	case TCP_CONN_ABORT_THRESHOLD:	return ("TCP_CONN_ABORT_THRESHOLD");
1839 	case TCP_RECVDSTADDR:		return ("TCP_RECVDSTADDR");
1840 	case TCP_ANONPRIVBIND:		return ("TCP_ANONPRIVBIND");
1841 	case TCP_EXCLBIND:		return ("TCP_EXCLBIND");
1842 	case TCP_INIT_CWND:		return ("TCP_INIT_CWND");
1843 	case TCP_KEEPALIVE_THRESHOLD:	return ("TCP_KEEPALIVE_THRESHOLD");
1844 	case TCP_KEEPALIVE_ABORT_THRESHOLD:
1845 		return ("TCP_KEEPALIVE_ABORT_THRESHOLD");
1846 	case TCP_CORK:			return ("TCP_CORK");
1847 
1848 	default:			(void) snprintf(pri->code_buf,
1849 					    sizeof (pri->code_buf),
1850 					    "0x%lx", val);
1851 					return (pri->code_buf);
1852 	}
1853 }
1854 
1855 
1856 const char *
1857 sctp_optname(private_t *pri, long val)
1858 {
1859 	switch (val) {
1860 	case SCTP_RTOINFO:		return ("SCTP_RTOINFO");
1861 	case SCTP_ASSOCINFO:		return ("SCTP_ASSOCINFO");
1862 	case SCTP_INITMSG:		return ("SCTP_INITMSG");
1863 	case SCTP_NODELAY:		return ("SCTP_NODELAY");
1864 	case SCTP_AUTOCLOSE:		return ("SCTP_AUTOCLOSE");
1865 	case SCTP_SET_PEER_PRIMARY_ADDR:
1866 		return ("SCTP_SET_PEER_PRIMARY_ADDR");
1867 	case SCTP_PRIMARY_ADDR:		return ("SCTP_PRIMARY_ADDR");
1868 	case SCTP_ADAPTATION_LAYER:	return ("SCTP_ADAPTATION_LAYER");
1869 	case SCTP_DISABLE_FRAGMENTS:	return ("SCTP_DISABLE_FRAGMENTS");
1870 	case SCTP_PEER_ADDR_PARAMS:	return ("SCTP_PEER_ADDR_PARAMS");
1871 	case SCTP_DEFAULT_SEND_PARAM:	return ("SCTP_DEFAULT_SEND_PARAM");
1872 	case SCTP_EVENTS:		return ("SCTP_EVENTS");
1873 	case SCTP_I_WANT_MAPPED_V4_ADDR:
1874 		return ("SCTP_I_WANT_MAPPED_V4_ADDR");
1875 	case SCTP_MAXSEG:		return ("SCTP_MAXSEG");
1876 	case SCTP_STATUS:		return ("SCTP_STATUS");
1877 	case SCTP_GET_PEER_ADDR_INFO:	return ("SCTP_GET_PEER_ADDR_INFO");
1878 
1879 	case SCTP_ADD_ADDR:		return ("SCTP_ADD_ADDR");
1880 	case SCTP_REM_ADDR:		return ("SCTP_REM_ADDR");
1881 
1882 	default:			(void) snprintf(pri->code_buf,
1883 					    sizeof (pri->code_buf),
1884 					    "0x%lx", val);
1885 					return (pri->code_buf);
1886 	}
1887 }
1888 
1889 
1890 const char *
1891 udp_optname(private_t *pri, long val)
1892 {
1893 	switch (val) {
1894 	case UDP_CHECKSUM:		return ("UDP_CHECKSUM");
1895 	case UDP_ANONPRIVBIND:		return ("UDP_ANONPRIVBIND");
1896 	case UDP_EXCLBIND:		return ("UDP_EXCLBIND");
1897 	case UDP_RCVHDR:		return ("UDP_RCVHDR");
1898 	case UDP_NAT_T_ENDPOINT:	return ("UDP_NAT_T_ENDPOINT");
1899 
1900 	default:			(void) snprintf(pri->code_buf,
1901 					    sizeof (pri->code_buf), "0x%lx",
1902 					    val);
1903 					return (pri->code_buf);
1904 	}
1905 }
1906 
1907 
1908 /*
1909  * Print setsockopt()/getsockopt() 3rd argument.
1910  */
1911 /*ARGSUSED*/
1912 void
1913 prt_son(private_t *pri, int raw, long val)
1914 {
1915 	/* cheating -- look at the level */
1916 	switch (pri->sys_args[1]) {
1917 	case SOL_SOCKET:	outstring(pri, sol_optname(pri, val));
1918 				break;
1919 	case SOL_ROUTE:		outstring(pri, route_optname(pri, val));
1920 				break;
1921 	case IPPROTO_TCP:	outstring(pri, tcp_optname(pri, val));
1922 				break;
1923 	case IPPROTO_UDP:	outstring(pri, udp_optname(pri, val));
1924 				break;
1925 	case IPPROTO_SCTP:	outstring(pri, sctp_optname(pri, val));
1926 				break;
1927 	default:		prt_dec(pri, 0, val);
1928 				break;
1929 	}
1930 }
1931 
1932 
1933 /*
1934  * Print utrap type
1935  */
1936 /*ARGSUSED*/
1937 void
1938 prt_utt(private_t *pri, int raw, long val)
1939 {
1940 	const char *s = NULL;
1941 
1942 #ifdef __sparc
1943 	if (!raw) {
1944 		switch (val) {
1945 		case UT_INSTRUCTION_DISABLED:
1946 			s = "UT_INSTRUCTION_DISABLED"; break;
1947 		case UT_INSTRUCTION_ERROR:
1948 			s = "UT_INSTRUCTION_ERROR"; break;
1949 		case UT_INSTRUCTION_PROTECTION:
1950 			s = "UT_INSTRUCTION_PROTECTION"; break;
1951 		case UT_ILLTRAP_INSTRUCTION:
1952 			s = "UT_ILLTRAP_INSTRUCTION"; break;
1953 		case UT_ILLEGAL_INSTRUCTION:
1954 			s = "UT_ILLEGAL_INSTRUCTION"; break;
1955 		case UT_PRIVILEGED_OPCODE:
1956 			s = "UT_PRIVILEGED_OPCODE"; break;
1957 		case UT_FP_DISABLED:
1958 			s = "UT_FP_DISABLED"; break;
1959 		case UT_FP_EXCEPTION_IEEE_754:
1960 			s = "UT_FP_EXCEPTION_IEEE_754"; break;
1961 		case UT_FP_EXCEPTION_OTHER:
1962 			s = "UT_FP_EXCEPTION_OTHER"; break;
1963 		case UT_TAG_OVERFLOW:
1964 			s = "UT_TAG_OVERFLOW"; break;
1965 		case UT_DIVISION_BY_ZERO:
1966 			s = "UT_DIVISION_BY_ZERO"; break;
1967 		case UT_DATA_EXCEPTION:
1968 			s = "UT_DATA_EXCEPTION"; break;
1969 		case UT_DATA_ERROR:
1970 			s = "UT_DATA_ERROR"; break;
1971 		case UT_DATA_PROTECTION:
1972 			s = "UT_DATA_PROTECTION"; break;
1973 		case UT_MEM_ADDRESS_NOT_ALIGNED:
1974 			s = "UT_MEM_ADDRESS_NOT_ALIGNED"; break;
1975 		case UT_PRIVILEGED_ACTION:
1976 			s = "UT_PRIVILEGED_ACTION"; break;
1977 		case UT_ASYNC_DATA_ERROR:
1978 			s = "UT_ASYNC_DATA_ERROR"; break;
1979 		case UT_TRAP_INSTRUCTION_16:
1980 			s = "UT_TRAP_INSTRUCTION_16"; break;
1981 		case UT_TRAP_INSTRUCTION_17:
1982 			s = "UT_TRAP_INSTRUCTION_17"; break;
1983 		case UT_TRAP_INSTRUCTION_18:
1984 			s = "UT_TRAP_INSTRUCTION_18"; break;
1985 		case UT_TRAP_INSTRUCTION_19:
1986 			s = "UT_TRAP_INSTRUCTION_19"; break;
1987 		case UT_TRAP_INSTRUCTION_20:
1988 			s = "UT_TRAP_INSTRUCTION_20"; break;
1989 		case UT_TRAP_INSTRUCTION_21:
1990 			s = "UT_TRAP_INSTRUCTION_21"; break;
1991 		case UT_TRAP_INSTRUCTION_22:
1992 			s = "UT_TRAP_INSTRUCTION_22"; break;
1993 		case UT_TRAP_INSTRUCTION_23:
1994 			s = "UT_TRAP_INSTRUCTION_23"; break;
1995 		case UT_TRAP_INSTRUCTION_24:
1996 			s = "UT_TRAP_INSTRUCTION_24"; break;
1997 		case UT_TRAP_INSTRUCTION_25:
1998 			s = "UT_TRAP_INSTRUCTION_25"; break;
1999 		case UT_TRAP_INSTRUCTION_26:
2000 			s = "UT_TRAP_INSTRUCTION_26"; break;
2001 		case UT_TRAP_INSTRUCTION_27:
2002 			s = "UT_TRAP_INSTRUCTION_27"; break;
2003 		case UT_TRAP_INSTRUCTION_28:
2004 			s = "UT_TRAP_INSTRUCTION_28"; break;
2005 		case UT_TRAP_INSTRUCTION_29:
2006 			s = "UT_TRAP_INSTRUCTION_29"; break;
2007 		case UT_TRAP_INSTRUCTION_30:
2008 			s = "UT_TRAP_INSTRUCTION_30"; break;
2009 		case UT_TRAP_INSTRUCTION_31:
2010 			s = "UT_TRAP_INSTRUCTION_31"; break;
2011 		}
2012 	}
2013 #endif /* __sparc */
2014 
2015 	if (s == NULL)
2016 		prt_dec(pri, 0, val);
2017 	else
2018 		outstring(pri, s);
2019 }
2020 
2021 
2022 /*
2023  * Print utrap handler
2024  */
2025 void
2026 prt_uth(private_t *pri, int raw, long val)
2027 {
2028 	const char *s = NULL;
2029 
2030 	if (!raw) {
2031 		switch (val) {
2032 		case (long)UTH_NOCHANGE:	s = "UTH_NOCHANGE"; break;
2033 		}
2034 	}
2035 
2036 	if (s == NULL)
2037 		prt_hex(pri, 0, val);
2038 	else
2039 		outstring(pri, s);
2040 }
2041 
2042 const char *
2043 access_flags(private_t *pri, long arg)
2044 {
2045 #define	E_OK 010
2046 	char *str = pri->code_buf;
2047 
2048 	if (arg & ~(R_OK|W_OK|X_OK|E_OK))
2049 		return (NULL);
2050 
2051 	/* NB: F_OK == 0 */
2052 	if (arg == F_OK)
2053 		return ("F_OK");
2054 	if (arg == E_OK)
2055 		return ("F_OK|E_OK");
2056 
2057 	*str = '\0';
2058 	if (arg & R_OK)
2059 		(void) strlcat(str, "|R_OK", sizeof (pri->code_buf));
2060 	if (arg & W_OK)
2061 		(void) strlcat(str, "|W_OK", sizeof (pri->code_buf));
2062 	if (arg & X_OK)
2063 		(void) strlcat(str, "|X_OK", sizeof (pri->code_buf));
2064 	if (arg & E_OK)
2065 		(void) strlcat(str, "|E_OK", sizeof (pri->code_buf));
2066 	return ((const char *)(str + 1));
2067 #undef E_OK
2068 }
2069 
2070 /*
2071  * Print access() flags.
2072  */
2073 void
2074 prt_acc(private_t *pri, int raw, long val)
2075 {
2076 	const char *s = raw? NULL : access_flags(pri, val);
2077 
2078 	if (s == NULL)
2079 		prt_dex(pri, 0, val);
2080 	else
2081 		outstring(pri, s);
2082 }
2083 
2084 /*
2085  * Print shutdown() "how" (2nd) argument
2086  */
2087 void
2088 prt_sht(private_t *pri, int raw, long val)
2089 {
2090 	if (raw) {
2091 		prt_dex(pri, 0, val);
2092 		return;
2093 	}
2094 	switch (val) {
2095 	case SHUT_RD:	outstring(pri, "SHUT_RD");	break;
2096 	case SHUT_WR:	outstring(pri, "SHUT_WR");	break;
2097 	case SHUT_RDWR:	outstring(pri, "SHUT_RDWR");	break;
2098 	default:	prt_dec(pri, 0, val);		break;
2099 	}
2100 }
2101 
2102 /*
2103  * Print fcntl() F_SETFL flags (3rd) argument or fdsync flag (2nd arg)
2104  */
2105 static struct fcntl_flags {
2106 	long		val;
2107 	const char	*name;
2108 } fcntl_flags[] = {
2109 #define	FC_FL(flag)	{ (long)flag, "|" # flag }
2110 	FC_FL(FREVOKED),
2111 	FC_FL(FREAD),
2112 	FC_FL(FWRITE),
2113 	FC_FL(FNDELAY),
2114 	FC_FL(FAPPEND),
2115 	FC_FL(FSYNC),
2116 	FC_FL(FDSYNC),
2117 	FC_FL(FRSYNC),
2118 	FC_FL(FOFFMAX),
2119 	FC_FL(FNONBLOCK),
2120 	FC_FL(FCREAT),
2121 	FC_FL(FTRUNC),
2122 	FC_FL(FEXCL),
2123 	FC_FL(FNOCTTY),
2124 	FC_FL(FXATTR),
2125 	FC_FL(FASYNC),
2126 	FC_FL(FNODSYNC)
2127 #undef FC_FL
2128 };
2129 
2130 void
2131 prt_ffg(private_t *pri, int raw, long val)
2132 {
2133 #define	CBSIZE	sizeof (pri->code_buf)
2134 	char *s = pri->code_buf;
2135 	size_t used = 1;
2136 	struct fcntl_flags *fp;
2137 
2138 	if (raw) {
2139 		(void) snprintf(s, CBSIZE, "0x%lx", val);
2140 		outstring(pri, s);
2141 		return;
2142 	}
2143 	if (val == 0) {
2144 		outstring(pri, "(no flags)");
2145 		return;
2146 	}
2147 
2148 	*s = '\0';
2149 	for (fp = fcntl_flags;
2150 	    fp < &fcntl_flags[sizeof (fcntl_flags) / sizeof (*fp)]; fp++) {
2151 		if (val & fp->val) {
2152 			used = strlcat(s, fp->name, CBSIZE);
2153 			val &= ~fp->val;
2154 		}
2155 	}
2156 
2157 	if (val != 0 && used <= CBSIZE)
2158 		used += snprintf(s + used, CBSIZE - used, "|0x%lx", val);
2159 
2160 	if (used >= CBSIZE)
2161 		(void) snprintf(s + 1, CBSIZE-1, "0x%lx", val);
2162 	outstring(pri, s + 1);
2163 #undef CBSIZE
2164 }
2165 
2166 void
2167 prt_prs(private_t *pri, int raw, long val)
2168 {
2169 	static size_t setsize;
2170 	priv_set_t *set = priv_allocset();
2171 
2172 	if (setsize == 0) {
2173 		const priv_impl_info_t *info = getprivimplinfo();
2174 		if (info != NULL)
2175 			setsize = info->priv_setsize * sizeof (priv_chunk_t);
2176 	}
2177 
2178 	if (setsize != 0 && !raw && set != NULL &&
2179 	    Pread(Proc, set, setsize, val) == setsize) {
2180 		int i;
2181 
2182 		outstring(pri, "{");
2183 		for (i = 0; i < setsize / sizeof (priv_chunk_t); i++) {
2184 			char buf[9];	/* 8 hex digits + '\0' */
2185 			(void) snprintf(buf, sizeof (buf), "%08x",
2186 			    ((priv_chunk_t *)set)[i]);
2187 			outstring(pri, buf);
2188 		}
2189 
2190 		outstring(pri, "}");
2191 	} else {
2192 		prt_hex(pri, 0, val);
2193 	}
2194 
2195 	if (set != NULL)
2196 		priv_freeset(set);
2197 }
2198 
2199 /*
2200  * Print privilege set operation.
2201  */
2202 void
2203 prt_pro(private_t *pri, int raw, long val)
2204 {
2205 	const char *s = NULL;
2206 
2207 	if (!raw) {
2208 		switch ((priv_op_t)val) {
2209 		case PRIV_ON:		s = "PRIV_ON";		break;
2210 		case PRIV_OFF:		s = "PRIV_OFF";		break;
2211 		case PRIV_SET:		s = "PRIV_SET";		break;
2212 		}
2213 	}
2214 
2215 	if (s == NULL)
2216 		prt_dec(pri, 0, val);
2217 	else
2218 		outstring(pri, s);
2219 }
2220 
2221 /*
2222  * Print privilege set name
2223  */
2224 void
2225 prt_prn(private_t *pri, int raw, long val)
2226 {
2227 	const char *s = NULL;
2228 
2229 	if (!raw)
2230 		s = priv_getsetbynum((int)val);
2231 
2232 	if (s == NULL)
2233 		prt_dec(pri, 0, val);
2234 	else {
2235 		char *dup = strdup(s);
2236 		char *q;
2237 
2238 		/* Do the best we can in this case */
2239 		if (dup == NULL) {
2240 			outstring(pri, s);
2241 			return;
2242 		}
2243 
2244 		outstring(pri, "PRIV_");
2245 
2246 		q = dup;
2247 
2248 		while (*q != '\0') {
2249 			*q = toupper(*q);
2250 			q++;
2251 		}
2252 		outstring(pri, dup);
2253 		free(dup);
2254 	}
2255 }
2256 
2257 /*
2258  * Print process flag names.
2259  */
2260 void
2261 prt_pfl(private_t *pri, int raw, long val)
2262 {
2263 	const char *s = NULL;
2264 
2265 	if (!raw) {
2266 		switch ((int)val) {
2267 		case PRIV_DEBUG:	s = "PRIV_DEBUG";	break;
2268 		case PRIV_AWARE:	s = "PRIV_AWARE";	break;
2269 		case PRIV_XPOLICY:	s = "PRIV_XPOLICY";	break;
2270 		case PRIV_AWARE_RESET:  s = "PRIV_AWARE_RESET"; break;
2271 		case NET_MAC_AWARE:	s =  "NET_MAC_AWARE";	break;
2272 		case NET_MAC_AWARE_INHERIT:
2273 			s = "NET_MAC_AWARE_INHERIT";
2274 			break;
2275 		}
2276 	}
2277 
2278 	if (s == NULL)
2279 		prt_dec(pri, 0, val);
2280 	else
2281 		outstring(pri, s);
2282 }
2283 
2284 /*
2285  * Print lgrp_affinity_{get,set}() arguments.
2286  */
2287 /*ARGSUSED*/
2288 void
2289 prt_laf(private_t *pri, int raw, long val)
2290 {
2291 	lgrp_affinity_args_t	laff;
2292 
2293 	if (Pread(Proc, &laff, sizeof (lgrp_affinity_args_t), val) !=
2294 	    sizeof (lgrp_affinity_args_t)) {
2295 		prt_hex(pri, 0, val);
2296 		return;
2297 	}
2298 	/*
2299 	 * arrange the arguments in the order that user calls with
2300 	 */
2301 	prt_dec(pri, 0, laff.idtype);
2302 	outstring(pri, ", ");
2303 	prt_dec(pri, 0, laff.id);
2304 	outstring(pri, ", ");
2305 	prt_dec(pri, 0, laff.lgrp);
2306 	outstring(pri, ", ");
2307 	if (pri->sys_args[0] == LGRP_SYS_AFFINITY_SET)
2308 		prt_dec(pri, 0, laff.aff);
2309 }
2310 
2311 /*
2312  * Print a key_t as IPC_PRIVATE if it is 0.
2313  */
2314 void
2315 prt_key(private_t *pri, int raw, long val)
2316 {
2317 	if (!raw && val == 0)
2318 		outstring(pri, "IPC_PRIVATE");
2319 	else
2320 		prt_dec(pri, 0, val);
2321 }
2322 
2323 
2324 /*
2325  * Print zone_getattr() attribute types.
2326  */
2327 void
2328 prt_zga(private_t *pri, int raw, long val)
2329 {
2330 	const char *s = NULL;
2331 
2332 	if (!raw) {
2333 		switch ((int)val) {
2334 		case ZONE_ATTR_NAME:	s = "ZONE_ATTR_NAME";	break;
2335 		case ZONE_ATTR_ROOT:	s = "ZONE_ATTR_ROOT";	break;
2336 		case ZONE_ATTR_STATUS:	s = "ZONE_ATTR_STATUS";	break;
2337 		case ZONE_ATTR_PRIVSET:	s = "ZONE_ATTR_PRIVSET"; break;
2338 		case ZONE_ATTR_UNIQID:	s = "ZONE_ATTR_UNIQID"; break;
2339 		case ZONE_ATTR_POOLID:	s = "ZONE_ATTR_POOLID"; break;
2340 		case ZONE_ATTR_INITPID:	s = "ZONE_ATTR_INITPID"; break;
2341 		case ZONE_ATTR_SLBL:	s = "ZONE_ATTR_SLBL"; break;
2342 		case ZONE_ATTR_INITNAME:	s = "ZONE_ATTR_INITNAME"; break;
2343 		case ZONE_ATTR_BOOTARGS:	s = "ZONE_ATTR_BOOTARGS"; break;
2344 		case ZONE_ATTR_BRAND:	s = "ZONE_ATTR_BRAND"; break;
2345 		case ZONE_ATTR_FLAGS:	s = "ZONE_ATTR_FLAGS"; break;
2346 		case ZONE_ATTR_PHYS_MCAP: s = "ZONE_ATTR_PHYS_MCAP"; break;
2347 		}
2348 	}
2349 
2350 	if (s == NULL)
2351 		prt_dec(pri, 0, val);
2352 	else
2353 		outstring(pri, s);
2354 }
2355 
2356 /*
2357  * Print a file descriptor as AT_FDCWD if necessary
2358  */
2359 void
2360 prt_atc(private_t *pri, int raw, long val)
2361 {
2362 	if (!raw && val == AT_FDCWD)
2363 		outstring(pri, "AT_FDCWD");
2364 	else
2365 		prt_dec(pri, 0, val);
2366 }
2367 
2368 /*
2369  * Print Trusted Networking database operation codes (labelsys; tn*)
2370  */
2371 static void
2372 prt_tnd(private_t *pri, int raw, long val)
2373 {
2374 	const char *s = NULL;
2375 
2376 	if (!raw) {
2377 		switch ((tsol_dbops_t)val) {
2378 		case TNDB_NOOP:		s = "TNDB_NOOP";	break;
2379 		case TNDB_LOAD:		s = "TNDB_LOAD";	break;
2380 		case TNDB_DELETE:	s = "TNDB_DELETE";	break;
2381 		case TNDB_FLUSH:	s = "TNDB_FLUSH";	break;
2382 		case TNDB_GET:		s = "TNDB_GET";		break;
2383 		}
2384 	}
2385 
2386 	if (s == NULL)
2387 		prt_dec(pri, 0, val);
2388 	else
2389 		outstring(pri, s);
2390 }
2391 
2392 /*
2393  * Print LIO_XX flags
2394  */
2395 void
2396 prt_lio(private_t *pri, int raw, long val)
2397 {
2398 	if (raw)
2399 		prt_dec(pri, 0, val);
2400 	else if (val == LIO_WAIT)
2401 		outstring(pri, "LIO_WAIT");
2402 	else if (val == LIO_NOWAIT)
2403 		outstring(pri, "LIO_NOWAIT");
2404 	else
2405 		prt_dec(pri, 0, val);
2406 }
2407 
2408 const char *
2409 door_flags(private_t *pri, long val)
2410 {
2411 	door_attr_t attr = (door_attr_t)val;
2412 	char *str = pri->code_buf;
2413 
2414 	*str = '\0';
2415 #define	PROCESS_FLAG(flg)						\
2416 	if (attr & flg) {						\
2417 		(void) strlcat(str, "|" #flg, sizeof (pri->code_buf));	\
2418 		attr &= ~flg;						\
2419 	}
2420 
2421 	PROCESS_FLAG(DOOR_UNREF);
2422 	PROCESS_FLAG(DOOR_UNREF_MULTI);
2423 	PROCESS_FLAG(DOOR_PRIVATE);
2424 	PROCESS_FLAG(DOOR_REFUSE_DESC);
2425 	PROCESS_FLAG(DOOR_NO_CANCEL);
2426 	PROCESS_FLAG(DOOR_LOCAL);
2427 	PROCESS_FLAG(DOOR_REVOKED);
2428 	PROCESS_FLAG(DOOR_IS_UNREF);
2429 #undef PROCESS_FLAG
2430 
2431 	if (attr != 0 || *str == '\0') {
2432 		size_t len = strlen(str);
2433 		(void) snprintf(str + len, sizeof (pri->code_buf) - len,
2434 		    "|0x%X", attr);
2435 	}
2436 
2437 	return (str + 1);
2438 }
2439 
2440 /*
2441  * Print door_create() flags
2442  */
2443 void
2444 prt_dfl(private_t *pri, int raw, long val)
2445 {
2446 	if (raw)
2447 		prt_hex(pri, 0, val);
2448 	else
2449 		outstring(pri, door_flags(pri, val));
2450 }
2451 
2452 /*
2453  * Print door_*param() param argument
2454  */
2455 void
2456 prt_dpm(private_t *pri, int raw, long val)
2457 {
2458 	if (raw)
2459 		prt_hex(pri, 0, val);
2460 	else if (val == DOOR_PARAM_DESC_MAX)
2461 		outstring(pri, "DOOR_PARAM_DESC_MAX");
2462 	else if (val == DOOR_PARAM_DATA_MIN)
2463 		outstring(pri, "DOOR_PARAM_DATA_MIN");
2464 	else if (val == DOOR_PARAM_DATA_MAX)
2465 		outstring(pri, "DOOR_PARAM_DATA_MAX");
2466 	else
2467 		prt_hex(pri, 0, val);
2468 }
2469 
2470 /*
2471  * Print rctlsys subcodes
2472  */
2473 void
2474 prt_rsc(private_t *pri, int raw, long val)	/* print utssys code */
2475 {
2476 	const char *s = raw? NULL : rctlsyscode(val);
2477 
2478 	if (s == NULL)
2479 		prt_dec(pri, 0, val);
2480 	else
2481 		outstring(pri, s);
2482 }
2483 
2484 /*
2485  * Print getrctl flags
2486  */
2487 void
2488 prt_rgf(private_t *pri, int raw, long val)
2489 {
2490 	long action = val & (~RCTLSYS_ACTION_MASK);
2491 
2492 	if (raw)
2493 		prt_hex(pri, 0, val);
2494 	else if (action == RCTL_FIRST)
2495 		outstring(pri, "RCTL_FIRST");
2496 	else if (action == RCTL_NEXT)
2497 		outstring(pri, "RCTL_NEXT");
2498 	else if (action == RCTL_USAGE)
2499 		outstring(pri, "RCTL_USAGE");
2500 	else
2501 		prt_hex(pri, 0, val);
2502 }
2503 
2504 /*
2505  * Print setrctl flags
2506  */
2507 void
2508 prt_rsf(private_t *pri, int raw, long val)
2509 {
2510 	long action = val & (~RCTLSYS_ACTION_MASK);
2511 	long pval = val & RCTL_LOCAL_ACTION_MASK;
2512 	char *s = pri->code_buf;
2513 
2514 	if (raw) {
2515 		prt_hex(pri, 0, val);
2516 		return;
2517 	} else if (action == RCTL_INSERT)
2518 		(void) strcpy(s, "RCTL_INSERT");
2519 	else if (action == RCTL_DELETE)
2520 		(void) strcpy(s, "RCTL_DELETE");
2521 	else if (action == RCTL_REPLACE)
2522 		(void) strcpy(s, "RCTL_REPLACE");
2523 	else {
2524 		prt_hex(pri, 0, val);
2525 		return;
2526 	}
2527 
2528 	if (pval & RCTL_USE_RECIPIENT_PID) {
2529 		pval ^= RCTL_USE_RECIPIENT_PID;
2530 		(void) strlcat(s, "|RCTL_USE_RECIPIENT_PID",
2531 		    sizeof (pri->code_buf));
2532 	}
2533 
2534 	if ((pval & RCTLSYS_ACTION_MASK) != 0)
2535 		prt_hex(pri, 0, val);
2536 	else if (*s != '\0')
2537 		outstring(pri, s);
2538 	else
2539 		prt_hex(pri, 0, val);
2540 }
2541 
2542 /*
2543  * Print rctlctl flags
2544  */
2545 void
2546 prt_rcf(private_t *pri, int raw, long val)
2547 {
2548 	long action = val & (~RCTLSYS_ACTION_MASK);
2549 
2550 	if (raw)
2551 		prt_hex(pri, 0, val);
2552 	else if (action == RCTLCTL_GET)
2553 		outstring(pri, "RCTLCTL_GET");
2554 	else if (action == RCTLCTL_SET)
2555 		outstring(pri, "RCTLCTL_SET");
2556 	else
2557 		prt_hex(pri, 0, val);
2558 }
2559 
2560 /*
2561  * Print setprojrctl flags
2562  */
2563 void
2564 prt_spf(private_t *pri, int raw, long val)
2565 {
2566 	long action = val & TASK_PROJ_MASK;
2567 
2568 	if (!raw && (action == TASK_PROJ_PURGE))
2569 		outstring(pri, "TASK_PROJ_PURGE");
2570 	else
2571 		prt_hex(pri, 0, val);
2572 }
2573 
2574 /*
2575  * Print forkx() flags
2576  */
2577 void
2578 prt_fxf(private_t *pri, int raw, long val)
2579 {
2580 	char *str;
2581 
2582 	if (val == 0)
2583 		outstring(pri, "0");
2584 	else if (raw || (val & ~(FORK_NOSIGCHLD | FORK_WAITPID)))
2585 		prt_hhx(pri, 0, val);
2586 	else {
2587 		str = pri->code_buf;
2588 		*str = '\0';
2589 		if (val & FORK_NOSIGCHLD)
2590 			(void) strlcat(str, "|FORK_NOSIGCHLD",
2591 			    sizeof (pri->code_buf));
2592 		if (val & FORK_WAITPID)
2593 			(void) strlcat(str, "|FORK_WAITPID",
2594 			    sizeof (pri->code_buf));
2595 		outstring(pri, str + 1);
2596 	}
2597 }
2598 
2599 /*
2600  * Print utimensat() flag
2601  */
2602 void
2603 prt_utf(private_t *pri, int raw, long val)
2604 {
2605 	if (val == 0)
2606 		outstring(pri, "0");
2607 	else if (!raw && val == AT_SYMLINK_NOFOLLOW)
2608 		outstring(pri, "AT_SYMLINK_NOFOLLOW");
2609 	else
2610 		prt_hex(pri, 0, val);
2611 }
2612 
2613 /*
2614  * Array of pointers to print functions, one for each format.
2615  */
2616 void (* const Print[])() = {
2617 	prt_nov,	/* NOV -- no value */
2618 	prt_dec,	/* DEC -- print value in decimal */
2619 	prt_oct,	/* OCT -- print value in octal */
2620 	prt_hex,	/* HEX -- print value in hexadecimal */
2621 	prt_dex,	/* DEX -- print value in hexadecimal if big enough */
2622 	prt_stg,	/* STG -- print value as string */
2623 	prt_ioc,	/* IOC -- print ioctl code */
2624 	prt_fcn,	/* FCN -- print fcntl code */
2625 	prt_s86,	/* S86 -- print sysi86 code */
2626 	prt_uts,	/* UTS -- print utssys code */
2627 	prt_opn,	/* OPN -- print open code */
2628 	prt_sig,	/* SIG -- print signal name plus flags */
2629 	prt_nov,	/* Was ACT, now available for reuse */
2630 	prt_msc,	/* MSC -- print msgsys command */
2631 	prt_msf,	/* MSF -- print msgsys flags */
2632 	prt_smc,	/* SMC -- print semsys command */
2633 	prt_sef,	/* SEF -- print semsys flags */
2634 	prt_shc,	/* SHC -- print shmsys command */
2635 	prt_shf,	/* SHF -- print shmsys flags */
2636 	prt_plk,	/* PLK -- print plock code */
2637 	prt_sfs,	/* SFS -- print sysfs code */
2638 	prt_rst,	/* RST -- print string returned by syscall */
2639 	prt_smf,	/* SMF -- print streams message flags */
2640 	prt_ioa,	/* IOA -- print ioctl argument */
2641 	prt_nov,	/* Was SIX, now available for reuse */
2642 	prt_mtf,	/* MTF -- print mount flags */
2643 	prt_mft,	/* MFT -- print mount file system type */
2644 	prt_iob,	/* IOB -- print contents of I/O buffer */
2645 	prt_hhx,	/* HHX -- print value in hexadecimal (half size) */
2646 	prt_wop,	/* WOP -- print waitsys() options */
2647 	prt_spm,	/* SPM -- print sigprocmask argument */
2648 	prt_rlk,	/* RLK -- print readlink buffer */
2649 	prt_mpr,	/* MPR -- print mmap()/mprotect() flags */
2650 	prt_mty,	/* MTY -- print mmap() mapping type flags */
2651 	prt_mcf,	/* MCF -- print memcntl() function */
2652 	prt_mc4,	/* MC4 -- print memcntl() (fourth) argument */
2653 	prt_mc5,	/* MC5 -- print memcntl() (fifth) argument */
2654 	prt_mad,	/* MAD -- print madvise() argument */
2655 	prt_ulm,	/* ULM -- print ulimit() argument */
2656 	prt_rlm,	/* RLM -- print get/setrlimit() argument */
2657 	prt_cnf,	/* CNF -- print sysconfig() argument */
2658 	prt_inf,	/* INF -- print sysinfo() argument */
2659 	prt_ptc,	/* PTC -- print pathconf/fpathconf() argument */
2660 	prt_fui,	/* FUI -- print fusers() input argument */
2661 	prt_idt,	/* IDT -- print idtype_t, waitid() argument */
2662 	prt_lwf,	/* LWF -- print lwp_create() flags */
2663 	prt_itm,	/* ITM -- print [get|set]itimer() arg */
2664 	prt_llo,	/* LLO -- print long long offset arg */
2665 	prt_mod,	/* MOD -- print modctl() subcode */
2666 	prt_whn,	/* WHN -- print lseek() whence arguiment */
2667 	prt_acl,	/* ACL -- print acl() code */
2668 	prt_aio,	/* AIO -- print kaio() code */
2669 	prt_aud,	/* AUD -- print auditsys() code */
2670 	prt_uns,	/* DEC -- print value in unsigned decimal */
2671 	prt_clc,	/* CLC -- print cladm command argument */
2672 	prt_clf,	/* CLF -- print cladm flag argument */
2673 	prt_cor,	/* COR -- print corectl() subcode */
2674 	prt_cco,	/* CCO -- print corectl() options */
2675 	prt_ccc,	/* CCC -- print corectl() content */
2676 	prt_rcc,	/* RCC -- print corectl() returned content */
2677 	prt_cpc,	/* CPC -- print cpc() subcode */
2678 	prt_sqc,	/* SQC -- print sigqueue() si_code argument */
2679 	prt_pc4,	/* PC4 -- print priocntlsys() (fourth) argument */
2680 	prt_pc5,	/* PC5 -- print priocntlsys() (key, value) pairs */
2681 	prt_pst,	/* PST -- print processor set id */
2682 	prt_mif,	/* MIF -- print meminfo() arguments */
2683 	prt_pfm,	/* PFM -- print so_socket() proto-family (1st) arg */
2684 	prt_skt,	/* SKT -- print so_socket() socket-type (2nd) arg */
2685 	prt_skp,	/* SKP -- print so_socket() protocol (3rd) arg */
2686 	prt_skv,	/* SKV -- print socket version arg */
2687 	prt_sol,	/* SOL -- print [sg]etsockopt() level (2nd) arg */
2688 	prt_son,	/* SON -- print [sg]etsockopt() opt-name (3rd) arg */
2689 	prt_utt,	/* UTT -- print utrap type */
2690 	prt_uth,	/* UTH -- print utrap handler */
2691 	prt_acc,	/* ACC -- print access() flags */
2692 	prt_sht,	/* SHT -- print shutdown() how (2nd) argument */
2693 	prt_ffg,	/* FFG -- print fcntl() flags (3rd) argument */
2694 	prt_prs,	/* PRS -- print privilege set */
2695 	prt_pro,	/* PRO -- print privilege set operation */
2696 	prt_prn,	/* PRN -- print privilege set name */
2697 	prt_pfl,	/* PFL -- print privilege/process flag name */
2698 	prt_laf,	/* LAF -- print lgrp_affinity arguments */
2699 	prt_key,	/* KEY -- print key_t 0 as IPC_PRIVATE */
2700 	prt_zga,	/* ZGA -- print zone_getattr attribute types */
2701 	prt_atc,	/* ATC -- print AT_FDCWD or file descriptor */
2702 	prt_lio,	/* LIO -- print LIO_XX flags */
2703 	prt_dfl,	/* DFL -- print door_create() flags */
2704 	prt_dpm,	/* DPM -- print DOOR_PARAM_XX flags */
2705 	prt_tnd,	/* TND -- print trusted network data base opcode */
2706 	prt_rsc,	/* RSC -- print rctlsys() subcodes */
2707 	prt_rgf,	/* RGF -- print getrctl() flags */
2708 	prt_rsf,	/* RSF -- print setrctl() flags */
2709 	prt_rcf,	/* RCF -- print rctlsys_ctl() flags */
2710 	prt_fxf,	/* FXF -- print forkx() flags */
2711 	prt_spf,	/* SPF -- print rctlsys_projset() flags */
2712 	prt_un1,	/* UN1 -- as prt_uns except for -1 */
2713 	prt_mob,	/* MOB -- print mmapobj() flags */
2714 	prt_utf,	/* UTF -- print utimensat() flag */
2715 	prt_dec,	/* HID -- hidden argument, make this the last one */
2716 };
2717