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