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