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.
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.
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]
23 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright (c) 2015, Joyent, Inc. All rights reserved.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
30 /* Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. */
32 #define _SYSCALL32 /* make 32-bit compat headers visible */
44 #include <sys/types.h>
46 #include <sys/resource.h>
47 #include <sys/ulimit.h>
48 #include <sys/utsname.h>
49 #include <sys/kstat.h>
50 #include <sys/modctl.h>
53 #include <sys/isa_defs.h>
54 #include <sys/systeminfo.h>
55 #include <sys/cladm.h>
57 #include <bsm/audit.h>
61 #include <sys/aiocb.h>
62 #include <sys/corectl.h>
63 #include <sys/cpc_impl.h>
64 #include <sys/priocntl.h>
65 #include <sys/tspriocntl.h>
66 #include <sys/iapriocntl.h>
67 #include <sys/rtpriocntl.h>
68 #include <sys/fsspriocntl.h>
69 #include <sys/fxpriocntl.h>
72 #include <nss_dbdefs.h>
73 #include <sys/socketvar.h>
74 #include <netinet/in.h>
75 #include <netinet/tcp.h>
76 #include <netinet/udp.h>
77 #include <netinet/sctp.h>
78 #include <net/route.h>
79 #include <sys/utrap.h>
80 #include <sys/lgrp_user.h>
82 #include <sys/tsol/tndb.h>
84 #include <sys/rctl_impl.h>
87 #include <sys/random.h>
93 void grow(private_t
*, int nbyte
);
95 #define GROW(nb) if (pri->sys_leng + (nb) >= pri->sys_ssize) grow(pri, (nb))
100 prt_nov(private_t
*pri
, int raw
, long val
) /* print nothing */
106 prt_dec(private_t
*pri
, int raw
, long val
) /* print as decimal */
109 if (data_model
== PR_MODEL_ILP32
)
110 pri
->sys_leng
+= sprintf(pri
->sys_string
+ pri
->sys_leng
,
113 pri
->sys_leng
+= sprintf(pri
->sys_string
+ pri
->sys_leng
,
119 prt_uns(private_t
*pri
, int raw
, long val
) /* print as unsigned decimal */
122 if (data_model
== PR_MODEL_ILP32
)
123 pri
->sys_leng
+= sprintf(pri
->sys_string
+ pri
->sys_leng
,
126 pri
->sys_leng
+= sprintf(pri
->sys_string
+ pri
->sys_leng
,
130 /* print as unsigned decimal, except for -1 */
132 prt_un1(private_t
*pri
, int raw
, long val
)
135 prt_dec(pri
, raw
, val
);
137 prt_uns(pri
, raw
, val
);
142 prt_oct(private_t
*pri
, int raw
, long val
) /* print as octal */
145 if (data_model
== PR_MODEL_ILP32
)
146 pri
->sys_leng
+= sprintf(pri
->sys_string
+ pri
->sys_leng
,
149 pri
->sys_leng
+= sprintf(pri
->sys_string
+ pri
->sys_leng
,
155 prt_hex(private_t
*pri
, int raw
, long val
) /* print as hexadecimal */
158 if (data_model
== PR_MODEL_ILP32
)
159 pri
->sys_leng
+= sprintf(pri
->sys_string
+ pri
->sys_leng
,
162 pri
->sys_leng
+= sprintf(pri
->sys_string
+ pri
->sys_leng
,
166 /* print as hexadecimal (half size) */
169 prt_hhx(private_t
*pri
, int raw
, long val
)
172 if (data_model
== PR_MODEL_ILP32
)
173 pri
->sys_leng
+= sprintf(pri
->sys_string
+ pri
->sys_leng
,
176 pri
->sys_leng
+= sprintf(pri
->sys_string
+ pri
->sys_leng
,
180 /* print as decimal if small, else hexadecimal */
183 prt_dex(private_t
*pri
, int raw
, long val
)
185 if (val
& 0xff000000)
186 prt_hex(pri
, 0, val
);
188 prt_dec(pri
, 0, val
);
191 /* print long long offset */
194 prt_llo(private_t
*pri
, int raw
, long val1
, long val2
)
199 #ifdef _LONG_LONG_LTOH
208 prt_dex(pri
, 0, loval
);
212 sprintf(pri
->sys_string
+ pri
->sys_leng
, "0x%.8X%.8X",
218 escape_string(private_t
*pri
, const char *s
)
221 * We want to avoid outputting unprintable characters that may
222 * destroy the user's terminal. So we do one pass to find any
223 * unprintable characters, size the array appropriately, and
224 * then walk each character by hand. Those that are unprintable
225 * are replaced by a hex escape (\xNN). We also escape quotes for
228 int i
, unprintable
, quotes
;
229 size_t len
= strlen(s
);
230 for (i
= 0, unprintable
= 0, quotes
= 0; i
< len
; i
++) {
237 GROW(len
+ 3 * unprintable
+ quotes
+ 2);
239 pri
->sys_string
[pri
->sys_leng
++] = '"';
240 for (i
= 0; i
< len
; i
++) {
242 pri
->sys_string
[pri
->sys_leng
++] = '\\';
245 pri
->sys_string
[pri
->sys_leng
++] = s
[i
];
247 pri
->sys_leng
+= sprintf(pri
->sys_string
+
248 pri
->sys_leng
, "\\x%02x", (uint8_t)s
[i
]);
251 pri
->sys_string
[pri
->sys_leng
++] = '"';
255 prt_stg(private_t
*pri
, int raw
, long val
) /* print as string */
257 char *s
= raw
? NULL
: fetchstring(pri
, (long)val
, PATH_MAX
);
260 prt_hex(pri
, 0, val
);
262 escape_string(pri
, s
);
265 /* print as string returned from syscall */
267 prt_rst(private_t
*pri
, int raw
, long val
)
269 char *s
= (raw
|| pri
->Errno
)? NULL
:
270 fetchstring(pri
, (long)val
, PATH_MAX
);
273 prt_hex(pri
, 0, val
);
275 GROW((int)strlen(s
) + 2);
276 pri
->sys_leng
+= snprintf(pri
->sys_string
+ pri
->sys_leng
,
277 pri
->sys_ssize
- pri
->sys_leng
, "\"%s\"", s
);
281 /* print contents of readlink() buffer */
283 prt_rlk(private_t
*pri
, int raw
, long val
)
285 char *s
= (raw
|| pri
->Errno
|| pri
->Rval1
<= 0)? NULL
:
286 fetchstring(pri
, (long)val
,
287 (pri
->Rval1
> PATH_MAX
)? PATH_MAX
: (int)pri
->Rval1
);
290 prt_hex(pri
, 0, val
);
292 GROW((int)strlen(s
) + 2);
293 pri
->sys_leng
+= snprintf(pri
->sys_string
+ pri
->sys_leng
,
294 pri
->sys_ssize
- pri
->sys_leng
, "\"%s\"", s
);
299 prt_ioc(private_t
*pri
, int raw
, long val
) /* print ioctl code */
301 const char *s
= raw
? NULL
: ioctlname(pri
, (int)val
);
304 prt_hex(pri
, 0, val
);
310 prt_ioa(private_t
*pri
, int raw
, long val
) /* print ioctl argument */
314 /* cheating -- look at the ioctl() code */
315 switch (pri
->sys_args
[1]) {
319 case KSTAT_IOC_WRITE
:
321 if (data_model
== PR_MODEL_ILP32
)
323 val
+ offsetof(kstat32_t
, ks_name
[0]));
327 val
+ offsetof(kstat_t
, ks_name
[0]));
330 /* streams ioctl()s */
332 prt_rst(pri
, raw
, val
);
336 prt_stg(pri
, raw
, val
);
341 prt_dec(pri
, 0, val
);
344 if (raw
|| (s
= strrdopt(val
)) == NULL
)
345 prt_dec(pri
, 0, val
);
350 if (raw
|| (s
= strevents(pri
, val
)) == NULL
)
351 prt_hex(pri
, 0, val
);
356 if (raw
|| (s
= strflush(val
)) == NULL
)
357 prt_dec(pri
, 0, val
);
367 prt_dec(pri
, 0, val
);
371 prt_hex(pri
, 0, val
);
377 prt_pip(private_t
*pri
, int raw
, long val
) /* print pipe code */
379 const char *s
= NULL
;
389 case O_CLOEXEC
|O_NONBLOCK
:
390 s
= "O_CLOEXEC|O_NONBLOCK";
396 prt_dex(pri
, 0, val
);
402 prt_pfd(private_t
*pri
, int raw
, long val
) /* print pipe code */
407 /* the fds only have meaning if the return value is 0 */
410 Pread(Proc
, fds
, sizeof (fds
), (long)val
) == sizeof (fds
)) {
411 (void) snprintf(str
, sizeof (str
), "[%d,%d]", fds
[0], fds
[1]);
414 prt_hex(pri
, 0, val
);
419 prt_fcn(private_t
*pri
, int raw
, long val
) /* print fcntl code */
421 const char *s
= raw
? NULL
: fcntlname(val
);
424 prt_dec(pri
, 0, val
);
430 prt_s86(private_t
*pri
, int raw
, long val
) /* print sysi86 code */
433 const char *s
= raw
? NULL
: si86name(val
);
436 prt_dec(pri
, 0, val
);
442 prt_uts(private_t
*pri
, int raw
, long val
) /* print utssys code */
444 const char *s
= raw
? NULL
: utscode(val
);
447 prt_dec(pri
, 0, val
);
453 prt_msc(private_t
*pri
, int raw
, long val
) /* print msgsys command */
455 const char *s
= raw
? NULL
: msgcmd(val
);
458 prt_dec(pri
, 0, val
);
464 prt_msf(private_t
*pri
, int raw
, long val
) /* print msgsys flags */
466 const char *s
= raw
? NULL
: msgflags(pri
, (int)val
);
469 prt_oct(pri
, 0, val
);
475 prt_smc(private_t
*pri
, int raw
, long val
) /* print semsys command */
477 const char *s
= raw
? NULL
: semcmd(val
);
480 prt_dec(pri
, 0, val
);
486 prt_sef(private_t
*pri
, int raw
, long val
) /* print semsys flags */
488 const char *s
= raw
? NULL
: semflags(pri
, (int)val
);
491 prt_oct(pri
, 0, val
);
497 prt_shc(private_t
*pri
, int raw
, long val
) /* print shmsys command */
499 const char *s
= raw
? NULL
: shmcmd(val
);
502 prt_dec(pri
, 0, val
);
508 prt_shf(private_t
*pri
, int raw
, long val
) /* print shmsys flags */
510 const char *s
= raw
? NULL
: shmflags(pri
, (int)val
);
513 prt_oct(pri
, 0, val
);
519 prt_sfs(private_t
*pri
, int raw
, long val
) /* print sysfs code */
521 const char *s
= raw
? NULL
: sfsname(val
);
524 prt_dec(pri
, 0, val
);
530 prt_opn(private_t
*pri
, int raw
, long val
) /* print open code */
532 const char *s
= raw
? NULL
: openarg(pri
, val
);
535 prt_oct(pri
, 0, val
);
541 prt_sig(private_t
*pri
, int raw
, long val
) /* print signal name */
543 const char *s
= raw
? NULL
: signame(pri
, (int)val
);
546 prt_hex(pri
, 0, val
);
552 prt_smf(private_t
*pri
, int raw
, long val
) /* print streams message flags */
556 prt_dec(pri
, 0, val
);
560 prt_hhx(pri
, 0, val
);
562 outstring(pri
, "RS_HIPRI");
565 prt_hhx(pri
, 0, val
);
571 prt_mtf(private_t
*pri
, int raw
, long val
) /* print mount flags */
573 const char *s
= raw
? NULL
: mountflags(pri
, val
);
576 prt_hex(pri
, 0, val
);
582 prt_mft(private_t
*pri
, int raw
, long val
) /* print mount file system type */
584 if (val
>= 0 && val
< 256)
585 prt_dec(pri
, 0, val
);
587 prt_hex(pri
, 0, val
);
589 prt_stg(pri
, raw
, val
);
592 #define ISREAD(code) \
593 ((code) == SYS_read || (code) == SYS_pread || (code) == SYS_pread64 || \
594 (code) == SYS_recv || (code) == SYS_recvfrom)
595 #define ISWRITE(code) \
596 ((code) == SYS_write || (code) == SYS_pwrite || \
597 (code) == SYS_pwrite64 || (code) == SYS_send || (code) == SYS_sendto)
599 /* print contents of read() or write() I/O buffer */
601 prt_iob(private_t
*pri
, int raw
, long val
)
603 const lwpstatus_t
*Lsp
= pri
->lwpstat
;
604 int syscall
= Lsp
->pr_what
;
605 int fdp1
= pri
->sys_args
[0] + 1;
606 ssize_t nbyte
= ISWRITE(syscall
)? pri
->sys_args
[2] :
607 (pri
->Errno
? 0 : pri
->Rval1
);
608 int elsewhere
= FALSE
; /* TRUE iff dumped elsewhere */
609 char buffer
[IOBSIZE
];
611 pri
->iob_buf
[0] = '\0';
613 if (Lsp
->pr_why
== PR_SYSEXIT
&& nbyte
> IOBSIZE
) {
615 elsewhere
= prismember(&readfd
, fdp1
);
617 elsewhere
= prismember(&writefd
, fdp1
);
620 if (nbyte
<= 0 || elsewhere
)
621 prt_hex(pri
, 0, val
);
623 int nb
= nbyte
> IOBSIZE
? IOBSIZE
: (int)nbyte
;
625 if (Pread(Proc
, buffer
, (size_t)nb
, (long)val
) != nb
)
626 prt_hex(pri
, 0, val
);
628 pri
->iob_buf
[0] = '"';
629 showbytes(buffer
, nb
, pri
->iob_buf
+ 1);
630 (void) strlcat(pri
->iob_buf
,
632 (const char *)"\"" : (const char *)"\"..",
633 sizeof (pri
->iob_buf
));
635 prt_hex(pri
, 0, val
);
637 outstring(pri
, pri
->iob_buf
);
645 prt_idt(private_t
*pri
, int raw
, long val
) /* print idtype_t, waitid() arg */
647 const char *s
= raw
? NULL
: idtype_enum(pri
, val
);
650 prt_dec(pri
, 0, val
);
656 prt_wop(private_t
*pri
, int raw
, long val
) /* print waitid() options */
658 const char *s
= raw
? NULL
: woptions(pri
, (int)val
);
661 prt_oct(pri
, 0, val
);
667 prt_whn(private_t
*pri
, int raw
, long val
) /* print lseek() whence argument */
669 const char *s
= raw
? NULL
: whencearg(val
);
672 prt_dec(pri
, 0, val
);
679 prt_spm(private_t
*pri
, int raw
, long val
) /* print sigprocmask argument */
681 const char *s
= NULL
;
685 case SIG_BLOCK
: s
= "SIG_BLOCK"; break;
686 case SIG_UNBLOCK
: s
= "SIG_UNBLOCK"; break;
687 case SIG_SETMASK
: s
= "SIG_SETMASK"; break;
692 prt_dec(pri
, 0, val
);
698 mmap_protect(private_t
*pri
, long arg
)
700 char *str
= pri
->code_buf
;
702 if (arg
& ~(PROT_READ
|PROT_WRITE
|PROT_EXEC
))
703 return ((char *)NULL
);
705 if (arg
== PROT_NONE
)
706 return ("PROT_NONE");
710 (void) strlcat(str
, "|PROT_READ", sizeof (pri
->code_buf
));
711 if (arg
& PROT_WRITE
)
712 (void) strlcat(str
, "|PROT_WRITE", sizeof (pri
->code_buf
));
714 (void) strlcat(str
, "|PROT_EXEC", sizeof (pri
->code_buf
));
715 return ((const char *)(str
+ 1));
719 mmap_type(private_t
*pri
, long arg
)
721 char *str
= pri
->code_buf
;
724 #define CBSIZE sizeof (pri->code_buf)
725 switch (arg
& MAP_TYPE
) {
727 used
= strlcpy(str
, "MAP_SHARED", CBSIZE
);
730 used
= strlcpy(str
, "MAP_PRIVATE", CBSIZE
);
733 used
= snprintf(str
, CBSIZE
, "%ld", arg
&MAP_TYPE
);
737 arg
&= ~(_MAP_NEW
|MAP_TYPE
);
739 if (arg
& ~(MAP_FIXED
|MAP_RENAME
|MAP_NORESERVE
|MAP_ANON
|MAP_ALIGN
|
740 MAP_TEXT
|MAP_INITDATA
|MAP_32BIT
))
741 (void) snprintf(str
+ used
, sizeof (pri
->code_buf
) - used
,
745 (void) strlcat(str
, "|MAP_FIXED", CBSIZE
);
746 if (arg
& MAP_RENAME
)
747 (void) strlcat(str
, "|MAP_RENAME", CBSIZE
);
748 if (arg
& MAP_NORESERVE
)
749 (void) strlcat(str
, "|MAP_NORESERVE", CBSIZE
);
751 (void) strlcat(str
, "|MAP_ANON", CBSIZE
);
753 (void) strlcat(str
, "|MAP_ALIGN", CBSIZE
);
755 (void) strlcat(str
, "|MAP_TEXT", CBSIZE
);
756 if (arg
& MAP_INITDATA
)
757 (void) strlcat(str
, "|MAP_INITDATA", CBSIZE
);
759 (void) strlcat(str
, "|MAP_32BIT", CBSIZE
);
762 return ((const char *)str
);
767 prt_mpr(private_t
*pri
, int raw
, long val
) /* print mmap()/mprotect() flags */
769 const char *s
= raw
? NULL
: mmap_protect(pri
, val
);
772 prt_hhx(pri
, 0, val
);
778 prt_mty(private_t
*pri
, int raw
, long val
) /* print mmap() mapping type flags */
780 const char *s
= raw
? NULL
: mmap_type(pri
, val
);
783 prt_hhx(pri
, 0, val
);
789 prt_mob(private_t
*pri
, int raw
, long val
) /* print mmapobj() flags */
792 prt_dec(pri
, 0, val
);
793 else if (raw
|| (val
& ~(MMOBJ_PADDING
|MMOBJ_INTERPRET
)) != 0)
794 prt_hhx(pri
, 0, val
);
796 #define CBSIZE sizeof (pri->code_buf)
797 char *s
= pri
->code_buf
;
800 if (val
& MMOBJ_PADDING
)
801 (void) strlcat(s
, "|MMOBJ_PADDING", CBSIZE
);
802 if (val
& MMOBJ_INTERPRET
)
803 (void) strlcat(s
, "|MMOBJ_INTERPRET", CBSIZE
);
804 outstring(pri
, s
+ 1);
811 prt_mcf(private_t
*pri
, int raw
, long val
) /* print memcntl() function */
813 const char *s
= NULL
;
817 case MC_SYNC
: s
= "MC_SYNC"; break;
818 case MC_LOCK
: s
= "MC_LOCK"; break;
819 case MC_UNLOCK
: s
= "MC_UNLOCK"; break;
820 case MC_ADVISE
: s
= "MC_ADVISE"; break;
821 case MC_LOCKAS
: s
= "MC_LOCKAS"; break;
822 case MC_UNLOCKAS
: s
= "MC_UNLOCKAS"; break;
823 case MC_HAT_ADVISE
: s
= "MC_HAT_ADVISE"; break;
828 prt_dec(pri
, 0, val
);
834 prt_mad(private_t
*pri
, int raw
, long val
) /* print madvise() argument */
836 const char *s
= NULL
;
840 case MADV_NORMAL
: s
= "MADV_NORMAL"; break;
841 case MADV_RANDOM
: s
= "MADV_RANDOM"; break;
842 case MADV_SEQUENTIAL
: s
= "MADV_SEQUENTIAL"; break;
843 case MADV_WILLNEED
: s
= "MADV_WILLNEED"; break;
844 case MADV_DONTNEED
: s
= "MADV_DONTNEED"; break;
845 case MADV_FREE
: s
= "MADV_FREE"; break;
846 case MADV_ACCESS_DEFAULT
: s
= "MADV_ACCESS_DEFAULT"; break;
847 case MADV_ACCESS_LWP
: s
= "MADV_ACCESS_LWP"; break;
848 case MADV_ACCESS_MANY
: s
= "MADV_ACCESS_MANY"; break;
849 case MADV_PURGE
: s
= "MADV_PURGE"; break;
854 prt_dec(pri
, 0, val
);
860 prt_mc4(private_t
*pri
, int raw
, long val
) /* print memcntl() (4th) argument */
863 prt_dec(pri
, 0, val
);
865 prt_hhx(pri
, 0, val
);
869 #define CBSIZE sizeof (pri->code_buf)
870 /* cheating -- look at memcntl func */
871 switch (pri
->sys_args
[2]) {
873 prt_mad(pri
, 0, val
);
877 if ((val
& ~(MS_SYNC
|MS_ASYNC
|MS_INVALIDATE
)) == 0) {
878 *(s
= pri
->code_buf
) = '\0';
880 (void) strlcat(s
, "|MS_SYNC", CBSIZE
);
882 (void) strlcat(s
, "|MS_ASYNC", CBSIZE
);
883 if (val
& MS_INVALIDATE
)
884 (void) strlcat(s
, "|MS_INVALIDATE",
891 if ((val
& ~(MCL_CURRENT
|MCL_FUTURE
)) == 0) {
892 *(s
= pri
->code_buf
) = '\0';
893 if (val
& MCL_CURRENT
)
894 (void) strlcat(s
, "|MCL_CURRENT",
896 if (val
& MCL_FUTURE
)
897 (void) strlcat(s
, "|MCL_FUTURE",
904 if (s
== NULL
|| *s
== '\0')
905 prt_hhx(pri
, 0, val
);
912 prt_mc5(private_t
*pri
, int raw
, long val
) /* print memcntl() (5th) argument */
916 #define CBSIZE sizeof (pri->code_buf)
918 prt_dec(pri
, 0, val
);
919 else if (raw
|| (val
& ~VALID_ATTR
))
920 prt_hhx(pri
, 0, val
);
925 (void) strlcat(s
, "|SHARED", CBSIZE
);
927 (void) strlcat(s
, "|PRIVATE", CBSIZE
);
929 (void) strlcat(s
, "|PROT_READ", CBSIZE
);
930 if (val
& PROT_WRITE
)
931 (void) strlcat(s
, "|PROT_WRITE", CBSIZE
);
933 (void) strlcat(s
, "|PROT_EXEC", CBSIZE
);
935 prt_hhx(pri
, 0, val
);
943 prt_ulm(private_t
*pri
, int raw
, long val
) /* print ulimit() argument */
945 const char *s
= NULL
;
949 case UL_GFILLIM
: s
= "UL_GFILLIM"; break;
950 case UL_SFILLIM
: s
= "UL_SFILLIM"; break;
951 case UL_GMEMLIM
: s
= "UL_GMEMLIM"; break;
952 case UL_GDESLIM
: s
= "UL_GDESLIM"; break;
957 prt_dec(pri
, 0, val
);
963 prt_rlm(private_t
*pri
, int raw
, long val
) /* print get/setrlimit() argument */
965 const char *s
= NULL
;
969 case RLIMIT_CPU
: s
= "RLIMIT_CPU"; break;
970 case RLIMIT_FSIZE
: s
= "RLIMIT_FSIZE"; break;
971 case RLIMIT_DATA
: s
= "RLIMIT_DATA"; break;
972 case RLIMIT_STACK
: s
= "RLIMIT_STACK"; break;
973 case RLIMIT_CORE
: s
= "RLIMIT_CORE"; break;
974 case RLIMIT_NOFILE
: s
= "RLIMIT_NOFILE"; break;
975 case RLIMIT_VMEM
: s
= "RLIMIT_VMEM"; break;
980 prt_dec(pri
, 0, val
);
986 prt_cnf(private_t
*pri
, int raw
, long val
) /* print sysconfig code */
988 const char *s
= raw
? NULL
: sconfname(val
);
991 prt_dec(pri
, 0, val
);
997 prt_inf(private_t
*pri
, int raw
, long val
) /* print sysinfo code */
999 const char *s
= NULL
;
1003 case SI_SYSNAME
: s
= "SI_SYSNAME"; break;
1004 case SI_HOSTNAME
: s
= "SI_HOSTNAME"; break;
1005 case SI_RELEASE
: s
= "SI_RELEASE"; break;
1006 case SI_VERSION
: s
= "SI_VERSION"; break;
1007 case SI_MACHINE
: s
= "SI_MACHINE"; break;
1008 case SI_ARCHITECTURE
: s
= "SI_ARCHITECTURE"; break;
1009 case SI_ARCHITECTURE_32
:s
= "SI_ARCHITECTURE_32"; break;
1010 case SI_ARCHITECTURE_64
:s
= "SI_ARCHITECTURE_64"; break;
1011 case SI_ARCHITECTURE_K
: s
= "SI_ARCHITECTURE_K"; break;
1012 case SI_HW_SERIAL
: s
= "SI_HW_SERIAL"; break;
1013 case SI_HW_PROVIDER
: s
= "SI_HW_PROVIDER"; break;
1014 case SI_SRPC_DOMAIN
: s
= "SI_SRPC_DOMAIN"; break;
1015 case SI_SET_HOSTNAME
: s
= "SI_SET_HOSTNAME"; break;
1016 case SI_SET_SRPC_DOMAIN
: s
= "SI_SET_SRPC_DOMAIN"; break;
1017 case SI_PLATFORM
: s
= "SI_PLATFORM"; break;
1018 case SI_ISALIST
: s
= "SI_ISALIST"; break;
1019 case SI_DHCP_CACHE
: s
= "SI_DHCP_CACHE"; break;
1024 prt_dec(pri
, 0, val
);
1030 prt_ptc(private_t
*pri
, int raw
, long val
) /* print pathconf code */
1032 const char *s
= raw
? NULL
: pathconfname(val
);
1035 prt_dec(pri
, 0, val
);
1041 prt_fui(private_t
*pri
, int raw
, long val
) /* print fusers() input argument */
1043 const char *s
= raw
? NULL
: fuiname(val
);
1046 prt_hhx(pri
, 0, val
);
1052 prt_lwf(private_t
*pri
, int raw
, long val
) /* print lwp_create() flags */
1057 prt_dec(pri
, 0, val
);
1059 (val
& ~(LWP_DAEMON
|LWP_DETACHED
|LWP_SUSPENDED
)))
1060 prt_hhx(pri
, 0, val
);
1062 #define CBSIZE sizeof (pri->code_buf)
1065 if (val
& LWP_DAEMON
)
1066 (void) strlcat(s
, "|LWP_DAEMON", CBSIZE
);
1067 if (val
& LWP_DETACHED
)
1068 (void) strlcat(s
, "|LWP_DETACHED", CBSIZE
);
1069 if (val
& LWP_SUSPENDED
)
1070 (void) strlcat(s
, "|LWP_SUSPENDED", CBSIZE
);
1071 outstring(pri
, ++s
);
1077 prt_itm(private_t
*pri
, int raw
, long val
) /* print [get|set]itimer() arg */
1079 const char *s
= NULL
;
1083 case ITIMER_REAL
: s
= "ITIMER_REAL"; break;
1084 case ITIMER_VIRTUAL
: s
= "ITIMER_VIRTUAL"; break;
1085 case ITIMER_PROF
: s
= "ITIMER_PROF"; break;
1086 #ifdef ITIMER_REALPROF
1087 case ITIMER_REALPROF
: s
= "ITIMER_REALPROF"; break;
1093 prt_dec(pri
, 0, val
);
1099 prt_mod(private_t
*pri
, int raw
, long val
) /* print modctl() code */
1101 const char *s
= NULL
;
1105 case MODLOAD
: s
= "MODLOAD"; break;
1106 case MODUNLOAD
: s
= "MODUNLOAD"; break;
1107 case MODINFO
: s
= "MODINFO"; break;
1108 case MODRESERVED
: s
= "MODRESERVED"; break;
1109 case MODSETMINIROOT
: s
= "MODSETMINIROOT"; break;
1110 case MODADDMAJBIND
: s
= "MODADDMAJBIND"; break;
1111 case MODGETPATH
: s
= "MODGETPATH"; break;
1112 case MODGETPATHLEN
: s
= "MODGETPATHLEN"; break;
1113 case MODREADSYSBIND
: s
= "MODREADSYSBIND"; break;
1114 case MODGETMAJBIND
: s
= "MODGETMAJBIND"; break;
1115 case MODGETNAME
: s
= "MODGETNAME"; break;
1116 case MODSIZEOF_DEVID
: s
= "MODSIZEOF_DEVID"; break;
1117 case MODGETDEVID
: s
= "MODGETDEVID"; break;
1118 case MODSIZEOF_MINORNAME
: s
= "MODSIZEOF_MINORNAME"; break;
1119 case MODGETMINORNAME
: s
= "MODGETMINORNAME"; break;
1120 case MODGETFBNAME
: s
= "MODGETFBNAME"; break;
1121 case MODEVENTS
: s
= "MODEVENTS"; break;
1122 case MODREREADDACF
: s
= "MODREREADDACF"; break;
1123 case MODLOADDRVCONF
: s
= "MODLOADDRVCONF"; break;
1124 case MODUNLOADDRVCONF
: s
= "MODUNLOADDRVCONF"; break;
1125 case MODREMMAJBIND
: s
= "MODREMMAJBIND"; break;
1126 case MODDEVT2INSTANCE
: s
= "MODDEVT2INSTANCE"; break;
1127 case MODGETDEVFSPATH_LEN
: s
= "MODGETDEVFSPATH_LEN"; break;
1128 case MODGETDEVFSPATH
: s
= "MODGETDEVFSPATH"; break;
1129 case MODDEVID2PATHS
: s
= "MODDEVID2PATHS"; break;
1130 case MODSETDEVPOLICY
: s
= "MODSETDEVPOLICY"; break;
1131 case MODGETDEVPOLICY
: s
= "MODGETDEVPOLICY"; break;
1132 case MODALLOCPRIV
: s
= "MODALLOCPRIV"; break;
1133 case MODGETDEVPOLICYBYNAME
:
1134 s
= "MODGETDEVPOLICYBYNAME"; break;
1135 case MODLOADMINORPERM
: s
= "MODLOADMINORPERM"; break;
1136 case MODADDMINORPERM
: s
= "MODADDMINORPERM"; break;
1137 case MODREMMINORPERM
: s
= "MODREMMINORPERM"; break;
1138 case MODREMDRVCLEANUP
: s
= "MODREMDRVCLEANUP"; break;
1139 case MODDEVEXISTS
: s
= "MODDEVEXISTS"; break;
1140 case MODDEVREADDIR
: s
= "MODDEVREADDIR"; break;
1141 case MODDEVEMPTYDIR
: s
= "MODDEVEMPTYDIR"; break;
1142 case MODDEVNAME
: s
= "MODDEVNAME"; break;
1143 case MODGETDEVFSPATH_MI_LEN
:
1144 s
= "MODGETDEVFSPATH_MI_LEN"; break;
1145 case MODGETDEVFSPATH_MI
:
1146 s
= "MODGETDEVFSPATH_MI"; break;
1147 case MODREMDRVALIAS
: s
= "MODREMDRVALIAS"; break;
1148 case MODHPOPS
: s
= "MODHPOPS"; break;
1153 prt_dec(pri
, 0, val
);
1159 prt_acl(private_t
*pri
, int raw
, long val
) /* print acl() code */
1161 const char *s
= NULL
;
1165 case GETACL
: s
= "GETACL"; break;
1166 case SETACL
: s
= "SETACL"; break;
1167 case GETACLCNT
: s
= "GETACLCNT"; break;
1168 case ACE_GETACL
: s
= "ACE_GETACL"; break;
1169 case ACE_SETACL
: s
= "ACE_SETACL"; break;
1170 case ACE_GETACLCNT
: s
= "ACE_GETACLCNT"; break;
1175 prt_dec(pri
, 0, val
);
1181 prt_aio(private_t
*pri
, int raw
, long val
) /* print kaio() code */
1183 const char *s
= NULL
;
1187 switch (val
& ~AIO_POLL_BIT
) {
1188 case AIOREAD
: s
= "AIOREAD"; break;
1189 case AIOWRITE
: s
= "AIOWRITE"; break;
1190 case AIOWAIT
: s
= "AIOWAIT"; break;
1191 case AIOCANCEL
: s
= "AIOCANCEL"; break;
1192 case AIONOTIFY
: s
= "AIONOTIFY"; break;
1193 case AIOINIT
: s
= "AIOINIT"; break;
1194 case AIOSTART
: s
= "AIOSTART"; break;
1195 case AIOLIO
: s
= "AIOLIO"; break;
1196 case AIOSUSPEND
: s
= "AIOSUSPEND"; break;
1197 case AIOERROR
: s
= "AIOERROR"; break;
1198 case AIOLIOWAIT
: s
= "AIOLIOWAIT"; break;
1199 case AIOAREAD
: s
= "AIOAREAD"; break;
1200 case AIOAWRITE
: s
= "AIOAWRITE"; break;
1202 * We have to hardcode the values for the 64-bit versions of
1203 * these calls, because <sys/aio.h> defines them to be identical
1204 * when compiled 64-bit. If our target is 32-bit, we still need
1205 * to decode them correctly.
1207 case 13: s
= "AIOLIO64"; break;
1208 case 14: s
= "AIOSUSPEND64"; break;
1209 case 15: s
= "AUIOERROR64"; break;
1210 case 16: s
= "AIOLIOWAIT64"; break;
1211 case 17: s
= "AIOAREAD64"; break;
1212 case 18: s
= "AIOAWRITE64"; break;
1213 case 19: s
= "AIOCANCEL64"; break;
1216 * AIOFSYNC doesn't correspond to a syscall.
1218 case AIOWAITN
: s
= "AIOWAITN"; break;
1220 if (s
!= NULL
&& (val
& AIO_POLL_BIT
)) {
1221 (void) strlcpy(buf
, s
, sizeof (buf
));
1222 (void) strlcat(buf
, "|AIO_POLL_BIT", sizeof (buf
));
1223 s
= (const char *)buf
;
1228 prt_dec(pri
, 0, val
);
1234 prt_aud(private_t
*pri
, int raw
, long val
) /* print auditsys() code */
1236 const char *s
= NULL
;
1240 case BSM_GETAUID
: s
= "BSM_GETAUID"; break;
1241 case BSM_SETAUID
: s
= "BSM_SETAUID"; break;
1242 case BSM_GETAUDIT
: s
= "BSM_GETAUDIT"; break;
1243 case BSM_SETAUDIT
: s
= "BSM_SETAUDIT"; break;
1244 case BSM_AUDIT
: s
= "BSM_AUDIT"; break;
1245 case BSM_AUDITCTL
: s
= "BSM_AUDITCTL"; break;
1246 case BSM_GETAUDIT_ADDR
: s
= "BSM_GETAUDIT_ADDR"; break;
1247 case BSM_SETAUDIT_ADDR
: s
= "BSM_SETAUDIT_ADDR"; break;
1252 prt_dec(pri
, 0, val
);
1258 prt_cor(private_t
*pri
, int raw
, long val
) /* print corectl() subcode */
1260 const char *s
= NULL
;
1264 case CC_SET_OPTIONS
:
1265 s
= "CC_SET_OPTIONS"; break;
1266 case CC_GET_OPTIONS
:
1267 s
= "CC_GET_OPTIONS"; break;
1268 case CC_SET_GLOBAL_PATH
:
1269 s
= "CC_SET_GLOBAL_PATH"; break;
1270 case CC_GET_GLOBAL_PATH
:
1271 s
= "CC_GET_GLOBAL_PATH"; break;
1272 case CC_SET_PROCESS_PATH
:
1273 s
= "CC_SET_PROCESS_PATH"; break;
1274 case CC_GET_PROCESS_PATH
:
1275 s
= "CC_GET_PROCESS_PATH"; break;
1276 case CC_SET_GLOBAL_CONTENT
:
1277 s
= "CC_SET_GLOBAL_CONTENT"; break;
1278 case CC_GET_GLOBAL_CONTENT
:
1279 s
= "CC_GET_GLOBAL_CONTENT"; break;
1280 case CC_SET_PROCESS_CONTENT
:
1281 s
= "CC_SET_PROCESS_CONTENT"; break;
1282 case CC_GET_PROCESS_CONTENT
:
1283 s
= "CC_GET_PROCESS_CONTENT"; break;
1284 case CC_SET_DEFAULT_PATH
:
1285 s
= "CC_SET_DEFAULT_PATH"; break;
1286 case CC_GET_DEFAULT_PATH
:
1287 s
= "CC_GET_DEFAULT_PATH"; break;
1288 case CC_SET_DEFAULT_CONTENT
:
1289 s
= "CC_SET_DEFAULT_CONTENT"; break;
1290 case CC_GET_DEFAULT_CONTENT
:
1291 s
= "CC_GET_DEFAULT_CONTENT"; break;
1296 prt_dec(pri
, 0, val
);
1302 prt_cco(private_t
*pri
, int raw
, long val
) /* print corectl() options */
1307 prt_dec(pri
, 0, val
);
1308 else if (raw
|| (val
& ~CC_OPTIONS
))
1309 prt_hhx(pri
, 0, val
);
1311 #define CBSIZE sizeof (pri->code_buf)
1314 if (val
& CC_GLOBAL_PATH
)
1315 (void) strlcat(s
, "|CC_GLOBAL_PATH", CBSIZE
);
1316 if (val
& CC_PROCESS_PATH
)
1317 (void) strlcat(s
, "|CC_PROCESS_PATH", CBSIZE
);
1318 if (val
& CC_GLOBAL_SETID
)
1319 (void) strlcat(s
, "|CC_GLOBAL_SETID", CBSIZE
);
1320 if (val
& CC_PROCESS_SETID
)
1321 (void) strlcat(s
, "|CC_PROCESS_SETID", CBSIZE
);
1322 if (val
& CC_GLOBAL_LOG
)
1323 (void) strlcat(s
, "|CC_GLOBAL_LOG", CBSIZE
);
1325 prt_hhx(pri
, 0, val
);
1327 outstring(pri
, ++s
);
1333 prt_ccc(private_t
*pri
, int raw
, long val
) /* print corectl() content */
1337 if (Pread(Proc
, &ccc
, sizeof (ccc
), val
) != sizeof (ccc
))
1338 prt_hex(pri
, 0, val
);
1339 else if (!raw
&& proc_content2str(ccc
, pri
->code_buf
,
1340 sizeof (pri
->code_buf
)) >= 0)
1341 outstring(pri
, pri
->code_buf
);
1343 prt_hhx(pri
, 0, (long)ccc
);
1347 prt_rcc(private_t
*pri
, int raw
, long val
) /* print corectl() ret. cont. */
1351 if (pri
->Errno
|| Pread(Proc
, &ccc
, sizeof (ccc
), val
) != sizeof (ccc
))
1352 prt_hex(pri
, 0, val
);
1353 else if (!raw
&& proc_content2str(ccc
, pri
->code_buf
,
1354 sizeof (pri
->code_buf
)) >= 0)
1355 outstring(pri
, pri
->code_buf
);
1357 prt_hhx(pri
, 0, (long)ccc
);
1361 prt_cpc(private_t
*pri
, int raw
, long val
) /* print cpc() subcode */
1363 const char *s
= NULL
;
1367 case CPC_BIND
: s
= "CPC_BIND"; break;
1368 case CPC_SAMPLE
: s
= "CPC_SAMPLE"; break;
1369 case CPC_INVALIDATE
: s
= "CPC_INVALIDATE"; break;
1370 case CPC_RELE
: s
= "CPC_RELE"; break;
1371 case CPC_EVLIST_SIZE
: s
= "CPC_EVLIST_SIZE"; break;
1372 case CPC_LIST_EVENTS
: s
= "CPC_LIST_EVENTS"; break;
1373 case CPC_ATTRLIST_SIZE
: s
= "CPC_ATTRLIST_SIZE"; break;
1374 case CPC_LIST_ATTRS
: s
= "CPC_LIST_ATTRS"; break;
1375 case CPC_IMPL_NAME
: s
= "CPC_IMPL_NAME"; break;
1376 case CPC_CPUREF
: s
= "CPC_CPUREF"; break;
1377 case CPC_USR_EVENTS
: s
= "CPC_USR_EVENTS"; break;
1378 case CPC_SYS_EVENTS
: s
= "CPC_SYS_EVENTS"; break;
1379 case CPC_NPIC
: s
= "CPC_NPIC"; break;
1380 case CPC_CAPS
: s
= "CPC_CAPS"; break;
1381 case CPC_ENABLE
: s
= "CPC_ENABLE"; break;
1382 case CPC_DISABLE
: s
= "CPC_DISABLE"; break;
1387 prt_dec(pri
, 0, val
);
1393 outstring(private_t
*pri
, const char *s
)
1395 int len
= strlen(s
);
1398 (void) strcpy(pri
->sys_string
+ pri
->sys_leng
, s
);
1399 pri
->sys_leng
+= len
;
1403 grow(private_t
*pri
, int nbyte
) /* reallocate format buffer if necessary */
1405 while (pri
->sys_leng
+ nbyte
>= pri
->sys_ssize
)
1406 pri
->sys_string
= my_realloc(pri
->sys_string
,
1407 pri
->sys_ssize
*= 2, "format buffer");
1411 prt_clc(private_t
*pri
, int raw
, long val
)
1413 const char *s
= NULL
;
1417 case CL_INITIALIZE
: s
= "CL_INITIALIZE"; break;
1418 case CL_CONFIG
: s
= "CL_CONFIG"; break;
1423 prt_dec(pri
, 0, val
);
1429 prt_clf(private_t
*pri
, int raw
, long val
)
1431 const char *s
= NULL
;
1434 switch (pri
->sys_args
[0]) {
1436 switch (pri
->sys_args
[1]) {
1438 s
= "CL_NODEID"; break;
1439 case CL_HIGHEST_NODEID
:
1440 s
= "CL_HIGHEST_NODEID"; break;
1444 switch (pri
->sys_args
[1]) {
1445 case CL_GET_BOOTFLAG
:
1446 s
= "CL_GET_BOOTFLAG"; break;
1453 prt_dec(pri
, 0, val
);
1459 prt_sqc(private_t
*pri
, int raw
, long val
) /* print sigqueue() si_code */
1461 const char *s
= NULL
;
1465 case SI_QUEUE
: s
= "SI_QUEUE"; break;
1466 case SI_TIMER
: s
= "SI_TIMER"; break;
1467 case SI_ASYNCIO
: s
= "SI_ASYNCIO"; break;
1468 case SI_MESGQ
: s
= "SI_MESGQ"; break;
1473 prt_dec(pri
, 0, val
);
1479 * print priocntlsys() (key, value) pair key.
1482 print_pck(private_t
*pri
, int raw
, long val
)
1484 const char *s
= NULL
;
1485 char clname
[PC_CLNMSZ
];
1487 if ((pri
->sys_args
[2] != PC_GETXPARMS
&&
1488 pri
->sys_args
[2] != PC_SETXPARMS
) || val
== 0 || raw
) {
1489 prt_dec(pri
, 0, val
);
1493 if (pri
->sys_args
[3] == NULL
) {
1494 if (val
== PC_KY_CLNAME
) {
1498 prt_dec(pri
, 0, val
);
1502 if (Pread(Proc
, &clname
, PC_CLNMSZ
, pri
->sys_args
[3]) != PC_CLNMSZ
) {
1503 prt_dec(pri
, 0, val
);
1507 if (strcmp(clname
, "TS") == 0) {
1509 case TS_KY_UPRILIM
: s
= "TS_KY_UPRILIM"; break;
1510 case TS_KY_UPRI
: s
= "TS_KY_UPRI"; break;
1513 } else if (strcmp(clname
, "IA") == 0) {
1515 case IA_KY_UPRILIM
: s
= "IA_KY_UPRILIM"; break;
1516 case IA_KY_UPRI
: s
= "IA_KY_UPRI"; break;
1517 case IA_KY_MODE
: s
= "IA_KY_MODE"; break;
1520 } else if (strcmp(clname
, "RT") == 0) {
1522 case RT_KY_PRI
: s
= "RT_KY_PRI"; break;
1523 case RT_KY_TQSECS
: s
= "RT_KY_TQSECS"; break;
1524 case RT_KY_TQNSECS
: s
= "RT_KY_TQNSECS"; break;
1525 case RT_KY_TQSIG
: s
= "RT_KY_TQSIG"; break;
1528 } else if (strcmp(clname
, "FSS") == 0) {
1530 case FSS_KY_UPRILIM
: s
= "FSS_KY_UPRILIM"; break;
1531 case FSS_KY_UPRI
: s
= "FSS_KY_UPRI"; break;
1534 } else if (strcmp(clname
, "FX") == 0) {
1536 case FX_KY_UPRILIM
: s
= "FX_KY_UPRILIM"; break;
1537 case FX_KY_UPRI
: s
= "FX_KY_UPRI"; break;
1538 case FX_KY_TQSECS
: s
= "FX_KY_TQSECS"; break;
1539 case FX_KY_TQNSECS
: s
= "FX_KY_TQNSECS"; break;
1545 prt_dec(pri
, 0, val
);
1551 * print priocntlsys() fourth argument.
1555 prt_pc4(private_t
*pri
, int raw
, long val
)
1557 /* look at pricntlsys function */
1558 if ((pri
->sys_args
[2] != PC_GETXPARMS
&&
1559 pri
->sys_args
[2] != PC_SETXPARMS
))
1560 prt_hex(pri
, 0, val
);
1562 prt_stg(pri
, 0, val
);
1564 prt_dec(pri
, 0, val
);
1568 * print priocntlsys() (key, value) pairs (5th argument).
1572 prt_pc5(private_t
*pri
, int raw
, long val
)
1575 pc_vaparm_t
*vpp
= &prms
.pc_parms
[0];
1579 /* look at pricntlsys function */
1580 if ((pri
->sys_args
[2] != PC_GETXPARMS
&&
1581 pri
->sys_args
[2] != PC_SETXPARMS
) || val
== 0) {
1586 if (Pread(Proc
, &prms
, sizeof (prms
), val
) != sizeof (prms
)) {
1587 prt_hex(pri
, 0, val
);
1591 if ((cnt
= prms
.pc_vaparmscnt
) > PC_VAPARMCNT
)
1594 for (; cnt
--; vpp
++) {
1595 print_pck(pri
, 0, vpp
->pc_key
);
1596 outstring(pri
, ", ");
1597 prt_hex(pri
, 0, (long)vpp
->pc_parm
);
1598 outstring(pri
, ", ");
1601 prt_dec(pri
, 0, PC_KY_NULL
);
1606 prt_psflags(private_t
*pri
, secflagset_t val
)
1611 outstring(pri
, "0x0");
1616 if (secflag_isset(val
, PROC_SEC_ASLR
)) {
1617 (void) strlcat(str
, "|PROC_SEC_ASLR", sizeof (str
));
1618 secflag_clear(&val
, PROC_SEC_ASLR
);
1620 if (secflag_isset(val
, PROC_SEC_FORBIDNULLMAP
)) {
1621 (void) strlcat(str
, "|PROC_SEC_FORBIDNULLMAP",
1623 secflag_clear(&val
, PROC_SEC_FORBIDNULLMAP
);
1625 if (secflag_isset(val
, PROC_SEC_NOEXECSTACK
)) {
1626 (void) strlcat(str
, "|PROC_SEC_NOEXECSTACK",
1628 secflag_clear(&val
, PROC_SEC_NOEXECSTACK
);
1632 (void) snprintf(str
, sizeof (str
), "%s|%#x", str
, val
);
1634 outstring(pri
, str
+ 1);
1638 * Print a psecflags(2) delta
1641 prt_psdelta(private_t
*pri
, int raw
, long value
)
1646 (Pread(Proc
, &psd
, sizeof (psd
), value
) != sizeof (psd
))) {
1647 prt_hex(pri
, 0, value
);
1650 outstring(pri
, "{ ");
1651 prt_psflags(pri
, psd
.psd_add
);
1652 outstring(pri
, ", ");
1653 prt_psflags(pri
, psd
.psd_rem
);
1654 outstring(pri
, ", ");
1655 prt_psflags(pri
, psd
.psd_assign
);
1656 outstring(pri
, ", ");
1657 outstring(pri
, psd
.psd_ass_active
? "B_TRUE" : "B_FALSE");
1658 outstring(pri
, " }");
1662 * Print a psecflagswhich_t
1665 prt_psfw(private_t
*pri
, int raw
, long value
)
1667 psecflagwhich_t which
= (psecflagwhich_t
)value
;
1671 prt_dec(pri
, 0, value
);
1677 s
= "PSF_EFFECTIVE";
1691 prt_dec(pri
, 0, value
);
1697 * Print processor set id, including logical expansion of "special" ids.
1700 prt_pst(private_t
*pri
, int raw
, long val
)
1702 const char *s
= NULL
;
1705 switch ((psetid_t
)val
) {
1706 case PS_NONE
: s
= "PS_NONE"; break;
1707 case PS_QUERY
: s
= "PS_QUERY"; break;
1708 case PS_MYID
: s
= "PS_MYID"; break;
1713 prt_dec(pri
, 0, val
);
1719 * Print meminfo() argument.
1723 prt_mif(private_t
*pri
, int raw
, long val
)
1725 struct meminfo minfo
;
1728 if (data_model
== PR_MODEL_ILP32
) {
1729 struct meminfo32 minfo32
;
1731 if (Pread(Proc
, &minfo32
, sizeof (struct meminfo32
), val
) !=
1732 sizeof (struct meminfo32
)) {
1733 prt_dec(pri
, 0, pri
->sys_args
[1]); /* addr_count */
1734 outstring(pri
, ", ");
1735 prt_hex(pri
, 0, val
);
1739 * arrange the arguments in the order that user calls with
1741 prt_hex(pri
, 0, minfo32
.mi_inaddr
);
1742 outstring(pri
, ", ");
1743 prt_dec(pri
, 0, pri
->sys_args
[1]); /* addr_count */
1744 outstring(pri
, ", ");
1745 prt_hex(pri
, 0, minfo32
.mi_info_req
);
1746 outstring(pri
, ", ");
1747 prt_dec(pri
, 0, minfo32
.mi_info_count
);
1748 outstring(pri
, ", ");
1749 prt_hex(pri
, 0, minfo32
.mi_outdata
);
1750 outstring(pri
, ", ");
1751 prt_hex(pri
, 0, minfo32
.mi_validity
);
1755 if (Pread(Proc
, &minfo
, sizeof (struct meminfo
), val
) !=
1756 sizeof (struct meminfo
)) {
1757 prt_dec(pri
, 0, pri
->sys_args
[1]); /* addr_count */
1758 outstring(pri
, ", ");
1759 prt_hex(pri
, 0, val
);
1763 * arrange the arguments in the order that user calls with
1765 prt_hex(pri
, 0, (long)minfo
.mi_inaddr
);
1766 outstring(pri
, ", ");
1767 prt_dec(pri
, 0, pri
->sys_args
[1]); /* addr_count */
1768 outstring(pri
, ", ");
1769 prt_hex(pri
, 0, (long)minfo
.mi_info_req
);
1770 outstring(pri
, ", ");
1771 prt_dec(pri
, 0, minfo
.mi_info_count
);
1772 outstring(pri
, ", ");
1773 prt_hex(pri
, 0, (long)minfo
.mi_outdata
);
1774 outstring(pri
, ", ");
1775 prt_hex(pri
, 0, (long)minfo
.mi_validity
);
1780 * Print so_socket() 1st argument.
1784 prt_pfm(private_t
*pri
, int raw
, long val
)
1786 /* Protocol Families have same names as Address Families */
1787 if ((ulong_t
)val
< MAX_AFCODES
) {
1788 outstring(pri
, "PF_");
1789 outstring(pri
, afcodes
[val
]);
1791 prt_dec(pri
, 0, val
);
1796 * Print sockconfig() subcode.
1800 prt_skc(private_t
*pri
, int raw
, long val
)
1802 const char *s
= NULL
;
1806 case SOCKCONFIG_ADD_SOCK
:
1807 s
= "SOCKCONFIG_ADD_SOCK"; break;
1808 case SOCKCONFIG_REMOVE_SOCK
:
1809 s
= "SOCKCONFIG_REMOVE_SOCK"; break;
1810 case SOCKCONFIG_ADD_FILTER
:
1811 s
= "SOCKCONFIG_ADD_FILTER"; break;
1812 case SOCKCONFIG_REMOVE_FILTER
:
1813 s
= "SOCKCONFIG_REMOVE_FILTER"; break;
1817 prt_dec(pri
, 0, val
);
1822 * Print so_socket() 2nd argument.
1826 prt_skt(private_t
*pri
, int raw
, long val
)
1829 long type
= val
& SOCK_TYPE_MASK
;
1831 if ((ulong_t
)type
<= MAX_SOCKTYPES
&&
1832 (s
= socktype_codes
[type
]) != NULL
) {
1834 if ((val
& SOCK_CLOEXEC
) != 0) {
1835 outstring(pri
, "|SOCK_CLOEXEC");
1838 prt_dec(pri
, 0, val
);
1844 * Print so_socket() 3rd argument.
1848 prt_skp(private_t
*pri
, int raw
, long val
)
1852 /* cheating -- look at the protocol-family */
1853 switch (pri
->sys_args
[0]) {
1856 case PF_NCA
: if ((s
= ipprotos((int)val
)) != NULL
) {
1861 default: prt_dec(pri
, 0, val
);
1868 * Print so_socket() 5th argument.
1872 prt_skv(private_t
*pri
, int raw
, long val
)
1875 case SOV_STREAM
: outstring(pri
, "SOV_STREAM"); break;
1876 case SOV_DEFAULT
: outstring(pri
, "SOV_DEFAULT"); break;
1877 case SOV_SOCKSTREAM
: outstring(pri
, "SOV_SOCKSTREAM"); break;
1878 case SOV_SOCKBSD
: outstring(pri
, "SOV_SOCKBSD"); break;
1879 case SOV_XPG4_2
: outstring(pri
, "SOV_XPG4_2"); break;
1880 default: prt_dec(pri
, 0, val
); break;
1885 * Print accept4() flags argument.
1888 prt_acf(private_t
*pri
, int raw
, long val
)
1892 (val
& ~(SOCK_CLOEXEC
|SOCK_NDELAY
|SOCK_NONBLOCK
))) {
1893 prt_dex(pri
, 0, val
);
1897 if (val
& SOCK_CLOEXEC
) {
1898 outstring(pri
, "|SOCK_CLOEXEC" + first
);
1901 if (val
& SOCK_NDELAY
) {
1902 outstring(pri
, "|SOCK_NDELAY" + first
);
1905 if (val
& SOCK_NONBLOCK
) {
1906 outstring(pri
, "|SOCK_NONBLOCK" + first
);
1912 * Print setsockopt()/getsockopt() 2nd argument.
1916 prt_sol(private_t
*pri
, int raw
, long val
)
1918 if (val
== SOL_SOCKET
) {
1919 outstring(pri
, "SOL_SOCKET");
1920 } else if (val
== SOL_ROUTE
) {
1921 outstring(pri
, "SOL_ROUTE");
1923 const struct protoent
*p
;
1924 struct protoent res
;
1925 char buf
[NSS_BUFLEN_PROTOCOLS
];
1927 if ((p
= getprotobynumber_r(val
, &res
,
1928 (char *)buf
, sizeof (buf
))) != NULL
)
1929 outstring(pri
, p
->p_name
);
1931 prt_dec(pri
, 0, val
);
1937 sol_optname(private_t
*pri
, long val
)
1939 #define CBSIZE sizeof (pri->code_buf)
1940 if (val
>= SO_SNDBUF
) {
1942 case SO_SNDBUF
: return ("SO_SNDBUF");
1943 case SO_RCVBUF
: return ("SO_RCVBUF");
1944 case SO_SNDLOWAT
: return ("SO_SNDLOWAT");
1945 case SO_RCVLOWAT
: return ("SO_RCVLOWAT");
1946 case SO_SNDTIMEO
: return ("SO_SNDTIMEO");
1947 case SO_RCVTIMEO
: return ("SO_RCVTIMEO");
1948 case SO_ERROR
: return ("SO_ERROR");
1949 case SO_TYPE
: return ("SO_TYPE");
1950 case SO_PROTOTYPE
: return ("SO_PROTOTYPE");
1951 case SO_ANON_MLP
: return ("SO_ANON_MLP");
1952 case SO_MAC_EXEMPT
: return ("SO_MAC_EXEMPT");
1953 case SO_ALLZONES
: return ("SO_ALLZONES");
1954 case SO_MAC_IMPLICIT
: return ("SO_MAC_IMPLICIT");
1955 case SO_VRRP
: return ("SO_VRRP");
1956 case SO_EXCLBIND
: return ("SO_EXCLBIND");
1957 case SO_DOMAIN
: return ("SO_DOMAIN");
1959 default: (void) snprintf(pri
->code_buf
, CBSIZE
,
1961 return (pri
->code_buf
);
1964 char *s
= pri
->code_buf
;
1969 val2
= val
& ~(SO_DEBUG
|SO_ACCEPTCONN
|SO_REUSEADDR
|SO_KEEPALIVE
|
1970 SO_DONTROUTE
|SO_BROADCAST
|SO_USELOOPBACK
|SO_LINGER
|
1971 SO_OOBINLINE
|SO_DGRAM_ERRIND
|SO_RECVUCRED
);
1973 used
= snprintf(s
, CBSIZE
, "|0x%lx", val2
);
1975 used
= strlcat(s
, "|SO_DEBUG", CBSIZE
);
1976 if (val
& SO_ACCEPTCONN
)
1977 used
= strlcat(s
, "|SO_ACCEPTCONN", CBSIZE
);
1978 if (val
& SO_REUSEADDR
)
1979 used
= strlcat(s
, "|SO_REUSEADDR", CBSIZE
);
1980 if (val
& SO_KEEPALIVE
)
1981 used
= strlcat(s
, "|SO_KEEPALIVE", CBSIZE
);
1982 if (val
& SO_DONTROUTE
)
1983 used
= strlcat(s
, "|SO_DONTROUTE", CBSIZE
);
1984 if (val
& SO_BROADCAST
)
1985 used
= strlcat(s
, "|SO_BROADCAST", CBSIZE
);
1986 if (val
& SO_USELOOPBACK
)
1987 used
= strlcat(s
, "|SO_USELOOPBACK", CBSIZE
);
1988 if (val
& SO_LINGER
)
1989 used
= strlcat(s
, "|SO_LINGER", CBSIZE
);
1990 if (val
& SO_OOBINLINE
)
1991 used
= strlcat(s
, "|SO_OOBINLINE", CBSIZE
);
1992 if (val
& SO_DGRAM_ERRIND
)
1993 used
= strlcat(s
, "|SO_DGRAM_ERRIND", CBSIZE
);
1994 if (val
& SO_RECVUCRED
)
1995 used
= strlcat(s
, "|SO_RECVUCRED", CBSIZE
);
1996 if (used
>= CBSIZE
|| val
== 0)
1997 (void) snprintf(s
+ 1, CBSIZE
-1, "0x%lx", val
);
1998 return ((const char *)(s
+ 1));
2004 route_optname(private_t
*pri
, long val
)
2008 return ("RT_AWARE");
2010 (void) snprintf(pri
->code_buf
, sizeof (pri
->code_buf
),
2012 return (pri
->code_buf
);
2017 tcp_optname(private_t
*pri
, long val
)
2020 case TCP_NODELAY
: return ("TCP_NODELAY");
2021 case TCP_MAXSEG
: return ("TCP_MAXSEG");
2022 case TCP_KEEPALIVE
: return ("TCP_KEEPALIVE");
2023 case TCP_NOTIFY_THRESHOLD
: return ("TCP_NOTIFY_THRESHOLD");
2024 case TCP_ABORT_THRESHOLD
: return ("TCP_ABORT_THRESHOLD");
2025 case TCP_CONN_NOTIFY_THRESHOLD
: return ("TCP_CONN_NOTIFY_THRESHOLD");
2026 case TCP_CONN_ABORT_THRESHOLD
: return ("TCP_CONN_ABORT_THRESHOLD");
2027 case TCP_RECVDSTADDR
: return ("TCP_RECVDSTADDR");
2028 case TCP_ANONPRIVBIND
: return ("TCP_ANONPRIVBIND");
2029 case TCP_EXCLBIND
: return ("TCP_EXCLBIND");
2030 case TCP_INIT_CWND
: return ("TCP_INIT_CWND");
2031 case TCP_KEEPALIVE_THRESHOLD
: return ("TCP_KEEPALIVE_THRESHOLD");
2032 case TCP_KEEPALIVE_ABORT_THRESHOLD
:
2033 return ("TCP_KEEPALIVE_ABORT_THRESHOLD");
2034 case TCP_CORK
: return ("TCP_CORK");
2035 case TCP_RTO_INITIAL
: return ("TCP_RTO_INITIAL");
2036 case TCP_RTO_MIN
: return ("TCP_RTO_MIN");
2037 case TCP_RTO_MAX
: return ("TCP_RTO_MAX");
2038 case TCP_LINGER2
: return ("TCP_LINGER2");
2039 case TCP_KEEPIDLE
: return ("TCP_KEEPIDLE");
2040 case TCP_KEEPCNT
: return ("TCP_KEEPCNT");
2041 case TCP_KEEPINTVL
: return ("TCP_KEEPINTVL");
2043 default: (void) snprintf(pri
->code_buf
,
2044 sizeof (pri
->code_buf
),
2046 return (pri
->code_buf
);
2052 sctp_optname(private_t
*pri
, long val
)
2055 case SCTP_RTOINFO
: return ("SCTP_RTOINFO");
2056 case SCTP_ASSOCINFO
: return ("SCTP_ASSOCINFO");
2057 case SCTP_INITMSG
: return ("SCTP_INITMSG");
2058 case SCTP_NODELAY
: return ("SCTP_NODELAY");
2059 case SCTP_AUTOCLOSE
: return ("SCTP_AUTOCLOSE");
2060 case SCTP_SET_PEER_PRIMARY_ADDR
:
2061 return ("SCTP_SET_PEER_PRIMARY_ADDR");
2062 case SCTP_PRIMARY_ADDR
: return ("SCTP_PRIMARY_ADDR");
2063 case SCTP_ADAPTATION_LAYER
: return ("SCTP_ADAPTATION_LAYER");
2064 case SCTP_DISABLE_FRAGMENTS
: return ("SCTP_DISABLE_FRAGMENTS");
2065 case SCTP_PEER_ADDR_PARAMS
: return ("SCTP_PEER_ADDR_PARAMS");
2066 case SCTP_DEFAULT_SEND_PARAM
: return ("SCTP_DEFAULT_SEND_PARAM");
2067 case SCTP_EVENTS
: return ("SCTP_EVENTS");
2068 case SCTP_I_WANT_MAPPED_V4_ADDR
:
2069 return ("SCTP_I_WANT_MAPPED_V4_ADDR");
2070 case SCTP_MAXSEG
: return ("SCTP_MAXSEG");
2071 case SCTP_STATUS
: return ("SCTP_STATUS");
2072 case SCTP_GET_PEER_ADDR_INFO
: return ("SCTP_GET_PEER_ADDR_INFO");
2074 case SCTP_ADD_ADDR
: return ("SCTP_ADD_ADDR");
2075 case SCTP_REM_ADDR
: return ("SCTP_REM_ADDR");
2077 default: (void) snprintf(pri
->code_buf
,
2078 sizeof (pri
->code_buf
),
2080 return (pri
->code_buf
);
2086 udp_optname(private_t
*pri
, long val
)
2089 case UDP_CHECKSUM
: return ("UDP_CHECKSUM");
2090 case UDP_ANONPRIVBIND
: return ("UDP_ANONPRIVBIND");
2091 case UDP_EXCLBIND
: return ("UDP_EXCLBIND");
2092 case UDP_RCVHDR
: return ("UDP_RCVHDR");
2093 case UDP_NAT_T_ENDPOINT
: return ("UDP_NAT_T_ENDPOINT");
2095 default: (void) snprintf(pri
->code_buf
,
2096 sizeof (pri
->code_buf
), "0x%lx",
2098 return (pri
->code_buf
);
2104 * Print setsockopt()/getsockopt() 3rd argument.
2108 prt_son(private_t
*pri
, int raw
, long val
)
2110 /* cheating -- look at the level */
2111 switch (pri
->sys_args
[1]) {
2112 case SOL_SOCKET
: outstring(pri
, sol_optname(pri
, val
));
2114 case SOL_ROUTE
: outstring(pri
, route_optname(pri
, val
));
2116 case IPPROTO_TCP
: outstring(pri
, tcp_optname(pri
, val
));
2118 case IPPROTO_UDP
: outstring(pri
, udp_optname(pri
, val
));
2120 case IPPROTO_SCTP
: outstring(pri
, sctp_optname(pri
, val
));
2122 default: prt_dec(pri
, 0, val
);
2133 prt_utt(private_t
*pri
, int raw
, long val
)
2135 const char *s
= NULL
;
2140 case UT_INSTRUCTION_DISABLED
:
2141 s
= "UT_INSTRUCTION_DISABLED"; break;
2142 case UT_INSTRUCTION_ERROR
:
2143 s
= "UT_INSTRUCTION_ERROR"; break;
2144 case UT_INSTRUCTION_PROTECTION
:
2145 s
= "UT_INSTRUCTION_PROTECTION"; break;
2146 case UT_ILLTRAP_INSTRUCTION
:
2147 s
= "UT_ILLTRAP_INSTRUCTION"; break;
2148 case UT_ILLEGAL_INSTRUCTION
:
2149 s
= "UT_ILLEGAL_INSTRUCTION"; break;
2150 case UT_PRIVILEGED_OPCODE
:
2151 s
= "UT_PRIVILEGED_OPCODE"; break;
2152 case UT_FP_DISABLED
:
2153 s
= "UT_FP_DISABLED"; break;
2154 case UT_FP_EXCEPTION_IEEE_754
:
2155 s
= "UT_FP_EXCEPTION_IEEE_754"; break;
2156 case UT_FP_EXCEPTION_OTHER
:
2157 s
= "UT_FP_EXCEPTION_OTHER"; break;
2158 case UT_TAG_OVERFLOW
:
2159 s
= "UT_TAG_OVERFLOW"; break;
2160 case UT_DIVISION_BY_ZERO
:
2161 s
= "UT_DIVISION_BY_ZERO"; break;
2162 case UT_DATA_EXCEPTION
:
2163 s
= "UT_DATA_EXCEPTION"; break;
2165 s
= "UT_DATA_ERROR"; break;
2166 case UT_DATA_PROTECTION
:
2167 s
= "UT_DATA_PROTECTION"; break;
2168 case UT_MEM_ADDRESS_NOT_ALIGNED
:
2169 s
= "UT_MEM_ADDRESS_NOT_ALIGNED"; break;
2170 case UT_PRIVILEGED_ACTION
:
2171 s
= "UT_PRIVILEGED_ACTION"; break;
2172 case UT_ASYNC_DATA_ERROR
:
2173 s
= "UT_ASYNC_DATA_ERROR"; break;
2174 case UT_TRAP_INSTRUCTION_16
:
2175 s
= "UT_TRAP_INSTRUCTION_16"; break;
2176 case UT_TRAP_INSTRUCTION_17
:
2177 s
= "UT_TRAP_INSTRUCTION_17"; break;
2178 case UT_TRAP_INSTRUCTION_18
:
2179 s
= "UT_TRAP_INSTRUCTION_18"; break;
2180 case UT_TRAP_INSTRUCTION_19
:
2181 s
= "UT_TRAP_INSTRUCTION_19"; break;
2182 case UT_TRAP_INSTRUCTION_20
:
2183 s
= "UT_TRAP_INSTRUCTION_20"; break;
2184 case UT_TRAP_INSTRUCTION_21
:
2185 s
= "UT_TRAP_INSTRUCTION_21"; break;
2186 case UT_TRAP_INSTRUCTION_22
:
2187 s
= "UT_TRAP_INSTRUCTION_22"; break;
2188 case UT_TRAP_INSTRUCTION_23
:
2189 s
= "UT_TRAP_INSTRUCTION_23"; break;
2190 case UT_TRAP_INSTRUCTION_24
:
2191 s
= "UT_TRAP_INSTRUCTION_24"; break;
2192 case UT_TRAP_INSTRUCTION_25
:
2193 s
= "UT_TRAP_INSTRUCTION_25"; break;
2194 case UT_TRAP_INSTRUCTION_26
:
2195 s
= "UT_TRAP_INSTRUCTION_26"; break;
2196 case UT_TRAP_INSTRUCTION_27
:
2197 s
= "UT_TRAP_INSTRUCTION_27"; break;
2198 case UT_TRAP_INSTRUCTION_28
:
2199 s
= "UT_TRAP_INSTRUCTION_28"; break;
2200 case UT_TRAP_INSTRUCTION_29
:
2201 s
= "UT_TRAP_INSTRUCTION_29"; break;
2202 case UT_TRAP_INSTRUCTION_30
:
2203 s
= "UT_TRAP_INSTRUCTION_30"; break;
2204 case UT_TRAP_INSTRUCTION_31
:
2205 s
= "UT_TRAP_INSTRUCTION_31"; break;
2208 #endif /* __sparc */
2211 prt_dec(pri
, 0, val
);
2218 * Print utrap handler
2221 prt_uth(private_t
*pri
, int raw
, long val
)
2223 const char *s
= NULL
;
2227 case (long)UTH_NOCHANGE
: s
= "UTH_NOCHANGE"; break;
2232 prt_hex(pri
, 0, val
);
2238 access_flags(private_t
*pri
, long arg
)
2241 char *str
= pri
->code_buf
;
2243 if (arg
& ~(R_OK
|W_OK
|X_OK
|E_OK
))
2250 return ("F_OK|E_OK");
2254 (void) strlcat(str
, "|R_OK", sizeof (pri
->code_buf
));
2256 (void) strlcat(str
, "|W_OK", sizeof (pri
->code_buf
));
2258 (void) strlcat(str
, "|X_OK", sizeof (pri
->code_buf
));
2260 (void) strlcat(str
, "|E_OK", sizeof (pri
->code_buf
));
2261 return ((const char *)(str
+ 1));
2266 * Print access() flags.
2269 prt_acc(private_t
*pri
, int raw
, long val
)
2271 const char *s
= raw
? NULL
: access_flags(pri
, val
);
2274 prt_dex(pri
, 0, val
);
2280 * Print shutdown() "how" (2nd) argument
2283 prt_sht(private_t
*pri
, int raw
, long val
)
2286 prt_dex(pri
, 0, val
);
2290 case SHUT_RD
: outstring(pri
, "SHUT_RD"); break;
2291 case SHUT_WR
: outstring(pri
, "SHUT_WR"); break;
2292 case SHUT_RDWR
: outstring(pri
, "SHUT_RDWR"); break;
2293 default: prt_dec(pri
, 0, val
); break;
2298 * Print fcntl() F_SETFL flags (3rd) argument or fdsync flag (2nd arg)
2300 static struct fcntl_flags
{
2304 #define FC_FL(flag) { (long)flag, "|" # flag }
2326 prt_ffg(private_t
*pri
, int raw
, long val
)
2328 #define CBSIZE sizeof (pri->code_buf)
2329 char *s
= pri
->code_buf
;
2331 struct fcntl_flags
*fp
;
2334 (void) snprintf(s
, CBSIZE
, "0x%lx", val
);
2339 outstring(pri
, "(no flags)");
2344 for (fp
= fcntl_flags
;
2345 fp
< &fcntl_flags
[sizeof (fcntl_flags
) / sizeof (*fp
)]; fp
++) {
2346 if (val
& fp
->val
) {
2347 used
= strlcat(s
, fp
->name
, CBSIZE
);
2352 if (val
!= 0 && used
<= CBSIZE
)
2353 used
+= snprintf(s
+ used
, CBSIZE
- used
, "|0x%lx", val
);
2356 (void) snprintf(s
+ 1, CBSIZE
-1, "0x%lx", val
);
2357 outstring(pri
, s
+ 1);
2362 prt_prs(private_t
*pri
, int raw
, long val
)
2364 static size_t setsize
;
2365 priv_set_t
*set
= priv_allocset();
2368 const priv_impl_info_t
*info
= getprivimplinfo();
2370 setsize
= info
->priv_setsize
* sizeof (priv_chunk_t
);
2373 if (setsize
!= 0 && !raw
&& set
!= NULL
&&
2374 Pread(Proc
, set
, setsize
, val
) == setsize
) {
2377 outstring(pri
, "{");
2378 for (i
= 0; i
< setsize
/ sizeof (priv_chunk_t
); i
++) {
2379 char buf
[9]; /* 8 hex digits + '\0' */
2380 (void) snprintf(buf
, sizeof (buf
), "%08x",
2381 ((priv_chunk_t
*)set
)[i
]);
2382 outstring(pri
, buf
);
2385 outstring(pri
, "}");
2387 prt_hex(pri
, 0, val
);
2395 * Print privilege set operation.
2398 prt_pro(private_t
*pri
, int raw
, long val
)
2400 const char *s
= NULL
;
2403 switch ((priv_op_t
)val
) {
2404 case PRIV_ON
: s
= "PRIV_ON"; break;
2405 case PRIV_OFF
: s
= "PRIV_OFF"; break;
2406 case PRIV_SET
: s
= "PRIV_SET"; break;
2411 prt_dec(pri
, 0, val
);
2417 * Print privilege set name
2420 prt_prn(private_t
*pri
, int raw
, long val
)
2422 const char *s
= NULL
;
2425 s
= priv_getsetbynum((int)val
);
2428 prt_dec(pri
, 0, val
);
2430 char *dup
= strdup(s
);
2433 /* Do the best we can in this case */
2439 outstring(pri
, "PRIV_");
2443 while (*q
!= '\0') {
2447 outstring(pri
, dup
);
2453 * Print process flag names.
2456 prt_pfl(private_t
*pri
, int raw
, long val
)
2458 const char *s
= NULL
;
2462 case PRIV_DEBUG
: s
= "PRIV_DEBUG"; break;
2463 case PRIV_AWARE
: s
= "PRIV_AWARE"; break;
2464 case PRIV_XPOLICY
: s
= "PRIV_XPOLICY"; break;
2465 case PRIV_AWARE_RESET
: s
= "PRIV_AWARE_RESET"; break;
2466 case PRIV_PFEXEC
: s
= "PRIV_PFEXEC"; break;
2467 case NET_MAC_AWARE
: s
= "NET_MAC_AWARE"; break;
2468 case NET_MAC_AWARE_INHERIT
:
2469 s
= "NET_MAC_AWARE_INHERIT";
2475 prt_dec(pri
, 0, val
);
2481 * Print lgrp_affinity_{get,set}() arguments.
2485 prt_laf(private_t
*pri
, int raw
, long val
)
2487 lgrp_affinity_args_t laff
;
2489 if (Pread(Proc
, &laff
, sizeof (lgrp_affinity_args_t
), val
) !=
2490 sizeof (lgrp_affinity_args_t
)) {
2491 prt_hex(pri
, 0, val
);
2495 * arrange the arguments in the order that user calls with
2497 prt_dec(pri
, 0, laff
.idtype
);
2498 outstring(pri
, ", ");
2499 prt_dec(pri
, 0, laff
.id
);
2500 outstring(pri
, ", ");
2501 prt_dec(pri
, 0, laff
.lgrp
);
2502 outstring(pri
, ", ");
2503 if (pri
->sys_args
[0] == LGRP_SYS_AFFINITY_SET
)
2504 prt_dec(pri
, 0, laff
.aff
);
2508 * Print a key_t as IPC_PRIVATE if it is 0.
2511 prt_key(private_t
*pri
, int raw
, long val
)
2513 if (!raw
&& val
== 0)
2514 outstring(pri
, "IPC_PRIVATE");
2516 prt_dec(pri
, 0, val
);
2521 * Print zone_getattr() attribute types.
2524 prt_zga(private_t
*pri
, int raw
, long val
)
2526 const char *s
= NULL
;
2530 case ZONE_ATTR_NAME
: s
= "ZONE_ATTR_NAME"; break;
2531 case ZONE_ATTR_ROOT
: s
= "ZONE_ATTR_ROOT"; break;
2532 case ZONE_ATTR_STATUS
: s
= "ZONE_ATTR_STATUS"; break;
2533 case ZONE_ATTR_PRIVSET
: s
= "ZONE_ATTR_PRIVSET"; break;
2534 case ZONE_ATTR_UNIQID
: s
= "ZONE_ATTR_UNIQID"; break;
2535 case ZONE_ATTR_POOLID
: s
= "ZONE_ATTR_POOLID"; break;
2536 case ZONE_ATTR_INITPID
: s
= "ZONE_ATTR_INITPID"; break;
2537 case ZONE_ATTR_SLBL
: s
= "ZONE_ATTR_SLBL"; break;
2538 case ZONE_ATTR_INITNAME
: s
= "ZONE_ATTR_INITNAME"; break;
2539 case ZONE_ATTR_BOOTARGS
: s
= "ZONE_ATTR_BOOTARGS"; break;
2540 case ZONE_ATTR_BRAND
: s
= "ZONE_ATTR_BRAND"; break;
2541 case ZONE_ATTR_FLAGS
: s
= "ZONE_ATTR_FLAGS"; break;
2542 case ZONE_ATTR_PHYS_MCAP
: s
= "ZONE_ATTR_PHYS_MCAP"; break;
2547 prt_dec(pri
, 0, val
);
2553 * Print a file descriptor as AT_FDCWD if necessary
2556 prt_atc(private_t
*pri
, int raw
, long val
)
2558 if ((int)val
== AT_FDCWD
) {
2560 prt_hex(pri
, 0, (uint_t
)AT_FDCWD
);
2562 outstring(pri
, "AT_FDCWD");
2564 prt_dec(pri
, 0, val
);
2569 * Print Trusted Networking database operation codes (labelsys; tn*)
2572 prt_tnd(private_t
*pri
, int raw
, long val
)
2574 const char *s
= NULL
;
2577 switch ((tsol_dbops_t
)val
) {
2578 case TNDB_NOOP
: s
= "TNDB_NOOP"; break;
2579 case TNDB_LOAD
: s
= "TNDB_LOAD"; break;
2580 case TNDB_DELETE
: s
= "TNDB_DELETE"; break;
2581 case TNDB_FLUSH
: s
= "TNDB_FLUSH"; break;
2582 case TNDB_GET
: s
= "TNDB_GET"; break;
2587 prt_dec(pri
, 0, val
);
2593 * Print LIO_XX flags
2596 prt_lio(private_t
*pri
, int raw
, long val
)
2599 prt_dec(pri
, 0, val
);
2600 else if (val
== LIO_WAIT
)
2601 outstring(pri
, "LIO_WAIT");
2602 else if (val
== LIO_NOWAIT
)
2603 outstring(pri
, "LIO_NOWAIT");
2605 prt_dec(pri
, 0, val
);
2609 door_flags(private_t
*pri
, long val
)
2611 door_attr_t attr
= (door_attr_t
)val
;
2612 char *str
= pri
->code_buf
;
2615 #define PROCESS_FLAG(flg) \
2617 (void) strlcat(str, "|" #flg, sizeof (pri->code_buf)); \
2621 PROCESS_FLAG(DOOR_UNREF
);
2622 PROCESS_FLAG(DOOR_UNREF_MULTI
);
2623 PROCESS_FLAG(DOOR_PRIVATE
);
2624 PROCESS_FLAG(DOOR_REFUSE_DESC
);
2625 PROCESS_FLAG(DOOR_NO_CANCEL
);
2626 PROCESS_FLAG(DOOR_LOCAL
);
2627 PROCESS_FLAG(DOOR_REVOKED
);
2628 PROCESS_FLAG(DOOR_IS_UNREF
);
2631 if (attr
!= 0 || *str
== '\0') {
2632 size_t len
= strlen(str
);
2633 (void) snprintf(str
+ len
, sizeof (pri
->code_buf
) - len
,
2641 * Print door_create() flags
2644 prt_dfl(private_t
*pri
, int raw
, long val
)
2647 prt_hex(pri
, 0, val
);
2649 outstring(pri
, door_flags(pri
, val
));
2653 * Print door_*param() param argument
2656 prt_dpm(private_t
*pri
, int raw
, long val
)
2659 prt_hex(pri
, 0, val
);
2660 else if (val
== DOOR_PARAM_DESC_MAX
)
2661 outstring(pri
, "DOOR_PARAM_DESC_MAX");
2662 else if (val
== DOOR_PARAM_DATA_MIN
)
2663 outstring(pri
, "DOOR_PARAM_DATA_MIN");
2664 else if (val
== DOOR_PARAM_DATA_MAX
)
2665 outstring(pri
, "DOOR_PARAM_DATA_MAX");
2667 prt_hex(pri
, 0, val
);
2671 * Print rctlsys subcodes
2674 prt_rsc(private_t
*pri
, int raw
, long val
) /* print utssys code */
2676 const char *s
= raw
? NULL
: rctlsyscode(val
);
2679 prt_dec(pri
, 0, val
);
2685 * Print getrctl flags
2688 prt_rgf(private_t
*pri
, int raw
, long val
)
2690 long action
= val
& (~RCTLSYS_ACTION_MASK
);
2693 prt_hex(pri
, 0, val
);
2694 else if (action
== RCTL_FIRST
)
2695 outstring(pri
, "RCTL_FIRST");
2696 else if (action
== RCTL_NEXT
)
2697 outstring(pri
, "RCTL_NEXT");
2698 else if (action
== RCTL_USAGE
)
2699 outstring(pri
, "RCTL_USAGE");
2701 prt_hex(pri
, 0, val
);
2705 * Print setrctl flags
2708 prt_rsf(private_t
*pri
, int raw
, long val
)
2710 long action
= val
& (~RCTLSYS_ACTION_MASK
);
2711 long pval
= val
& RCTL_LOCAL_ACTION_MASK
;
2712 char *s
= pri
->code_buf
;
2715 prt_hex(pri
, 0, val
);
2717 } else if (action
== RCTL_INSERT
)
2718 (void) strcpy(s
, "RCTL_INSERT");
2719 else if (action
== RCTL_DELETE
)
2720 (void) strcpy(s
, "RCTL_DELETE");
2721 else if (action
== RCTL_REPLACE
)
2722 (void) strcpy(s
, "RCTL_REPLACE");
2724 prt_hex(pri
, 0, val
);
2728 if (pval
& RCTL_USE_RECIPIENT_PID
) {
2729 pval
^= RCTL_USE_RECIPIENT_PID
;
2730 (void) strlcat(s
, "|RCTL_USE_RECIPIENT_PID",
2731 sizeof (pri
->code_buf
));
2734 if ((pval
& RCTLSYS_ACTION_MASK
) != 0)
2735 prt_hex(pri
, 0, val
);
2736 else if (*s
!= '\0')
2739 prt_hex(pri
, 0, val
);
2743 * Print rctlctl flags
2746 prt_rcf(private_t
*pri
, int raw
, long val
)
2748 long action
= val
& (~RCTLSYS_ACTION_MASK
);
2751 prt_hex(pri
, 0, val
);
2752 else if (action
== RCTLCTL_GET
)
2753 outstring(pri
, "RCTLCTL_GET");
2754 else if (action
== RCTLCTL_SET
)
2755 outstring(pri
, "RCTLCTL_SET");
2757 prt_hex(pri
, 0, val
);
2761 * Print setprojrctl flags
2764 prt_spf(private_t
*pri
, int raw
, long val
)
2766 long action
= val
& TASK_PROJ_MASK
;
2768 if (!raw
&& (action
== TASK_PROJ_PURGE
))
2769 outstring(pri
, "TASK_PROJ_PURGE");
2771 prt_hex(pri
, 0, val
);
2775 * Print forkx() flags
2778 prt_fxf(private_t
*pri
, int raw
, long val
)
2783 outstring(pri
, "0");
2784 else if (raw
|| (val
& ~(FORK_NOSIGCHLD
| FORK_WAITPID
)))
2785 prt_hhx(pri
, 0, val
);
2787 str
= pri
->code_buf
;
2789 if (val
& FORK_NOSIGCHLD
)
2790 (void) strlcat(str
, "|FORK_NOSIGCHLD",
2791 sizeof (pri
->code_buf
));
2792 if (val
& FORK_WAITPID
)
2793 (void) strlcat(str
, "|FORK_WAITPID",
2794 sizeof (pri
->code_buf
));
2795 outstring(pri
, str
+ 1);
2800 * Print faccessat() flag
2803 prt_fat(private_t
*pri
, int raw
, long val
)
2806 outstring(pri
, "0");
2807 else if (!raw
&& val
== AT_EACCESS
)
2808 outstring(pri
, "AT_EACCESS");
2810 prt_hex(pri
, 0, val
);
2814 * Print unlinkat() flag
2817 prt_uat(private_t
*pri
, int raw
, long val
)
2820 outstring(pri
, "0");
2821 else if (!raw
&& val
== AT_REMOVEDIR
)
2822 outstring(pri
, "AT_REMOVEDIR");
2824 prt_hex(pri
, 0, val
);
2828 * Print AT_SYMLINK_NOFOLLOW / AT_SYMLINK_FOLLOW flag
2831 prt_snf(private_t
*pri
, int raw
, long val
)
2834 outstring(pri
, "0");
2835 else if (!raw
&& val
== AT_SYMLINK_NOFOLLOW
)
2836 outstring(pri
, "AT_SYMLINK_NOFOLLOW");
2837 else if (!raw
&& val
== AT_SYMLINK_FOLLOW
)
2838 outstring(pri
, "AT_SYMLINK_FOLLOW");
2840 prt_hex(pri
, 0, val
);
2844 prt_grf(private_t
*pri
, int raw
, long val
)
2848 if (raw
!= 0 || val
== 0 ||
2849 (val
& ~(GRND_NONBLOCK
| GRND_RANDOM
)) != 0) {
2850 outstring(pri
, "0");
2854 if (val
& GRND_NONBLOCK
) {
2855 outstring(pri
, "|GRND_NONBLOCK" + first
);
2858 if (val
& GRND_RANDOM
) {
2859 outstring(pri
, "|GRND_RANDOM" + first
);
2865 * Array of pointers to print functions, one for each format.
2867 void (* const Print
[])() = {
2868 prt_nov
, /* NOV -- no value */
2869 prt_dec
, /* DEC -- print value in decimal */
2870 prt_oct
, /* OCT -- print value in octal */
2871 prt_hex
, /* HEX -- print value in hexadecimal */
2872 prt_dex
, /* DEX -- print value in hexadecimal if big enough */
2873 prt_stg
, /* STG -- print value as string */
2874 prt_ioc
, /* IOC -- print ioctl code */
2875 prt_fcn
, /* FCN -- print fcntl code */
2876 prt_s86
, /* S86 -- print sysi86 code */
2877 prt_uts
, /* UTS -- print utssys code */
2878 prt_opn
, /* OPN -- print open code */
2879 prt_sig
, /* SIG -- print signal name plus flags */
2880 prt_uat
, /* UAT -- print unlinkat() flag */
2881 prt_msc
, /* MSC -- print msgsys command */
2882 prt_msf
, /* MSF -- print msgsys flags */
2883 prt_smc
, /* SMC -- print semsys command */
2884 prt_sef
, /* SEF -- print semsys flags */
2885 prt_shc
, /* SHC -- print shmsys command */
2886 prt_shf
, /* SHF -- print shmsys flags */
2887 prt_fat
, /* FAT -- print faccessat( flag */
2888 prt_sfs
, /* SFS -- print sysfs code */
2889 prt_rst
, /* RST -- print string returned by syscall */
2890 prt_smf
, /* SMF -- print streams message flags */
2891 prt_ioa
, /* IOA -- print ioctl argument */
2892 prt_pip
, /* PIP -- print pipe flags */
2893 prt_mtf
, /* MTF -- print mount flags */
2894 prt_mft
, /* MFT -- print mount file system type */
2895 prt_iob
, /* IOB -- print contents of I/O buffer */
2896 prt_hhx
, /* HHX -- print value in hexadecimal (half size) */
2897 prt_wop
, /* WOP -- print waitsys() options */
2898 prt_spm
, /* SPM -- print sigprocmask argument */
2899 prt_rlk
, /* RLK -- print readlink buffer */
2900 prt_mpr
, /* MPR -- print mmap()/mprotect() flags */
2901 prt_mty
, /* MTY -- print mmap() mapping type flags */
2902 prt_mcf
, /* MCF -- print memcntl() function */
2903 prt_mc4
, /* MC4 -- print memcntl() (fourth) argument */
2904 prt_mc5
, /* MC5 -- print memcntl() (fifth) argument */
2905 prt_mad
, /* MAD -- print madvise() argument */
2906 prt_ulm
, /* ULM -- print ulimit() argument */
2907 prt_rlm
, /* RLM -- print get/setrlimit() argument */
2908 prt_cnf
, /* CNF -- print sysconfig() argument */
2909 prt_inf
, /* INF -- print sysinfo() argument */
2910 prt_ptc
, /* PTC -- print pathconf/fpathconf() argument */
2911 prt_fui
, /* FUI -- print fusers() input argument */
2912 prt_idt
, /* IDT -- print idtype_t, waitid() argument */
2913 prt_lwf
, /* LWF -- print lwp_create() flags */
2914 prt_itm
, /* ITM -- print [get|set]itimer() arg */
2915 prt_llo
, /* LLO -- print long long offset arg */
2916 prt_mod
, /* MOD -- print modctl() subcode */
2917 prt_whn
, /* WHN -- print lseek() whence arguiment */
2918 prt_acl
, /* ACL -- print acl() code */
2919 prt_aio
, /* AIO -- print kaio() code */
2920 prt_aud
, /* AUD -- print auditsys() code */
2921 prt_uns
, /* DEC -- print value in unsigned decimal */
2922 prt_clc
, /* CLC -- print cladm command argument */
2923 prt_clf
, /* CLF -- print cladm flag argument */
2924 prt_cor
, /* COR -- print corectl() subcode */
2925 prt_cco
, /* CCO -- print corectl() options */
2926 prt_ccc
, /* CCC -- print corectl() content */
2927 prt_rcc
, /* RCC -- print corectl() returned content */
2928 prt_cpc
, /* CPC -- print cpc() subcode */
2929 prt_sqc
, /* SQC -- print sigqueue() si_code argument */
2930 prt_pc4
, /* PC4 -- print priocntlsys() (fourth) argument */
2931 prt_pc5
, /* PC5 -- print priocntlsys() (key, value) pairs */
2932 prt_pst
, /* PST -- print processor set id */
2933 prt_mif
, /* MIF -- print meminfo() arguments */
2934 prt_pfm
, /* PFM -- print so_socket() proto-family (1st) arg */
2935 prt_skt
, /* SKT -- print so_socket() socket-type (2nd) arg */
2936 prt_skp
, /* SKP -- print so_socket() protocol (3rd) arg */
2937 prt_skv
, /* SKV -- print socket version arg */
2938 prt_sol
, /* SOL -- print [sg]etsockopt() level (2nd) arg */
2939 prt_son
, /* SON -- print [sg]etsockopt() opt-name (3rd) arg */
2940 prt_utt
, /* UTT -- print utrap type */
2941 prt_uth
, /* UTH -- print utrap handler */
2942 prt_acc
, /* ACC -- print access() flags */
2943 prt_sht
, /* SHT -- print shutdown() how (2nd) argument */
2944 prt_ffg
, /* FFG -- print fcntl() flags (3rd) argument */
2945 prt_prs
, /* PRS -- print privilege set */
2946 prt_pro
, /* PRO -- print privilege set operation */
2947 prt_prn
, /* PRN -- print privilege set name */
2948 prt_pfl
, /* PFL -- print privilege/process flag name */
2949 prt_laf
, /* LAF -- print lgrp_affinity arguments */
2950 prt_key
, /* KEY -- print key_t 0 as IPC_PRIVATE */
2951 prt_zga
, /* ZGA -- print zone_getattr attribute types */
2952 prt_atc
, /* ATC -- print AT_FDCWD or file descriptor */
2953 prt_lio
, /* LIO -- print LIO_XX flags */
2954 prt_dfl
, /* DFL -- print door_create() flags */
2955 prt_dpm
, /* DPM -- print DOOR_PARAM_XX flags */
2956 prt_tnd
, /* TND -- print trusted network data base opcode */
2957 prt_rsc
, /* RSC -- print rctlsys() subcodes */
2958 prt_rgf
, /* RGF -- print getrctl() flags */
2959 prt_rsf
, /* RSF -- print setrctl() flags */
2960 prt_rcf
, /* RCF -- print rctlsys_ctl() flags */
2961 prt_fxf
, /* FXF -- print forkx() flags */
2962 prt_spf
, /* SPF -- print rctlsys_projset() flags */
2963 prt_un1
, /* UN1 -- as prt_uns except for -1 */
2964 prt_mob
, /* MOB -- print mmapobj() flags */
2965 prt_snf
, /* SNF -- print AT_SYMLINK_[NO]FOLLOW flag */
2966 prt_skc
, /* SKC -- print sockconfig() subcode */
2967 prt_acf
, /* ACF -- print accept4 flags */
2968 prt_pfd
, /* PFD -- print pipe fds */
2969 prt_grf
, /* GRF -- print getrandom flags */
2970 prt_psdelta
, /* PSDLT -- print psecflags(2) delta */
2971 prt_psfw
, /* PSFW -- print psecflags(2) set */
2972 prt_dec
, /* HID -- hidden argument, make this the last one */