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