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