xref: /titanic_44/usr/src/cmd/truss/print.c (revision 491d31d91dffec9b5f8abaf7728301a572326daa)
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  * Print sockconfig() subcode.
1654  */
1655 /*ARGSUSED*/
1656 void
1657 prt_skc(private_t *pri, int raw, long val)
1658 {
1659 	const char *s = NULL;
1660 
1661 	if (!raw) {
1662 		switch (val) {
1663 		case SOCKCONFIG_ADD_SOCK:
1664 			s = "SOCKCONFIG_ADD_SOCK"; break;
1665 		case SOCKCONFIG_REMOVE_SOCK:
1666 			s = "SOCKCONFIG_REMOVE_SOCK"; break;
1667 		case SOCKCONFIG_ADD_FILTER:
1668 			s = "SOCKCONFIG_ADD_FILTER"; break;
1669 		case SOCKCONFIG_REMOVE_FILTER:
1670 			s = "SOCKCONFIG_REMOVE_FILTER"; break;
1671 		}
1672 	}
1673 	if (s == NULL)
1674 		prt_dec(pri, 0, val);
1675 	else
1676 		outstring(pri, s);
1677 }
1678 /*
1679  * Print so_socket() 2nd argument.
1680  */
1681 /*ARGSUSED*/
1682 void
1683 prt_skt(private_t *pri, int raw, long val)
1684 {
1685 	const char *s;
1686 
1687 	if ((ulong_t)val <= MAX_SOCKTYPES && (s = socktype_codes[val]) != NULL)
1688 		outstring(pri, s);
1689 	else
1690 		prt_dec(pri, 0, val);
1691 }
1692 
1693 
1694 /*
1695  * Print so_socket() 3rd argument.
1696  */
1697 /*ARGSUSED*/
1698 void
1699 prt_skp(private_t *pri, int raw, long val)
1700 {
1701 	const char *s;
1702 
1703 	/* cheating -- look at the protocol-family */
1704 	switch (pri->sys_args[0]) {
1705 	case PF_INET6:
1706 	case PF_INET:
1707 	case PF_NCA:	if ((s = ipprotos((int)val)) != NULL) {
1708 				outstring(pri, s);
1709 				break;
1710 			}
1711 			/* FALLTHROUGH */
1712 	default:	prt_dec(pri, 0, val);
1713 			break;
1714 	}
1715 }
1716 
1717 
1718 /*
1719  * Print so_socket() 5th argument.
1720  */
1721 /*ARGSUSED*/
1722 void
1723 prt_skv(private_t *pri, int raw, long val)
1724 {
1725 	switch (val) {
1726 	case SOV_STREAM:	outstring(pri, "SOV_STREAM");	break;
1727 	case SOV_DEFAULT:	outstring(pri, "SOV_DEFAULT");	break;
1728 	case SOV_SOCKSTREAM:	outstring(pri, "SOV_SOCKSTREAM");	break;
1729 	case SOV_SOCKBSD:	outstring(pri, "SOV_SOCKBSD");	break;
1730 	case SOV_XPG4_2:	outstring(pri, "SOV_XPG4_2");	break;
1731 	default:		prt_dec(pri, 0, val);		break;
1732 	}
1733 }
1734 
1735 
1736 /*
1737  * Print setsockopt()/getsockopt() 2nd argument.
1738  */
1739 /*ARGSUSED*/
1740 void
1741 prt_sol(private_t *pri, int raw, long val)
1742 {
1743 	if (val == SOL_SOCKET) {
1744 		outstring(pri, "SOL_SOCKET");
1745 	} else if (val == SOL_ROUTE) {
1746 		outstring(pri, "SOL_ROUTE");
1747 	} else {
1748 		const struct protoent *p;
1749 		struct protoent res;
1750 		char buf[NSS_BUFLEN_PROTOCOLS];
1751 
1752 		if ((p = getprotobynumber_r(val, &res,
1753 		    (char *)buf, sizeof (buf))) != NULL)
1754 			outstring(pri, p->p_name);
1755 		else
1756 			prt_dec(pri, 0, val);
1757 	}
1758 }
1759 
1760 
1761 const char *
1762 sol_optname(private_t *pri, long val)
1763 {
1764 #define	CBSIZE	sizeof (pri->code_buf)
1765 	if (val >= SO_SNDBUF) {
1766 		switch (val) {
1767 		case SO_SNDBUF:		return ("SO_SNDBUF");
1768 		case SO_RCVBUF:		return ("SO_RCVBUF");
1769 		case SO_SNDLOWAT:	return ("SO_SNDLOWAT");
1770 		case SO_RCVLOWAT:	return ("SO_RCVLOWAT");
1771 		case SO_SNDTIMEO:	return ("SO_SNDTIMEO");
1772 		case SO_RCVTIMEO:	return ("SO_RCVTIMEO");
1773 		case SO_ERROR:		return ("SO_ERROR");
1774 		case SO_TYPE:		return ("SO_TYPE");
1775 		case SO_PROTOTYPE:	return ("SO_PROTOTYPE");
1776 		case SO_ANON_MLP:	return ("SO_ANON_MLP");
1777 		case SO_MAC_EXEMPT:	return ("SO_MAC_EXEMPT");
1778 		case SO_ALLZONES:	return ("SO_ALLZONES");
1779 		case SO_MAC_IMPLICIT:	return ("SO_MAC_IMPLICIT");
1780 		case SO_VRRP:		return ("SO_VRRP");
1781 		case SO_EXCLBIND:	return ("SO_EXCLBIND");
1782 		case SO_DOMAIN:		return ("SO_DOMAIN");
1783 
1784 		default:		(void) snprintf(pri->code_buf, CBSIZE,
1785 					    "0x%lx", val);
1786 					return (pri->code_buf);
1787 		}
1788 	} else {
1789 		char *s = pri->code_buf;
1790 		size_t used = 1;
1791 		long val2;
1792 
1793 		*s = '\0';
1794 		val2 = val & ~(SO_DEBUG|SO_ACCEPTCONN|SO_REUSEADDR|SO_KEEPALIVE|
1795 		    SO_DONTROUTE|SO_BROADCAST|SO_USELOOPBACK|SO_LINGER|
1796 		    SO_OOBINLINE|SO_DGRAM_ERRIND|SO_RECVUCRED);
1797 		if (val2)
1798 			used = snprintf(s, CBSIZE, "|0x%lx", val2);
1799 		if (val & SO_DEBUG)
1800 			used = strlcat(s, "|SO_DEBUG", CBSIZE);
1801 		if (val & SO_ACCEPTCONN)
1802 			used = strlcat(s, "|SO_ACCEPTCONN", CBSIZE);
1803 		if (val & SO_REUSEADDR)
1804 			used = strlcat(s, "|SO_REUSEADDR", CBSIZE);
1805 		if (val & SO_KEEPALIVE)
1806 			used = strlcat(s, "|SO_KEEPALIVE", CBSIZE);
1807 		if (val & SO_DONTROUTE)
1808 			used = strlcat(s, "|SO_DONTROUTE", CBSIZE);
1809 		if (val & SO_BROADCAST)
1810 			used = strlcat(s, "|SO_BROADCAST", CBSIZE);
1811 		if (val & SO_USELOOPBACK)
1812 			used = strlcat(s, "|SO_USELOOPBACK", CBSIZE);
1813 		if (val & SO_LINGER)
1814 			used = strlcat(s, "|SO_LINGER", CBSIZE);
1815 		if (val & SO_OOBINLINE)
1816 			used = strlcat(s, "|SO_OOBINLINE", CBSIZE);
1817 		if (val & SO_DGRAM_ERRIND)
1818 			used = strlcat(s, "|SO_DGRAM_ERRIND", CBSIZE);
1819 		if (val & SO_RECVUCRED)
1820 			used = strlcat(s, "|SO_RECVUCRED", CBSIZE);
1821 		if (used >= CBSIZE || val == 0)
1822 			(void) snprintf(s + 1, CBSIZE-1, "0x%lx", val);
1823 		return ((const char *)(s + 1));
1824 	}
1825 #undef CBSIZE
1826 }
1827 
1828 const char *
1829 route_optname(private_t *pri, long val)
1830 {
1831 	switch (val) {
1832 	case RT_AWARE:
1833 		return ("RT_AWARE");
1834 	default:
1835 		(void) snprintf(pri->code_buf, sizeof (pri->code_buf),
1836 		    "0x%lx", val);
1837 		return (pri->code_buf);
1838 	}
1839 }
1840 
1841 const char *
1842 tcp_optname(private_t *pri, long val)
1843 {
1844 	switch (val) {
1845 	case TCP_NODELAY:		return ("TCP_NODELAY");
1846 	case TCP_MAXSEG:		return ("TCP_MAXSEG");
1847 	case TCP_KEEPALIVE:		return ("TCP_KEEPALIVE");
1848 	case TCP_NOTIFY_THRESHOLD:	return ("TCP_NOTIFY_THRESHOLD");
1849 	case TCP_ABORT_THRESHOLD:	return ("TCP_ABORT_THRESHOLD");
1850 	case TCP_CONN_NOTIFY_THRESHOLD:	return ("TCP_CONN_NOTIFY_THRESHOLD");
1851 	case TCP_CONN_ABORT_THRESHOLD:	return ("TCP_CONN_ABORT_THRESHOLD");
1852 	case TCP_RECVDSTADDR:		return ("TCP_RECVDSTADDR");
1853 	case TCP_ANONPRIVBIND:		return ("TCP_ANONPRIVBIND");
1854 	case TCP_EXCLBIND:		return ("TCP_EXCLBIND");
1855 	case TCP_INIT_CWND:		return ("TCP_INIT_CWND");
1856 	case TCP_KEEPALIVE_THRESHOLD:	return ("TCP_KEEPALIVE_THRESHOLD");
1857 	case TCP_KEEPALIVE_ABORT_THRESHOLD:
1858 		return ("TCP_KEEPALIVE_ABORT_THRESHOLD");
1859 	case TCP_CORK:			return ("TCP_CORK");
1860 	case TCP_RTO_INITIAL:		return ("TCP_RTO_INITIAL");
1861 	case TCP_RTO_MIN:		return ("TCP_RTO_MIN");
1862 	case TCP_RTO_MAX:		return ("TCP_RTO_MAX");
1863 	case TCP_LINGER2:		return ("TCP_LINGER2");
1864 
1865 	default:			(void) snprintf(pri->code_buf,
1866 					    sizeof (pri->code_buf),
1867 					    "0x%lx", val);
1868 					return (pri->code_buf);
1869 	}
1870 }
1871 
1872 
1873 const char *
1874 sctp_optname(private_t *pri, long val)
1875 {
1876 	switch (val) {
1877 	case SCTP_RTOINFO:		return ("SCTP_RTOINFO");
1878 	case SCTP_ASSOCINFO:		return ("SCTP_ASSOCINFO");
1879 	case SCTP_INITMSG:		return ("SCTP_INITMSG");
1880 	case SCTP_NODELAY:		return ("SCTP_NODELAY");
1881 	case SCTP_AUTOCLOSE:		return ("SCTP_AUTOCLOSE");
1882 	case SCTP_SET_PEER_PRIMARY_ADDR:
1883 		return ("SCTP_SET_PEER_PRIMARY_ADDR");
1884 	case SCTP_PRIMARY_ADDR:		return ("SCTP_PRIMARY_ADDR");
1885 	case SCTP_ADAPTATION_LAYER:	return ("SCTP_ADAPTATION_LAYER");
1886 	case SCTP_DISABLE_FRAGMENTS:	return ("SCTP_DISABLE_FRAGMENTS");
1887 	case SCTP_PEER_ADDR_PARAMS:	return ("SCTP_PEER_ADDR_PARAMS");
1888 	case SCTP_DEFAULT_SEND_PARAM:	return ("SCTP_DEFAULT_SEND_PARAM");
1889 	case SCTP_EVENTS:		return ("SCTP_EVENTS");
1890 	case SCTP_I_WANT_MAPPED_V4_ADDR:
1891 		return ("SCTP_I_WANT_MAPPED_V4_ADDR");
1892 	case SCTP_MAXSEG:		return ("SCTP_MAXSEG");
1893 	case SCTP_STATUS:		return ("SCTP_STATUS");
1894 	case SCTP_GET_PEER_ADDR_INFO:	return ("SCTP_GET_PEER_ADDR_INFO");
1895 
1896 	case SCTP_ADD_ADDR:		return ("SCTP_ADD_ADDR");
1897 	case SCTP_REM_ADDR:		return ("SCTP_REM_ADDR");
1898 
1899 	default:			(void) snprintf(pri->code_buf,
1900 					    sizeof (pri->code_buf),
1901 					    "0x%lx", val);
1902 					return (pri->code_buf);
1903 	}
1904 }
1905 
1906 
1907 const char *
1908 udp_optname(private_t *pri, long val)
1909 {
1910 	switch (val) {
1911 	case UDP_CHECKSUM:		return ("UDP_CHECKSUM");
1912 	case UDP_ANONPRIVBIND:		return ("UDP_ANONPRIVBIND");
1913 	case UDP_EXCLBIND:		return ("UDP_EXCLBIND");
1914 	case UDP_RCVHDR:		return ("UDP_RCVHDR");
1915 	case UDP_NAT_T_ENDPOINT:	return ("UDP_NAT_T_ENDPOINT");
1916 
1917 	default:			(void) snprintf(pri->code_buf,
1918 					    sizeof (pri->code_buf), "0x%lx",
1919 					    val);
1920 					return (pri->code_buf);
1921 	}
1922 }
1923 
1924 
1925 /*
1926  * Print setsockopt()/getsockopt() 3rd argument.
1927  */
1928 /*ARGSUSED*/
1929 void
1930 prt_son(private_t *pri, int raw, long val)
1931 {
1932 	/* cheating -- look at the level */
1933 	switch (pri->sys_args[1]) {
1934 	case SOL_SOCKET:	outstring(pri, sol_optname(pri, val));
1935 				break;
1936 	case SOL_ROUTE:		outstring(pri, route_optname(pri, val));
1937 				break;
1938 	case IPPROTO_TCP:	outstring(pri, tcp_optname(pri, val));
1939 				break;
1940 	case IPPROTO_UDP:	outstring(pri, udp_optname(pri, val));
1941 				break;
1942 	case IPPROTO_SCTP:	outstring(pri, sctp_optname(pri, val));
1943 				break;
1944 	default:		prt_dec(pri, 0, val);
1945 				break;
1946 	}
1947 }
1948 
1949 
1950 /*
1951  * Print utrap type
1952  */
1953 /*ARGSUSED*/
1954 void
1955 prt_utt(private_t *pri, int raw, long val)
1956 {
1957 	const char *s = NULL;
1958 
1959 #ifdef __sparc
1960 	if (!raw) {
1961 		switch (val) {
1962 		case UT_INSTRUCTION_DISABLED:
1963 			s = "UT_INSTRUCTION_DISABLED"; break;
1964 		case UT_INSTRUCTION_ERROR:
1965 			s = "UT_INSTRUCTION_ERROR"; break;
1966 		case UT_INSTRUCTION_PROTECTION:
1967 			s = "UT_INSTRUCTION_PROTECTION"; break;
1968 		case UT_ILLTRAP_INSTRUCTION:
1969 			s = "UT_ILLTRAP_INSTRUCTION"; break;
1970 		case UT_ILLEGAL_INSTRUCTION:
1971 			s = "UT_ILLEGAL_INSTRUCTION"; break;
1972 		case UT_PRIVILEGED_OPCODE:
1973 			s = "UT_PRIVILEGED_OPCODE"; break;
1974 		case UT_FP_DISABLED:
1975 			s = "UT_FP_DISABLED"; break;
1976 		case UT_FP_EXCEPTION_IEEE_754:
1977 			s = "UT_FP_EXCEPTION_IEEE_754"; break;
1978 		case UT_FP_EXCEPTION_OTHER:
1979 			s = "UT_FP_EXCEPTION_OTHER"; break;
1980 		case UT_TAG_OVERFLOW:
1981 			s = "UT_TAG_OVERFLOW"; break;
1982 		case UT_DIVISION_BY_ZERO:
1983 			s = "UT_DIVISION_BY_ZERO"; break;
1984 		case UT_DATA_EXCEPTION:
1985 			s = "UT_DATA_EXCEPTION"; break;
1986 		case UT_DATA_ERROR:
1987 			s = "UT_DATA_ERROR"; break;
1988 		case UT_DATA_PROTECTION:
1989 			s = "UT_DATA_PROTECTION"; break;
1990 		case UT_MEM_ADDRESS_NOT_ALIGNED:
1991 			s = "UT_MEM_ADDRESS_NOT_ALIGNED"; break;
1992 		case UT_PRIVILEGED_ACTION:
1993 			s = "UT_PRIVILEGED_ACTION"; break;
1994 		case UT_ASYNC_DATA_ERROR:
1995 			s = "UT_ASYNC_DATA_ERROR"; break;
1996 		case UT_TRAP_INSTRUCTION_16:
1997 			s = "UT_TRAP_INSTRUCTION_16"; break;
1998 		case UT_TRAP_INSTRUCTION_17:
1999 			s = "UT_TRAP_INSTRUCTION_17"; break;
2000 		case UT_TRAP_INSTRUCTION_18:
2001 			s = "UT_TRAP_INSTRUCTION_18"; break;
2002 		case UT_TRAP_INSTRUCTION_19:
2003 			s = "UT_TRAP_INSTRUCTION_19"; break;
2004 		case UT_TRAP_INSTRUCTION_20:
2005 			s = "UT_TRAP_INSTRUCTION_20"; break;
2006 		case UT_TRAP_INSTRUCTION_21:
2007 			s = "UT_TRAP_INSTRUCTION_21"; break;
2008 		case UT_TRAP_INSTRUCTION_22:
2009 			s = "UT_TRAP_INSTRUCTION_22"; break;
2010 		case UT_TRAP_INSTRUCTION_23:
2011 			s = "UT_TRAP_INSTRUCTION_23"; break;
2012 		case UT_TRAP_INSTRUCTION_24:
2013 			s = "UT_TRAP_INSTRUCTION_24"; break;
2014 		case UT_TRAP_INSTRUCTION_25:
2015 			s = "UT_TRAP_INSTRUCTION_25"; break;
2016 		case UT_TRAP_INSTRUCTION_26:
2017 			s = "UT_TRAP_INSTRUCTION_26"; break;
2018 		case UT_TRAP_INSTRUCTION_27:
2019 			s = "UT_TRAP_INSTRUCTION_27"; break;
2020 		case UT_TRAP_INSTRUCTION_28:
2021 			s = "UT_TRAP_INSTRUCTION_28"; break;
2022 		case UT_TRAP_INSTRUCTION_29:
2023 			s = "UT_TRAP_INSTRUCTION_29"; break;
2024 		case UT_TRAP_INSTRUCTION_30:
2025 			s = "UT_TRAP_INSTRUCTION_30"; break;
2026 		case UT_TRAP_INSTRUCTION_31:
2027 			s = "UT_TRAP_INSTRUCTION_31"; break;
2028 		}
2029 	}
2030 #endif /* __sparc */
2031 
2032 	if (s == NULL)
2033 		prt_dec(pri, 0, val);
2034 	else
2035 		outstring(pri, s);
2036 }
2037 
2038 
2039 /*
2040  * Print utrap handler
2041  */
2042 void
2043 prt_uth(private_t *pri, int raw, long val)
2044 {
2045 	const char *s = NULL;
2046 
2047 	if (!raw) {
2048 		switch (val) {
2049 		case (long)UTH_NOCHANGE:	s = "UTH_NOCHANGE"; break;
2050 		}
2051 	}
2052 
2053 	if (s == NULL)
2054 		prt_hex(pri, 0, val);
2055 	else
2056 		outstring(pri, s);
2057 }
2058 
2059 const char *
2060 access_flags(private_t *pri, long arg)
2061 {
2062 #define	E_OK 010
2063 	char *str = pri->code_buf;
2064 
2065 	if (arg & ~(R_OK|W_OK|X_OK|E_OK))
2066 		return (NULL);
2067 
2068 	/* NB: F_OK == 0 */
2069 	if (arg == F_OK)
2070 		return ("F_OK");
2071 	if (arg == E_OK)
2072 		return ("F_OK|E_OK");
2073 
2074 	*str = '\0';
2075 	if (arg & R_OK)
2076 		(void) strlcat(str, "|R_OK", sizeof (pri->code_buf));
2077 	if (arg & W_OK)
2078 		(void) strlcat(str, "|W_OK", sizeof (pri->code_buf));
2079 	if (arg & X_OK)
2080 		(void) strlcat(str, "|X_OK", sizeof (pri->code_buf));
2081 	if (arg & E_OK)
2082 		(void) strlcat(str, "|E_OK", sizeof (pri->code_buf));
2083 	return ((const char *)(str + 1));
2084 #undef E_OK
2085 }
2086 
2087 /*
2088  * Print access() flags.
2089  */
2090 void
2091 prt_acc(private_t *pri, int raw, long val)
2092 {
2093 	const char *s = raw? NULL : access_flags(pri, val);
2094 
2095 	if (s == NULL)
2096 		prt_dex(pri, 0, val);
2097 	else
2098 		outstring(pri, s);
2099 }
2100 
2101 /*
2102  * Print shutdown() "how" (2nd) argument
2103  */
2104 void
2105 prt_sht(private_t *pri, int raw, long val)
2106 {
2107 	if (raw) {
2108 		prt_dex(pri, 0, val);
2109 		return;
2110 	}
2111 	switch (val) {
2112 	case SHUT_RD:	outstring(pri, "SHUT_RD");	break;
2113 	case SHUT_WR:	outstring(pri, "SHUT_WR");	break;
2114 	case SHUT_RDWR:	outstring(pri, "SHUT_RDWR");	break;
2115 	default:	prt_dec(pri, 0, val);		break;
2116 	}
2117 }
2118 
2119 /*
2120  * Print fcntl() F_SETFL flags (3rd) argument or fdsync flag (2nd arg)
2121  */
2122 static struct fcntl_flags {
2123 	long		val;
2124 	const char	*name;
2125 } fcntl_flags[] = {
2126 #define	FC_FL(flag)	{ (long)flag, "|" # flag }
2127 	FC_FL(FREVOKED),
2128 	FC_FL(FREAD),
2129 	FC_FL(FWRITE),
2130 	FC_FL(FNDELAY),
2131 	FC_FL(FAPPEND),
2132 	FC_FL(FSYNC),
2133 	FC_FL(FDSYNC),
2134 	FC_FL(FRSYNC),
2135 	FC_FL(FOFFMAX),
2136 	FC_FL(FNONBLOCK),
2137 	FC_FL(FCREAT),
2138 	FC_FL(FTRUNC),
2139 	FC_FL(FEXCL),
2140 	FC_FL(FNOCTTY),
2141 	FC_FL(FXATTR),
2142 	FC_FL(FASYNC),
2143 	FC_FL(FNODSYNC)
2144 #undef FC_FL
2145 };
2146 
2147 void
2148 prt_ffg(private_t *pri, int raw, long val)
2149 {
2150 #define	CBSIZE	sizeof (pri->code_buf)
2151 	char *s = pri->code_buf;
2152 	size_t used = 1;
2153 	struct fcntl_flags *fp;
2154 
2155 	if (raw) {
2156 		(void) snprintf(s, CBSIZE, "0x%lx", val);
2157 		outstring(pri, s);
2158 		return;
2159 	}
2160 	if (val == 0) {
2161 		outstring(pri, "(no flags)");
2162 		return;
2163 	}
2164 
2165 	*s = '\0';
2166 	for (fp = fcntl_flags;
2167 	    fp < &fcntl_flags[sizeof (fcntl_flags) / sizeof (*fp)]; fp++) {
2168 		if (val & fp->val) {
2169 			used = strlcat(s, fp->name, CBSIZE);
2170 			val &= ~fp->val;
2171 		}
2172 	}
2173 
2174 	if (val != 0 && used <= CBSIZE)
2175 		used += snprintf(s + used, CBSIZE - used, "|0x%lx", val);
2176 
2177 	if (used >= CBSIZE)
2178 		(void) snprintf(s + 1, CBSIZE-1, "0x%lx", val);
2179 	outstring(pri, s + 1);
2180 #undef CBSIZE
2181 }
2182 
2183 void
2184 prt_prs(private_t *pri, int raw, long val)
2185 {
2186 	static size_t setsize;
2187 	priv_set_t *set = priv_allocset();
2188 
2189 	if (setsize == 0) {
2190 		const priv_impl_info_t *info = getprivimplinfo();
2191 		if (info != NULL)
2192 			setsize = info->priv_setsize * sizeof (priv_chunk_t);
2193 	}
2194 
2195 	if (setsize != 0 && !raw && set != NULL &&
2196 	    Pread(Proc, set, setsize, val) == setsize) {
2197 		int i;
2198 
2199 		outstring(pri, "{");
2200 		for (i = 0; i < setsize / sizeof (priv_chunk_t); i++) {
2201 			char buf[9];	/* 8 hex digits + '\0' */
2202 			(void) snprintf(buf, sizeof (buf), "%08x",
2203 			    ((priv_chunk_t *)set)[i]);
2204 			outstring(pri, buf);
2205 		}
2206 
2207 		outstring(pri, "}");
2208 	} else {
2209 		prt_hex(pri, 0, val);
2210 	}
2211 
2212 	if (set != NULL)
2213 		priv_freeset(set);
2214 }
2215 
2216 /*
2217  * Print privilege set operation.
2218  */
2219 void
2220 prt_pro(private_t *pri, int raw, long val)
2221 {
2222 	const char *s = NULL;
2223 
2224 	if (!raw) {
2225 		switch ((priv_op_t)val) {
2226 		case PRIV_ON:		s = "PRIV_ON";		break;
2227 		case PRIV_OFF:		s = "PRIV_OFF";		break;
2228 		case PRIV_SET:		s = "PRIV_SET";		break;
2229 		}
2230 	}
2231 
2232 	if (s == NULL)
2233 		prt_dec(pri, 0, val);
2234 	else
2235 		outstring(pri, s);
2236 }
2237 
2238 /*
2239  * Print privilege set name
2240  */
2241 void
2242 prt_prn(private_t *pri, int raw, long val)
2243 {
2244 	const char *s = NULL;
2245 
2246 	if (!raw)
2247 		s = priv_getsetbynum((int)val);
2248 
2249 	if (s == NULL)
2250 		prt_dec(pri, 0, val);
2251 	else {
2252 		char *dup = strdup(s);
2253 		char *q;
2254 
2255 		/* Do the best we can in this case */
2256 		if (dup == NULL) {
2257 			outstring(pri, s);
2258 			return;
2259 		}
2260 
2261 		outstring(pri, "PRIV_");
2262 
2263 		q = dup;
2264 
2265 		while (*q != '\0') {
2266 			*q = toupper(*q);
2267 			q++;
2268 		}
2269 		outstring(pri, dup);
2270 		free(dup);
2271 	}
2272 }
2273 
2274 /*
2275  * Print process flag names.
2276  */
2277 void
2278 prt_pfl(private_t *pri, int raw, long val)
2279 {
2280 	const char *s = NULL;
2281 
2282 	if (!raw) {
2283 		switch ((int)val) {
2284 		case PRIV_DEBUG:	s = "PRIV_DEBUG";	break;
2285 		case PRIV_AWARE:	s = "PRIV_AWARE";	break;
2286 		case PRIV_XPOLICY:	s = "PRIV_XPOLICY";	break;
2287 		case PRIV_AWARE_RESET:  s = "PRIV_AWARE_RESET"; break;
2288 		case PRIV_PFEXEC:	s = "PRIV_PFEXEC";	break;
2289 		case NET_MAC_AWARE:	s =  "NET_MAC_AWARE";	break;
2290 		case NET_MAC_AWARE_INHERIT:
2291 			s = "NET_MAC_AWARE_INHERIT";
2292 			break;
2293 		}
2294 	}
2295 
2296 	if (s == NULL)
2297 		prt_dec(pri, 0, val);
2298 	else
2299 		outstring(pri, s);
2300 }
2301 
2302 /*
2303  * Print lgrp_affinity_{get,set}() arguments.
2304  */
2305 /*ARGSUSED*/
2306 void
2307 prt_laf(private_t *pri, int raw, long val)
2308 {
2309 	lgrp_affinity_args_t	laff;
2310 
2311 	if (Pread(Proc, &laff, sizeof (lgrp_affinity_args_t), val) !=
2312 	    sizeof (lgrp_affinity_args_t)) {
2313 		prt_hex(pri, 0, val);
2314 		return;
2315 	}
2316 	/*
2317 	 * arrange the arguments in the order that user calls with
2318 	 */
2319 	prt_dec(pri, 0, laff.idtype);
2320 	outstring(pri, ", ");
2321 	prt_dec(pri, 0, laff.id);
2322 	outstring(pri, ", ");
2323 	prt_dec(pri, 0, laff.lgrp);
2324 	outstring(pri, ", ");
2325 	if (pri->sys_args[0] == LGRP_SYS_AFFINITY_SET)
2326 		prt_dec(pri, 0, laff.aff);
2327 }
2328 
2329 /*
2330  * Print a key_t as IPC_PRIVATE if it is 0.
2331  */
2332 void
2333 prt_key(private_t *pri, int raw, long val)
2334 {
2335 	if (!raw && val == 0)
2336 		outstring(pri, "IPC_PRIVATE");
2337 	else
2338 		prt_dec(pri, 0, val);
2339 }
2340 
2341 
2342 /*
2343  * Print zone_getattr() attribute types.
2344  */
2345 void
2346 prt_zga(private_t *pri, int raw, long val)
2347 {
2348 	const char *s = NULL;
2349 
2350 	if (!raw) {
2351 		switch ((int)val) {
2352 		case ZONE_ATTR_NAME:	s = "ZONE_ATTR_NAME";	break;
2353 		case ZONE_ATTR_ROOT:	s = "ZONE_ATTR_ROOT";	break;
2354 		case ZONE_ATTR_STATUS:	s = "ZONE_ATTR_STATUS";	break;
2355 		case ZONE_ATTR_PRIVSET:	s = "ZONE_ATTR_PRIVSET"; break;
2356 		case ZONE_ATTR_UNIQID:	s = "ZONE_ATTR_UNIQID"; break;
2357 		case ZONE_ATTR_POOLID:	s = "ZONE_ATTR_POOLID"; break;
2358 		case ZONE_ATTR_INITPID:	s = "ZONE_ATTR_INITPID"; break;
2359 		case ZONE_ATTR_SLBL:	s = "ZONE_ATTR_SLBL"; break;
2360 		case ZONE_ATTR_INITNAME:	s = "ZONE_ATTR_INITNAME"; break;
2361 		case ZONE_ATTR_BOOTARGS:	s = "ZONE_ATTR_BOOTARGS"; break;
2362 		case ZONE_ATTR_BRAND:	s = "ZONE_ATTR_BRAND"; break;
2363 		case ZONE_ATTR_FLAGS:	s = "ZONE_ATTR_FLAGS"; break;
2364 		case ZONE_ATTR_PHYS_MCAP: s = "ZONE_ATTR_PHYS_MCAP"; break;
2365 		}
2366 	}
2367 
2368 	if (s == NULL)
2369 		prt_dec(pri, 0, val);
2370 	else
2371 		outstring(pri, s);
2372 }
2373 
2374 /*
2375  * Print a file descriptor as AT_FDCWD if necessary
2376  */
2377 void
2378 prt_atc(private_t *pri, int raw, long val)
2379 {
2380 	if ((int)val == AT_FDCWD) {
2381 		if (raw)
2382 			prt_hex(pri, 0, (uint_t)AT_FDCWD);
2383 		else
2384 			outstring(pri, "AT_FDCWD");
2385 	} else {
2386 		prt_dec(pri, 0, val);
2387 	}
2388 }
2389 
2390 /*
2391  * Print Trusted Networking database operation codes (labelsys; tn*)
2392  */
2393 static void
2394 prt_tnd(private_t *pri, int raw, long val)
2395 {
2396 	const char *s = NULL;
2397 
2398 	if (!raw) {
2399 		switch ((tsol_dbops_t)val) {
2400 		case TNDB_NOOP:		s = "TNDB_NOOP";	break;
2401 		case TNDB_LOAD:		s = "TNDB_LOAD";	break;
2402 		case TNDB_DELETE:	s = "TNDB_DELETE";	break;
2403 		case TNDB_FLUSH:	s = "TNDB_FLUSH";	break;
2404 		case TNDB_GET:		s = "TNDB_GET";		break;
2405 		}
2406 	}
2407 
2408 	if (s == NULL)
2409 		prt_dec(pri, 0, val);
2410 	else
2411 		outstring(pri, s);
2412 }
2413 
2414 /*
2415  * Print LIO_XX flags
2416  */
2417 void
2418 prt_lio(private_t *pri, int raw, long val)
2419 {
2420 	if (raw)
2421 		prt_dec(pri, 0, val);
2422 	else if (val == LIO_WAIT)
2423 		outstring(pri, "LIO_WAIT");
2424 	else if (val == LIO_NOWAIT)
2425 		outstring(pri, "LIO_NOWAIT");
2426 	else
2427 		prt_dec(pri, 0, val);
2428 }
2429 
2430 const char *
2431 door_flags(private_t *pri, long val)
2432 {
2433 	door_attr_t attr = (door_attr_t)val;
2434 	char *str = pri->code_buf;
2435 
2436 	*str = '\0';
2437 #define	PROCESS_FLAG(flg)						\
2438 	if (attr & flg) {						\
2439 		(void) strlcat(str, "|" #flg, sizeof (pri->code_buf));	\
2440 		attr &= ~flg;						\
2441 	}
2442 
2443 	PROCESS_FLAG(DOOR_UNREF);
2444 	PROCESS_FLAG(DOOR_UNREF_MULTI);
2445 	PROCESS_FLAG(DOOR_PRIVATE);
2446 	PROCESS_FLAG(DOOR_REFUSE_DESC);
2447 	PROCESS_FLAG(DOOR_NO_CANCEL);
2448 	PROCESS_FLAG(DOOR_LOCAL);
2449 	PROCESS_FLAG(DOOR_REVOKED);
2450 	PROCESS_FLAG(DOOR_IS_UNREF);
2451 #undef PROCESS_FLAG
2452 
2453 	if (attr != 0 || *str == '\0') {
2454 		size_t len = strlen(str);
2455 		(void) snprintf(str + len, sizeof (pri->code_buf) - len,
2456 		    "|0x%X", attr);
2457 	}
2458 
2459 	return (str + 1);
2460 }
2461 
2462 /*
2463  * Print door_create() flags
2464  */
2465 void
2466 prt_dfl(private_t *pri, int raw, long val)
2467 {
2468 	if (raw)
2469 		prt_hex(pri, 0, val);
2470 	else
2471 		outstring(pri, door_flags(pri, val));
2472 }
2473 
2474 /*
2475  * Print door_*param() param argument
2476  */
2477 void
2478 prt_dpm(private_t *pri, int raw, long val)
2479 {
2480 	if (raw)
2481 		prt_hex(pri, 0, val);
2482 	else if (val == DOOR_PARAM_DESC_MAX)
2483 		outstring(pri, "DOOR_PARAM_DESC_MAX");
2484 	else if (val == DOOR_PARAM_DATA_MIN)
2485 		outstring(pri, "DOOR_PARAM_DATA_MIN");
2486 	else if (val == DOOR_PARAM_DATA_MAX)
2487 		outstring(pri, "DOOR_PARAM_DATA_MAX");
2488 	else
2489 		prt_hex(pri, 0, val);
2490 }
2491 
2492 /*
2493  * Print rctlsys subcodes
2494  */
2495 void
2496 prt_rsc(private_t *pri, int raw, long val)	/* print utssys code */
2497 {
2498 	const char *s = raw? NULL : rctlsyscode(val);
2499 
2500 	if (s == NULL)
2501 		prt_dec(pri, 0, val);
2502 	else
2503 		outstring(pri, s);
2504 }
2505 
2506 /*
2507  * Print getrctl flags
2508  */
2509 void
2510 prt_rgf(private_t *pri, int raw, long val)
2511 {
2512 	long action = val & (~RCTLSYS_ACTION_MASK);
2513 
2514 	if (raw)
2515 		prt_hex(pri, 0, val);
2516 	else if (action == RCTL_FIRST)
2517 		outstring(pri, "RCTL_FIRST");
2518 	else if (action == RCTL_NEXT)
2519 		outstring(pri, "RCTL_NEXT");
2520 	else if (action == RCTL_USAGE)
2521 		outstring(pri, "RCTL_USAGE");
2522 	else
2523 		prt_hex(pri, 0, val);
2524 }
2525 
2526 /*
2527  * Print setrctl flags
2528  */
2529 void
2530 prt_rsf(private_t *pri, int raw, long val)
2531 {
2532 	long action = val & (~RCTLSYS_ACTION_MASK);
2533 	long pval = val & RCTL_LOCAL_ACTION_MASK;
2534 	char *s = pri->code_buf;
2535 
2536 	if (raw) {
2537 		prt_hex(pri, 0, val);
2538 		return;
2539 	} else if (action == RCTL_INSERT)
2540 		(void) strcpy(s, "RCTL_INSERT");
2541 	else if (action == RCTL_DELETE)
2542 		(void) strcpy(s, "RCTL_DELETE");
2543 	else if (action == RCTL_REPLACE)
2544 		(void) strcpy(s, "RCTL_REPLACE");
2545 	else {
2546 		prt_hex(pri, 0, val);
2547 		return;
2548 	}
2549 
2550 	if (pval & RCTL_USE_RECIPIENT_PID) {
2551 		pval ^= RCTL_USE_RECIPIENT_PID;
2552 		(void) strlcat(s, "|RCTL_USE_RECIPIENT_PID",
2553 		    sizeof (pri->code_buf));
2554 	}
2555 
2556 	if ((pval & RCTLSYS_ACTION_MASK) != 0)
2557 		prt_hex(pri, 0, val);
2558 	else if (*s != '\0')
2559 		outstring(pri, s);
2560 	else
2561 		prt_hex(pri, 0, val);
2562 }
2563 
2564 /*
2565  * Print rctlctl flags
2566  */
2567 void
2568 prt_rcf(private_t *pri, int raw, long val)
2569 {
2570 	long action = val & (~RCTLSYS_ACTION_MASK);
2571 
2572 	if (raw)
2573 		prt_hex(pri, 0, val);
2574 	else if (action == RCTLCTL_GET)
2575 		outstring(pri, "RCTLCTL_GET");
2576 	else if (action == RCTLCTL_SET)
2577 		outstring(pri, "RCTLCTL_SET");
2578 	else
2579 		prt_hex(pri, 0, val);
2580 }
2581 
2582 /*
2583  * Print setprojrctl flags
2584  */
2585 void
2586 prt_spf(private_t *pri, int raw, long val)
2587 {
2588 	long action = val & TASK_PROJ_MASK;
2589 
2590 	if (!raw && (action == TASK_PROJ_PURGE))
2591 		outstring(pri, "TASK_PROJ_PURGE");
2592 	else
2593 		prt_hex(pri, 0, val);
2594 }
2595 
2596 /*
2597  * Print forkx() flags
2598  */
2599 void
2600 prt_fxf(private_t *pri, int raw, long val)
2601 {
2602 	char *str;
2603 
2604 	if (val == 0)
2605 		outstring(pri, "0");
2606 	else if (raw || (val & ~(FORK_NOSIGCHLD | FORK_WAITPID)))
2607 		prt_hhx(pri, 0, val);
2608 	else {
2609 		str = pri->code_buf;
2610 		*str = '\0';
2611 		if (val & FORK_NOSIGCHLD)
2612 			(void) strlcat(str, "|FORK_NOSIGCHLD",
2613 			    sizeof (pri->code_buf));
2614 		if (val & FORK_WAITPID)
2615 			(void) strlcat(str, "|FORK_WAITPID",
2616 			    sizeof (pri->code_buf));
2617 		outstring(pri, str + 1);
2618 	}
2619 }
2620 
2621 /*
2622  * Print utimensat() flag
2623  */
2624 void
2625 prt_utf(private_t *pri, int raw, long val)
2626 {
2627 	if (val == 0)
2628 		outstring(pri, "0");
2629 	else if (!raw && val == AT_SYMLINK_NOFOLLOW)
2630 		outstring(pri, "AT_SYMLINK_NOFOLLOW");
2631 	else
2632 		prt_hex(pri, 0, val);
2633 }
2634 
2635 /*
2636  * Array of pointers to print functions, one for each format.
2637  */
2638 void (* const Print[])() = {
2639 	prt_nov,	/* NOV -- no value */
2640 	prt_dec,	/* DEC -- print value in decimal */
2641 	prt_oct,	/* OCT -- print value in octal */
2642 	prt_hex,	/* HEX -- print value in hexadecimal */
2643 	prt_dex,	/* DEX -- print value in hexadecimal if big enough */
2644 	prt_stg,	/* STG -- print value as string */
2645 	prt_ioc,	/* IOC -- print ioctl code */
2646 	prt_fcn,	/* FCN -- print fcntl code */
2647 	prt_s86,	/* S86 -- print sysi86 code */
2648 	prt_uts,	/* UTS -- print utssys code */
2649 	prt_opn,	/* OPN -- print open code */
2650 	prt_sig,	/* SIG -- print signal name plus flags */
2651 	prt_nov,	/* Was ACT, now available for reuse */
2652 	prt_msc,	/* MSC -- print msgsys command */
2653 	prt_msf,	/* MSF -- print msgsys flags */
2654 	prt_smc,	/* SMC -- print semsys command */
2655 	prt_sef,	/* SEF -- print semsys flags */
2656 	prt_shc,	/* SHC -- print shmsys command */
2657 	prt_shf,	/* SHF -- print shmsys flags */
2658 	prt_nov,	/* Was PLK, now available for reuse */
2659 	prt_sfs,	/* SFS -- print sysfs code */
2660 	prt_rst,	/* RST -- print string returned by syscall */
2661 	prt_smf,	/* SMF -- print streams message flags */
2662 	prt_ioa,	/* IOA -- print ioctl argument */
2663 	prt_nov,	/* Was SIX, now available for reuse */
2664 	prt_mtf,	/* MTF -- print mount flags */
2665 	prt_mft,	/* MFT -- print mount file system type */
2666 	prt_iob,	/* IOB -- print contents of I/O buffer */
2667 	prt_hhx,	/* HHX -- print value in hexadecimal (half size) */
2668 	prt_wop,	/* WOP -- print waitsys() options */
2669 	prt_spm,	/* SPM -- print sigprocmask argument */
2670 	prt_rlk,	/* RLK -- print readlink buffer */
2671 	prt_mpr,	/* MPR -- print mmap()/mprotect() flags */
2672 	prt_mty,	/* MTY -- print mmap() mapping type flags */
2673 	prt_mcf,	/* MCF -- print memcntl() function */
2674 	prt_mc4,	/* MC4 -- print memcntl() (fourth) argument */
2675 	prt_mc5,	/* MC5 -- print memcntl() (fifth) argument */
2676 	prt_mad,	/* MAD -- print madvise() argument */
2677 	prt_ulm,	/* ULM -- print ulimit() argument */
2678 	prt_rlm,	/* RLM -- print get/setrlimit() argument */
2679 	prt_cnf,	/* CNF -- print sysconfig() argument */
2680 	prt_inf,	/* INF -- print sysinfo() argument */
2681 	prt_ptc,	/* PTC -- print pathconf/fpathconf() argument */
2682 	prt_fui,	/* FUI -- print fusers() input argument */
2683 	prt_idt,	/* IDT -- print idtype_t, waitid() argument */
2684 	prt_lwf,	/* LWF -- print lwp_create() flags */
2685 	prt_itm,	/* ITM -- print [get|set]itimer() arg */
2686 	prt_llo,	/* LLO -- print long long offset arg */
2687 	prt_mod,	/* MOD -- print modctl() subcode */
2688 	prt_whn,	/* WHN -- print lseek() whence arguiment */
2689 	prt_acl,	/* ACL -- print acl() code */
2690 	prt_aio,	/* AIO -- print kaio() code */
2691 	prt_aud,	/* AUD -- print auditsys() code */
2692 	prt_uns,	/* DEC -- print value in unsigned decimal */
2693 	prt_clc,	/* CLC -- print cladm command argument */
2694 	prt_clf,	/* CLF -- print cladm flag argument */
2695 	prt_cor,	/* COR -- print corectl() subcode */
2696 	prt_cco,	/* CCO -- print corectl() options */
2697 	prt_ccc,	/* CCC -- print corectl() content */
2698 	prt_rcc,	/* RCC -- print corectl() returned content */
2699 	prt_cpc,	/* CPC -- print cpc() subcode */
2700 	prt_sqc,	/* SQC -- print sigqueue() si_code argument */
2701 	prt_pc4,	/* PC4 -- print priocntlsys() (fourth) argument */
2702 	prt_pc5,	/* PC5 -- print priocntlsys() (key, value) pairs */
2703 	prt_pst,	/* PST -- print processor set id */
2704 	prt_mif,	/* MIF -- print meminfo() arguments */
2705 	prt_pfm,	/* PFM -- print so_socket() proto-family (1st) arg */
2706 	prt_skt,	/* SKT -- print so_socket() socket-type (2nd) arg */
2707 	prt_skp,	/* SKP -- print so_socket() protocol (3rd) arg */
2708 	prt_skv,	/* SKV -- print socket version arg */
2709 	prt_sol,	/* SOL -- print [sg]etsockopt() level (2nd) arg */
2710 	prt_son,	/* SON -- print [sg]etsockopt() opt-name (3rd) arg */
2711 	prt_utt,	/* UTT -- print utrap type */
2712 	prt_uth,	/* UTH -- print utrap handler */
2713 	prt_acc,	/* ACC -- print access() flags */
2714 	prt_sht,	/* SHT -- print shutdown() how (2nd) argument */
2715 	prt_ffg,	/* FFG -- print fcntl() flags (3rd) argument */
2716 	prt_prs,	/* PRS -- print privilege set */
2717 	prt_pro,	/* PRO -- print privilege set operation */
2718 	prt_prn,	/* PRN -- print privilege set name */
2719 	prt_pfl,	/* PFL -- print privilege/process flag name */
2720 	prt_laf,	/* LAF -- print lgrp_affinity arguments */
2721 	prt_key,	/* KEY -- print key_t 0 as IPC_PRIVATE */
2722 	prt_zga,	/* ZGA -- print zone_getattr attribute types */
2723 	prt_atc,	/* ATC -- print AT_FDCWD or file descriptor */
2724 	prt_lio,	/* LIO -- print LIO_XX flags */
2725 	prt_dfl,	/* DFL -- print door_create() flags */
2726 	prt_dpm,	/* DPM -- print DOOR_PARAM_XX flags */
2727 	prt_tnd,	/* TND -- print trusted network data base opcode */
2728 	prt_rsc,	/* RSC -- print rctlsys() subcodes */
2729 	prt_rgf,	/* RGF -- print getrctl() flags */
2730 	prt_rsf,	/* RSF -- print setrctl() flags */
2731 	prt_rcf,	/* RCF -- print rctlsys_ctl() flags */
2732 	prt_fxf,	/* FXF -- print forkx() flags */
2733 	prt_spf,	/* SPF -- print rctlsys_projset() flags */
2734 	prt_un1,	/* UN1 -- as prt_uns except for -1 */
2735 	prt_mob,	/* MOB -- print mmapobj() flags */
2736 	prt_utf,	/* UTF -- print utimensat() flag */
2737 	prt_skc,	/* SKC -- print sockconfig() subcode */
2738 	prt_dec,	/* HID -- hidden argument, make this the last one */
2739 };
2740