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 2012 Nexenta Systems, Inc. All rights reserved.
24 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
25 * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
26 * Copyright 2015 Joyent, Inc.
29 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
30 /* All Rights Reserved */
38 #include <sys/types.h>
43 #include <sys/statfs.h>
44 #include <sys/times.h>
45 #include <sys/timex.h>
46 #include <sys/utssys.h>
47 #include <sys/utsname.h>
49 #include <sys/ipc_impl.h>
51 #include <sys/msg_impl.h>
53 #include <sys/sem_impl.h>
55 #include <sys/shm_impl.h>
56 #include <sys/dirent.h>
60 #include <sys/termios.h>
61 #include <sys/termiox.h>
62 #include <sys/termio.h>
63 #include <sys/ttold.h>
64 #include <sys/jioctl.h>
65 #include <sys/filio.h>
69 #include <sys/resource.h>
70 #include <sys/statvfs.h>
73 #include <sys/socket.h>
74 #include <netinet/in.h>
76 #include <sys/byteorder.h>
77 #include <arpa/inet.h>
78 #include <sys/audioio.h>
79 #include <sys/synch.h>
80 #include <sys/synch32.h>
81 #include <sys/sysmacros.h>
82 #include <sys/sendfile.h>
85 #include <sys/ucred.h>
86 #include <sys/port_impl.h>
88 #include <sys/priv_impl.h>
90 #include <sys/nvpair.h>
91 #include <libnvpair.h>
92 #include <sys/rctl_impl.h>
93 #include <sys/socketvar.h>
94 #include <sys/fs/zfs.h>
95 #include <sys/zfs_ioctl.h>
101 void show_sigset(private_t
*, long, const char *);
102 void show_ioctl(private_t
*, int, long);
103 void show_zfs_ioc(private_t
*, long);
106 mk_ctime(char *str
, size_t maxsize
, time_t value
)
108 (void) strftime(str
, maxsize
, "%b %e %H:%M:%S %Z %Y",
113 prtime(private_t
*pri
, const char *name
, time_t value
)
117 mk_ctime(str
, sizeof (str
), value
);
118 (void) printf("%s\t%s%s [ %lu ]\n",
126 prtimeval(private_t
*pri
, const char *name
, struct timeval
*value
)
130 mk_ctime(str
, sizeof (str
), value
->tv_sec
);
131 (void) printf("%s\t%s%s [ %lu.%6.6lu ]\n",
140 prtimestruc(private_t
*pri
, const char *name
, timestruc_t
*value
)
144 mk_ctime(str
, sizeof (str
), value
->tv_sec
);
145 (void) printf("%s\t%s%s [ %lu.%9.9lu ]\n",
154 show_utimens(private_t
*pri
, long offset
)
164 if (data_model
== PR_MODEL_NATIVE
) {
165 if (Pread(Proc
, &utimbuf
, sizeof (utimbuf
), offset
)
174 if (Pread(Proc
, &utimbuf32
, sizeof (utimbuf32
), offset
)
175 != sizeof (utimbuf32
))
178 TIMESPEC32_TO_TIMESPEC(&utimbuf
.atime
, &utimbuf32
.atime
);
179 TIMESPEC32_TO_TIMESPEC(&utimbuf
.mtime
, &utimbuf32
.mtime
);
182 /* print access and modification times */
183 if (utimbuf
.atime
.tv_nsec
== UTIME_OMIT
)
184 (void) printf("%s\tat = UTIME_OMIT\n", pri
->pname
);
185 else if (utimbuf
.atime
.tv_nsec
== UTIME_NOW
)
186 (void) printf("%s\tat = UTIME_NOW\n", pri
->pname
);
188 prtimestruc(pri
, "at = ", &utimbuf
.atime
);
189 if (utimbuf
.mtime
.tv_nsec
== UTIME_OMIT
)
190 (void) printf("%s\tmt = UTIME_OMIT\n", pri
->pname
);
191 else if (utimbuf
.mtime
.tv_nsec
== UTIME_NOW
)
192 (void) printf("%s\tmt = UTIME_NOW\n", pri
->pname
);
194 prtimestruc(pri
, "mt = ", &utimbuf
.mtime
);
198 show_timeofday(private_t
*pri
)
203 if (pri
->sys_nargs
< 1 || (offset
= pri
->sys_args
[0]) == 0)
206 if (data_model
== PR_MODEL_NATIVE
) {
207 if (Pread(Proc
, &tod
, sizeof (tod
), offset
)
211 struct timeval32 tod32
;
213 if (Pread(Proc
, &tod32
, sizeof (tod32
), offset
)
217 TIMEVAL32_TO_TIMEVAL(&tod
, &tod32
);
220 prtimeval(pri
, "time: ", &tod
);
224 show_itimerval(private_t
*pri
, long offset
, const char *name
)
226 struct itimerval itimerval
;
231 if (data_model
== PR_MODEL_NATIVE
) {
232 if (Pread(Proc
, &itimerval
, sizeof (itimerval
), offset
)
233 != sizeof (itimerval
))
236 struct itimerval32 itimerval32
;
238 if (Pread(Proc
, &itimerval32
, sizeof (itimerval32
), offset
)
239 != sizeof (itimerval32
))
242 ITIMERVAL32_TO_ITIMERVAL(&itimerval
, &itimerval32
);
246 "%s\t%s: interval: %4ld.%6.6ld sec value: %4ld.%6.6ld sec\n",
249 itimerval
.it_interval
.tv_sec
,
250 itimerval
.it_interval
.tv_usec
,
251 itimerval
.it_value
.tv_sec
,
252 itimerval
.it_value
.tv_usec
);
256 show_timeval(private_t
*pri
, long offset
, const char *name
)
258 struct timeval timeval
;
263 if (data_model
== PR_MODEL_NATIVE
) {
264 if (Pread(Proc
, &timeval
, sizeof (timeval
), offset
)
268 struct timeval32 timeval32
;
270 if (Pread(Proc
, &timeval32
, sizeof (timeval32
), offset
)
271 != sizeof (timeval32
))
274 TIMEVAL32_TO_TIMEVAL(&timeval
, &timeval32
);
278 "%s\t%s: %ld.%6.6ld sec\n",
286 show_timestruc(private_t
*pri
, long offset
, const char *name
)
288 timestruc_t timestruc
;
293 if (data_model
== PR_MODEL_NATIVE
) {
294 if (Pread(Proc
, ×truc
, sizeof (timestruc
), offset
)
295 != sizeof (timestruc
))
298 timestruc32_t timestruc32
;
300 if (Pread(Proc
, ×truc32
, sizeof (timestruc32
), offset
)
301 != sizeof (timestruc32
))
304 TIMESPEC32_TO_TIMESPEC(×truc
, ×truc32
);
308 "%s\t%s: %ld.%9.9ld sec\n",
316 show_stime(private_t
*pri
)
318 if (pri
->sys_nargs
>= 1) {
319 /* print new system time */
320 prtime(pri
, "systime = ", (time_t)pri
->sys_args
[0]);
325 show_times(private_t
*pri
)
327 long hz
= sysconf(_SC_CLK_TCK
);
331 if (pri
->sys_nargs
< 1 || (offset
= pri
->sys_args
[0]) == 0)
334 if (data_model
== PR_MODEL_NATIVE
) {
335 if (Pread(Proc
, &tms
, sizeof (tms
), offset
)
341 if (Pread(Proc
, &tms32
, sizeof (tms32
), offset
)
346 * This looks a bit odd (since the values are actually
347 * signed), but we need to suppress sign extension to
348 * preserve compatibility (we've always printed these
349 * numbers as unsigned quantities).
351 tms
.tms_utime
= (unsigned)tms32
.tms_utime
;
352 tms
.tms_stime
= (unsigned)tms32
.tms_stime
;
353 tms
.tms_cutime
= (unsigned)tms32
.tms_cutime
;
354 tms
.tms_cstime
= (unsigned)tms32
.tms_cstime
;
358 "%s\tutim=%-6lu stim=%-6lu cutim=%-6lu cstim=%-6lu (HZ=%ld)\n",
367 /* XX64 -- definition of 'struct ustat' is strange -- check out the defn */
369 show_ustat(private_t
*pri
, long offset
)
374 Pread(Proc
, &ubuf
, sizeof (ubuf
), offset
) == sizeof (ubuf
)) {
376 "%s\ttfree=%-6ld tinode=%-5lu fname=%-6.6s fpack=%-.6s\n",
387 show_ustat32(private_t
*pri
, long offset
)
392 Pread(Proc
, &ubuf
, sizeof (ubuf
), offset
) == sizeof (ubuf
)) {
394 "%s\ttfree=%-6d tinode=%-5u fname=%-6.6s fpack=%-.6s\n",
405 show_fusers(private_t
*pri
, long offset
, long nproc
)
408 int serial
= (nproc
> 4);
413 /* enter region of lengthy output */
418 Pread(Proc
, &fubuf
, sizeof (fubuf
), offset
) == sizeof (fubuf
)) {
419 (void) printf("%s\tpid=%-5d uid=%-5u flags=%s\n",
423 fuflags(pri
, fubuf
.fu_flags
));
425 offset
+= sizeof (fubuf
);
428 /* exit region of lengthy output */
434 show_utssys(private_t
*pri
, long r0
)
436 if (pri
->sys_nargs
>= 3) {
437 switch (pri
->sys_args
[2]) {
439 show_ustat(pri
, (long)pri
->sys_args
[0]);
442 show_fusers(pri
, (long)pri
->sys_args
[3], r0
);
450 show_utssys32(private_t
*pri
, long r0
)
452 if (pri
->sys_nargs
>= 3) {
453 switch (pri
->sys_args
[2]) {
455 show_ustat32(pri
, (long)pri
->sys_args
[0]);
458 show_fusers(pri
, (long)pri
->sys_args
[3], r0
);
465 #define ALL_LOCK_TYPES \
466 (USYNC_PROCESS | LOCK_ERRORCHECK | LOCK_RECURSIVE | \
467 LOCK_PRIO_INHERIT | LOCK_PRIO_PROTECT | LOCK_ROBUST | \
468 USYNC_PROCESS_ROBUST)
470 /* return cv and mutex types */
472 synch_type(private_t
*pri
, uint_t type
)
474 char *str
= pri
->code_buf
;
476 if (type
& USYNC_PROCESS
)
477 (void) strcpy(str
, "USYNC_PROCESS");
479 (void) strcpy(str
, "USYNC_THREAD");
481 if (type
& LOCK_ERRORCHECK
)
482 (void) strcat(str
, "|LOCK_ERRORCHECK");
483 if (type
& LOCK_RECURSIVE
)
484 (void) strcat(str
, "|LOCK_RECURSIVE");
485 if (type
& LOCK_PRIO_INHERIT
)
486 (void) strcat(str
, "|LOCK_PRIO_INHERIT");
487 if (type
& LOCK_PRIO_PROTECT
)
488 (void) strcat(str
, "|LOCK_PRIO_PROTECT");
489 if (type
& LOCK_ROBUST
)
490 (void) strcat(str
, "|LOCK_ROBUST");
491 if (type
& USYNC_PROCESS_ROBUST
)
492 (void) strcat(str
, "|USYNC_PROCESS_ROBUST");
494 if ((type
&= ~ALL_LOCK_TYPES
) != 0)
495 (void) sprintf(str
+ strlen(str
), "|0x%.4X", type
);
497 return ((const char *)str
);
501 show_mutex(private_t
*pri
, long offset
)
505 if (Pread(Proc
, &mutex
, sizeof (mutex
), offset
) == sizeof (mutex
)) {
506 (void) printf("%s\tmutex type: %s\n",
508 synch_type(pri
, mutex
.mutex_type
));
513 show_condvar(private_t
*pri
, long offset
)
517 if (Pread(Proc
, &condvar
, sizeof (condvar
), offset
)
518 == sizeof (condvar
)) {
519 (void) printf("%s\tcondvar type: %s\n",
521 synch_type(pri
, condvar
.cond_type
));
526 show_sema(private_t
*pri
, long offset
)
530 if (Pread(Proc
, &sema
, sizeof (sema
), offset
) == sizeof (sema
)) {
531 (void) printf("%s\tsema type: %s count = %u\n",
533 synch_type(pri
, sema
.sema_type
),
539 show_rwlock(private_t
*pri
, long offset
)
543 if (Pread(Proc
, &rwlock
, sizeof (rwlock
), offset
) == sizeof (rwlock
)) {
544 (void) printf("%s\trwlock type: %s readers = %d\n",
546 synch_type(pri
, rwlock
.rwlock_type
),
547 rwlock
.rwlock_readers
);
551 /* represent character as itself ('c') or octal (012) */
553 show_char(char *buf
, int c
)
557 if (c
>= ' ' && c
< 0177)
562 (void) sprintf(buf
, fmt
, c
&0xff);
567 show_termio(private_t
*pri
, long offset
)
569 struct termio termio
;
573 if (Pread(Proc
, &termio
, sizeof (termio
), offset
) == sizeof (termio
)) {
575 "%s\tiflag=0%.6o oflag=0%.6o cflag=0%.6o lflag=0%.6o line=%d\n",
582 (void) printf("%s\t cc: ", pri
->pname
);
583 for (i
= 0; i
< NCC
; i
++)
585 show_char(cbuf
, (int)termio
.c_cc
[i
]));
586 (void) fputc('\n', stdout
);
591 show_termios(private_t
*pri
, long offset
)
593 struct termios termios
;
597 if (Pread(Proc
, &termios
, sizeof (termios
), offset
)
598 == sizeof (termios
)) {
600 "%s\tiflag=0%.6o oflag=0%.6o cflag=0%.6o lflag=0%.6o\n",
606 (void) printf("%s\t cc: ", pri
->pname
);
607 for (i
= 0; i
< NCCS
; i
++) {
608 if (i
== NCC
) /* show new chars on new line */
609 (void) printf("\n%s\t\t", pri
->pname
);
611 show_char(cbuf
, (int)termios
.c_cc
[i
]));
613 (void) fputc('\n', stdout
);
618 show_termiox(private_t
*pri
, long offset
)
620 struct termiox termiox
;
623 if (Pread(Proc
, &termiox
, sizeof (termiox
), offset
)
624 == sizeof (termiox
)) {
625 (void) printf("%s\thflag=0%.3o cflag=0%.3o rflag=0%.3o",
630 for (i
= 1; i
< NFF
; i
++)
631 (void) printf(",0%.3o", termiox
.x_rflag
[i
]);
632 (void) printf(" sflag=0%.3o\n",
638 show_sgttyb(private_t
*pri
, long offset
)
640 struct sgttyb sgttyb
;
642 if (Pread(Proc
, &sgttyb
, sizeof (sgttyb
), offset
) == sizeof (sgttyb
)) {
647 "%s\tispeed=%-2d ospeed=%-2d erase=%s kill=%s flags=0x%.8x\n",
649 sgttyb
.sg_ispeed
&0xff,
650 sgttyb
.sg_ospeed
&0xff,
651 show_char(erase
, sgttyb
.sg_erase
),
652 show_char(kill
, sgttyb
.sg_kill
),
658 show_ltchars(private_t
*pri
, long offset
)
660 struct ltchars ltchars
;
665 if (Pread(Proc
, <chars
, sizeof (ltchars
), offset
)
666 == sizeof (ltchars
)) {
667 (void) printf("%s\t cc: ", pri
->pname
);
668 for (p
= (char *)<chars
, i
= 0; i
< sizeof (ltchars
); i
++)
669 (void) printf(" %s", show_char(cbuf
, (int)*p
++));
670 (void) fputc('\n', stdout
);
675 show_tchars(private_t
*pri
, long offset
)
677 struct tchars tchars
;
682 if (Pread(Proc
, &tchars
, sizeof (tchars
), offset
) == sizeof (tchars
)) {
683 (void) printf("%s\t cc: ", pri
->pname
);
684 for (p
= (char *)&tchars
, i
= 0; i
< sizeof (tchars
); i
++)
685 (void) printf(" %s", show_char(cbuf
, (int)*p
++));
686 (void) fputc('\n', stdout
);
691 show_termcb(private_t
*pri
, long offset
)
693 struct termcb termcb
;
695 if (Pread(Proc
, &termcb
, sizeof (termcb
), offset
) == sizeof (termcb
)) {
697 "%s\tflgs=0%.2o termt=%d crow=%d ccol=%d vrow=%d lrow=%d\n",
700 termcb
.st_termt
&0xff,
702 termcb
.st_lrow
&0xff);
706 /* integer value pointed to by ioctl() arg */
708 show_strint(private_t
*pri
, int code
, long offset
)
712 if (Pread(Proc
, &val
, sizeof (val
), offset
) == sizeof (val
)) {
713 const char *s
= NULL
;
715 switch (code
) { /* interpret these symbolically */
720 s
= strevents(pri
, val
);
723 s
= tiocflush(pri
, val
);
728 (void) printf("%s\t0x%.8lX: %d\n",
729 pri
->pname
, offset
, val
);
731 (void) printf("%s\t0x%.8lX: %s\n",
732 pri
->pname
, offset
, s
);
737 show_strioctl(private_t
*pri
, long offset
)
739 struct strioctl strioctl
;
741 if (Pread(Proc
, &strioctl
, sizeof (strioctl
), offset
) ==
744 "%s\tcmd=%s timout=%d len=%d dp=0x%.8lX\n",
746 ioctlname(pri
, strioctl
.ic_cmd
),
749 (long)strioctl
.ic_dp
);
751 if (pri
->recur
++ == 0) /* avoid indefinite recursion */
752 show_ioctl(pri
, strioctl
.ic_cmd
,
753 (long)strioctl
.ic_dp
);
760 show_strioctl32(private_t
*pri
, long offset
)
762 struct strioctl32 strioctl
;
764 if (Pread(Proc
, &strioctl
, sizeof (strioctl
), offset
) ==
767 "%s\tcmd=%s timout=%d len=%d dp=0x%.8lX\n",
769 ioctlname(pri
, strioctl
.ic_cmd
),
772 (long)strioctl
.ic_dp
);
774 if (pri
->recur
++ == 0) /* avoid indefinite recursion */
775 show_ioctl(pri
, strioctl
.ic_cmd
,
776 (long)strioctl
.ic_dp
);
783 print_strbuf(private_t
*pri
, struct strbuf
*sp
, const char *name
, int dump
)
786 "%s\t%s: maxlen=%-4d len=%-4d buf=0x%.8lX",
793 * Should we show the buffer contents?
794 * Keyed to the '-r fds' and '-w fds' options?
796 if (sp
->buf
== NULL
|| sp
->len
<= 0)
797 (void) fputc('\n', stdout
);
799 int nb
= (sp
->len
> 8)? 8 : sp
->len
;
803 if (Pread(Proc
, buffer
, (size_t)nb
, (long)sp
->buf
) == nb
) {
804 (void) strcpy(obuf
, ": \"");
805 showbytes(buffer
, nb
, obuf
+3);
808 (const char *)"\"" : (const char *)"\"..");
809 (void) fputs(obuf
, stdout
);
811 (void) fputc('\n', stdout
);
812 if (dump
&& sp
->len
> 8)
813 showbuffer(pri
, (long)sp
->buf
, (long)sp
->len
);
819 print_strbuf32(private_t
*pri
, struct strbuf32
*sp
, const char *name
, int dump
)
822 "%s\t%s: maxlen=%-4d len=%-4d buf=0x%.8lX",
829 * Should we show the buffer contents?
830 * Keyed to the '-r fds' and '-w fds' options?
832 if (sp
->buf
== (uintptr_t)NULL
|| sp
->len
<= 0)
833 (void) fputc('\n', stdout
);
835 int nb
= (sp
->len
> 8)? 8 : sp
->len
;
839 if (Pread(Proc
, buffer
, (size_t)nb
, (long)sp
->buf
) == nb
) {
840 (void) strcpy(obuf
, ": \"");
841 showbytes(buffer
, nb
, obuf
+3);
844 (const char *)"\"" : (const char *)"\"..");
845 (void) fputs(obuf
, stdout
);
847 (void) fputc('\n', stdout
);
848 if (dump
&& sp
->len
> 8)
849 showbuffer(pri
, (long)sp
->buf
, (long)sp
->len
);
854 /* strpeek and strfdinsert flags word */
856 strflags(private_t
*pri
, int flags
)
868 (void) sprintf(pri
->code_buf
, "0x%.4X", flags
);
876 show_strpeek(private_t
*pri
, long offset
)
878 struct strpeek strpeek
;
880 if (Pread(Proc
, &strpeek
, sizeof (strpeek
), offset
)
881 == sizeof (strpeek
)) {
883 print_strbuf(pri
, &strpeek
.ctlbuf
, "ctl", FALSE
);
884 print_strbuf(pri
, &strpeek
.databuf
, "dat", FALSE
);
886 (void) printf("%s\tflags=%s\n",
888 strflags(pri
, strpeek
.flags
));
894 show_strpeek32(private_t
*pri
, long offset
)
896 struct strpeek32 strpeek
;
898 if (Pread(Proc
, &strpeek
, sizeof (strpeek
), offset
)
899 == sizeof (strpeek
)) {
901 print_strbuf32(pri
, &strpeek
.ctlbuf
, "ctl", FALSE
);
902 print_strbuf32(pri
, &strpeek
.databuf
, "dat", FALSE
);
904 (void) printf("%s\tflags=%s\n",
906 strflags(pri
, strpeek
.flags
));
912 show_strfdinsert(private_t
*pri
, long offset
)
914 struct strfdinsert strfdinsert
;
916 if (Pread(Proc
, &strfdinsert
, sizeof (strfdinsert
), offset
) ==
917 sizeof (strfdinsert
)) {
919 print_strbuf(pri
, &strfdinsert
.ctlbuf
, "ctl", FALSE
);
920 print_strbuf(pri
, &strfdinsert
.databuf
, "dat", FALSE
);
922 (void) printf("%s\tflags=%s fildes=%d offset=%d\n",
924 strflags(pri
, strfdinsert
.flags
),
932 show_strfdinsert32(private_t
*pri
, long offset
)
934 struct strfdinsert32 strfdinsert
;
936 if (Pread(Proc
, &strfdinsert
, sizeof (strfdinsert
), offset
) ==
937 sizeof (strfdinsert
)) {
939 print_strbuf32(pri
, &strfdinsert
.ctlbuf
, "ctl", FALSE
);
940 print_strbuf32(pri
, &strfdinsert
.databuf
, "dat", FALSE
);
942 (void) printf("%s\tflags=%s fildes=%d offset=%d\n",
944 strflags(pri
, strfdinsert
.flags
),
952 show_strrecvfd(private_t
*pri
, long offset
)
954 struct strrecvfd strrecvfd
;
956 if (Pread(Proc
, &strrecvfd
, sizeof (strrecvfd
), offset
) ==
957 sizeof (strrecvfd
)) {
959 "%s\tfd=%-5d uid=%-5u gid=%u\n",
968 show_strlist(private_t
*pri
, long offset
)
970 struct str_list strlist
;
971 struct str_mlist list
;
974 if (Pread(Proc
, &strlist
, sizeof (strlist
), offset
) ==
976 (void) printf("%s\tnmods=%d modlist=0x%.8lX\n",
979 (long)strlist
.sl_modlist
);
981 count
= strlist
.sl_nmods
;
982 offset
= (long)strlist
.sl_modlist
;
983 while (!interrupt
&& --count
>= 0) {
984 if (Pread(Proc
, &list
, sizeof (list
), offset
) !=
987 (void) printf("%s\t\t\"%.*s\"\n",
989 (int)sizeof (list
.l_name
),
991 offset
+= sizeof (struct str_mlist
);
998 show_strlist32(private_t
*pri
, long offset
)
1000 struct str_list32 strlist
;
1001 struct str_mlist list
;
1004 if (Pread(Proc
, &strlist
, sizeof (strlist
), offset
) ==
1006 (void) printf("%s\tnmods=%d modlist=0x%.8lX\n",
1009 (long)strlist
.sl_modlist
);
1011 count
= strlist
.sl_nmods
;
1012 offset
= (long)strlist
.sl_modlist
;
1013 while (!interrupt
&& --count
>= 0) {
1014 if (Pread(Proc
, &list
, sizeof (list
), offset
) !=
1017 (void) printf("%s\t\t\"%.*s\"\n",
1019 (int)sizeof (list
.l_name
),
1021 offset
+= sizeof (struct str_mlist
);
1028 show_jwinsize(private_t
*pri
, long offset
)
1030 struct jwinsize jwinsize
;
1032 if (Pread(Proc
, &jwinsize
, sizeof (jwinsize
), offset
) ==
1033 sizeof (jwinsize
)) {
1035 "%s\tbytesx=%-3u bytesy=%-3u bitsx=%-3u bitsy=%-3u\n",
1037 (unsigned)jwinsize
.bytesx
,
1038 (unsigned)jwinsize
.bytesy
,
1039 (unsigned)jwinsize
.bitsx
,
1040 (unsigned)jwinsize
.bitsy
);
1045 show_winsize(private_t
*pri
, long offset
)
1047 struct winsize winsize
;
1049 if (Pread(Proc
, &winsize
, sizeof (winsize
), offset
)
1050 == sizeof (winsize
)) {
1052 "%s\trow=%-3d col=%-3d xpixel=%-3d ypixel=%-3d\n",
1061 struct audio_stuff
{
1066 const struct audio_stuff audio_output_ports
[] = {
1067 { AUDIO_SPEAKER
, "SPEAKER" },
1068 { AUDIO_HEADPHONE
, "HEADPHONE" },
1069 { AUDIO_LINE_OUT
, "LINE_OUT" },
1070 { AUDIO_SPDIF_OUT
, "SPDIF_OUT" },
1071 { AUDIO_AUX1_OUT
, "AUX1_OUT" },
1072 { AUDIO_AUX2_OUT
, "AUX2_OUT" },
1076 const struct audio_stuff audio_input_ports
[] = {
1077 { AUDIO_MICROPHONE
, "MICROPHONE" },
1078 { AUDIO_LINE_IN
, "LINE_IN" },
1080 { AUDIO_SPDIF_IN
, "SPDIF_IN" },
1081 { AUDIO_AUX1_IN
, "AUX1_IN" },
1082 { AUDIO_AUX2_IN
, "AUX2_IN" },
1083 { AUDIO_CODEC_LOOPB_IN
, "CODEC_LOOPB_IN" },
1084 { AUDIO_SUNVTS
, "SUNVTS" },
1088 static const struct audio_stuff audio_hw_features
[] = {
1089 { AUDIO_HWFEATURE_DUPLEX
, "DUPLEX" },
1090 { AUDIO_HWFEATURE_MSCODEC
, "MSCODEC" },
1091 { AUDIO_HWFEATURE_IN2OUT
, "IN2OUT" },
1092 { AUDIO_HWFEATURE_PLAY
, "PLAY" },
1093 { AUDIO_HWFEATURE_RECORD
, "RECORD" },
1097 static const struct audio_stuff audio_sw_features
[] = {
1098 { AUDIO_SWFEATURE_MIXER
, "MIXER" },
1103 show_audio_features(const private_t
*pri
,
1104 const struct audio_stuff
*audio_porttab
, uint_t features
,
1107 (void) printf("%s\t%s=", pri
->pname
, name
);
1108 if (features
== 0) {
1109 (void) printf("0\n");
1113 for (; audio_porttab
->bit
!= 0; ++audio_porttab
) {
1114 if (features
& audio_porttab
->bit
) {
1115 (void) printf(audio_porttab
->str
);
1116 features
&= ~audio_porttab
->bit
;
1118 (void) putchar('|');
1122 (void) printf("0x%x", features
);
1123 (void) putchar('\n');
1127 show_audio_ports(private_t
*pri
, const char *mode
,
1128 const char *field
, uint_t ports
)
1130 const struct audio_stuff
*audio_porttab
;
1132 (void) printf("%s\t%s\t%s=", pri
->pname
, mode
, field
);
1134 (void) printf("0\n");
1138 audio_porttab
= audio_output_ports
;
1140 audio_porttab
= audio_input_ports
;
1141 for (; audio_porttab
->bit
!= 0; ++audio_porttab
) {
1142 if (ports
& audio_porttab
->bit
) {
1143 (void) printf(audio_porttab
->str
);
1144 ports
&= ~audio_porttab
->bit
;
1146 (void) putchar('|');
1150 (void) printf("0x%x", ports
);
1151 (void) putchar('\n');
1155 show_audio_prinfo(private_t
*pri
, const char *mode
, struct audio_prinfo
*au_pr
)
1160 * The following values describe the audio data encoding.
1163 (void) printf("%s\t%s\tsample_rate=%u channels=%u precision=%u\n",
1170 switch (au_pr
->encoding
) {
1171 case AUDIO_ENCODING_NONE
: s
= "NONE"; break;
1172 case AUDIO_ENCODING_ULAW
: s
= "ULAW"; break;
1173 case AUDIO_ENCODING_ALAW
: s
= "ALAW"; break;
1174 case AUDIO_ENCODING_LINEAR
: s
= "LINEAR"; break;
1175 case AUDIO_ENCODING_DVI
: s
= "DVI"; break;
1176 case AUDIO_ENCODING_LINEAR8
: s
= "LINEAR8"; break;
1179 (void) printf("%s\t%s\tencoding=%s\n", pri
->pname
, mode
, s
);
1181 (void) printf("%s\t%s\tencoding=%u\n",
1182 pri
->pname
, mode
, au_pr
->encoding
);
1186 * The following values control audio device configuration
1190 "%s\t%s\tgain=%u buffer_size=%u\n",
1193 au_pr
->buffer_size
);
1194 show_audio_ports(pri
, mode
, "port", au_pr
->port
);
1195 show_audio_ports(pri
, mode
, "avail_ports", au_pr
->avail_ports
);
1196 show_audio_ports(pri
, mode
, "mod_ports", au_pr
->mod_ports
);
1199 * The following values describe driver state
1202 (void) printf("%s\t%s\tsamples=%u eof=%u pause=%u error=%u\n",
1208 (void) printf("%s\t%s\twaiting=%u balance=%u minordev=%u\n",
1215 * The following values are read-only state flags
1217 (void) printf("%s\t%s\topen=%u active=%u\n",
1224 show_audio_info(private_t
*pri
, long offset
)
1226 struct audio_info au
;
1228 if (Pread(Proc
, &au
, sizeof (au
), offset
) == sizeof (au
)) {
1229 show_audio_prinfo(pri
, "play", &au
.play
);
1230 show_audio_prinfo(pri
, "record", &au
.record
);
1231 (void) printf("%s\tmonitor_gain=%u output_muted=%u\n",
1232 pri
->pname
, au
.monitor_gain
, au
.output_muted
);
1233 show_audio_features(pri
, audio_hw_features
, au
.hw_features
,
1235 show_audio_features(pri
, audio_sw_features
, au
.sw_features
,
1237 show_audio_features(pri
, audio_sw_features
,
1238 au
.sw_features_enabled
, "sw_features_enabled");
1243 show_ioctl(private_t
*pri
, int code
, long offset
)
1245 int lp64
= (data_model
== PR_MODEL_LP64
);
1246 int err
= pri
->Errno
; /* don't display output parameters */
1247 /* for a failed system call */
1263 show_termio(pri
, offset
);
1272 show_termios(pri
, offset
);
1281 show_termiox(pri
, offset
);
1289 show_sgttyb(pri
, offset
);
1296 show_ltchars(pri
, offset
);
1303 show_tchars(pri
, offset
);
1310 show_termcb(pri
, offset
);
1312 /* streams ioctl()s */
1314 /* these are displayed as strings in the arg list */
1315 /* by prt_ioa(). don't display them again here */
1319 /* these are displayed as decimal in the arg list */
1320 /* by prt_ioa(). don't display them again here */
1324 /* these are displayed symbolically in the arg list */
1325 /* by prt_ioa(). don't display them again here */
1330 /* this one just ignores the argument */
1334 /* these return something in an int pointed to by arg */
1346 /* these pass something in an int pointed to by arg */
1352 show_strint(pri
, code
, offset
);
1354 /* these all point to structures */
1358 show_strioctl(pri
, offset
);
1360 show_strioctl32(pri
, offset
);
1362 show_strioctl(pri
, offset
);
1368 show_strpeek(pri
, offset
);
1370 show_strpeek32(pri
, offset
);
1372 show_strpeek(pri
, offset
);
1378 show_strfdinsert(pri
, offset
);
1380 show_strfdinsert32(pri
, offset
);
1382 show_strfdinsert(pri
, offset
);
1388 show_strrecvfd(pri
, offset
);
1395 show_strlist(pri
, offset
);
1397 show_strlist32(pri
, offset
);
1399 show_strlist(pri
, offset
);
1405 show_jwinsize(pri
, offset
);
1412 show_winsize(pri
, offset
);
1415 case (int)AUDIO_SETINFO
:
1416 show_audio_info(pri
, offset
);
1420 if ((code
& ~0xff) == ZFS_IOC
) {
1421 show_zfs_ioc(pri
, offset
);
1425 if (code
& IOC_INOUT
) {
1426 const char *str
= ioctldatastruct(code
);
1428 (void) printf("\t\t%s",
1429 (code
& IOC_INOUT
) == IOC_INOUT
? "write/read" :
1430 code
& IOC_IN
? "write" : "read");
1432 (void) printf(" (struct %s)\n", str
);
1434 (void) printf(" %d bytes\n",
1435 (code
>> 16) & IOCPARM_MASK
);
1442 show_statvfs(private_t
*pri
)
1445 struct statvfs statvfs
;
1448 if (pri
->sys_nargs
> 1 && (offset
= pri
->sys_args
[1]) != 0 &&
1449 Pread(Proc
, &statvfs
, sizeof (statvfs
), offset
)
1450 == sizeof (statvfs
)) {
1452 "%s\tbsize=%-10lu frsize=%-9lu blocks=%-8llu bfree=%-9llu\n",
1456 (u_longlong_t
)statvfs
.f_blocks
,
1457 (u_longlong_t
)statvfs
.f_bfree
);
1459 "%s\tbavail=%-9llu files=%-10llu ffree=%-9llu favail=%-9llu\n",
1461 (u_longlong_t
)statvfs
.f_bavail
,
1462 (u_longlong_t
)statvfs
.f_files
,
1463 (u_longlong_t
)statvfs
.f_ffree
,
1464 (u_longlong_t
)statvfs
.f_favail
);
1466 "%s\tfsid=0x%-9.4lX basetype=%-7.16s namemax=%ld\n",
1470 (long)statvfs
.f_namemax
);
1474 svfsflags(pri
, (ulong_t
)statvfs
.f_flag
));
1475 cp
= statvfs
.f_fstr
+ strlen(statvfs
.f_fstr
);
1476 if (cp
< statvfs
.f_fstr
+ sizeof (statvfs
.f_fstr
) - 1 &&
1479 (void) printf("%s\tfstr=\"%.*s\"\n",
1481 (int)sizeof (statvfs
.f_fstr
),
1487 show_statfs(private_t
*pri
)
1490 struct statfs statfs
;
1492 if (pri
->sys_nargs
>= 2 && (offset
= pri
->sys_args
[1]) != 0 &&
1493 Pread(Proc
, &statfs
, sizeof (statfs
), offset
) == sizeof (statfs
)) {
1495 "%s\tfty=%d bsz=%ld fsz=%ld blk=%ld bfr=%ld fil=%lu ffr=%lu\n",
1504 (void) printf("%s\t fname=%.6s fpack=%.6s\n",
1512 show_flock32(private_t
*pri
, long offset
)
1514 struct flock32 flock
;
1516 if (Pread(Proc
, &flock
, sizeof (flock
), offset
) == sizeof (flock
)) {
1517 const char *str
= NULL
;
1519 (void) printf("%s\ttyp=", pri
->pname
);
1521 switch (flock
.l_type
) {
1533 (void) printf("%s", str
);
1535 (void) printf("%-7d", flock
.l_type
);
1537 str
= whencearg(flock
.l_whence
);
1539 (void) printf(" whence=%s", str
);
1541 (void) printf(" whence=%-8u", flock
.l_whence
);
1544 " start=%-5d len=%-5d sys=%-2u pid=%d\n",
1553 show_flock64(private_t
*pri
, long offset
)
1555 struct flock64 flock
;
1557 if (Pread(Proc
, &flock
, sizeof (flock
), offset
) == sizeof (flock
)) {
1558 const char *str
= NULL
;
1560 (void) printf("%s\ttyp=", pri
->pname
);
1562 switch (flock
.l_type
) {
1574 (void) printf("%s", str
);
1576 (void) printf("%-7d", flock
.l_type
);
1578 str
= whencearg(flock
.l_whence
);
1580 (void) printf(" whence=%s", str
);
1582 (void) printf(" whence=%-8u", flock
.l_whence
);
1585 " start=%-5lld len=%-5lld sys=%-2u pid=%d\n",
1586 (long long)flock
.l_start
,
1587 (long long)flock
.l_len
,
1594 show_share(private_t
*pri
, long offset
)
1596 struct fshare fshare
;
1598 if (Pread(Proc
, &fshare
, sizeof (fshare
), offset
) == sizeof (fshare
)) {
1599 const char *str
= NULL
;
1602 (void) printf("%s\taccess=", pri
->pname
);
1604 switch (fshare
.f_access
) {
1616 (void) printf("%s", str
);
1618 (void) printf("%-7d", fshare
.f_access
);
1621 if (fshare
.f_deny
& F_MANDDNY
) {
1622 fshare
.f_deny
&= ~F_MANDDNY
;
1625 switch (fshare
.f_deny
) {
1644 (void) printf(" deny=F_MANDDNY|%s", str
);
1646 (void) printf(" deny=%s", str
);
1648 (void) printf(" deny=0x%x", manddny
?
1649 fshare
.f_deny
| F_MANDDNY
: fshare
.f_deny
);
1652 (void) printf(" id=%x\n", fshare
.f_id
);
1657 show_ffg(private_t
*pri
)
1659 (void) putchar('\t');
1660 (void) putchar('\t');
1661 prt_ffg(pri
, 0, pri
->Rval1
);
1662 (void) puts(pri
->sys_string
);
1665 /* print values in fcntl() pointed-to structure */
1667 show_fcntl(private_t
*pri
)
1671 if (pri
->sys_nargs
>= 2 && pri
->sys_args
[1] == F_GETFL
) {
1676 if (pri
->sys_nargs
< 3 || (offset
= pri
->sys_args
[2]) == 0)
1679 switch (pri
->sys_args
[1]) {
1686 case F_SETLK_NBMAND
:
1692 if (data_model
== PR_MODEL_LP64
)
1693 show_flock64(pri
, offset
);
1695 show_flock32(pri
, offset
);
1697 case 33: /* F_GETLK64 */
1698 case 34: /* F_SETLK64 */
1699 case 35: /* F_SETLKW64 */
1700 case 27: /* F_FREESP64 */
1701 case 28: /* F_ALLOCSP64 */
1702 case 44: /* F_SETLK64_NBMAND */
1703 case 50: /* F_OFD_GETLK64 */
1704 case 51: /* F_OFD_SETLK64 */
1705 case 52: /* F_OFD_SETLKW64 */
1706 case 55: /* F_FLOCK64 */
1707 case 56: /* F_FLOCKW64 */
1708 show_flock64(pri
, offset
);
1716 case F_SETLK64_NBMAND
:
1719 case F_OFD_SETLKW64
:
1722 show_flock64(pri
, offset
);
1727 show_share(pri
, offset
);
1733 show_strbuf(private_t
*pri
, long offset
, const char *name
, int dump
)
1735 struct strbuf strbuf
;
1737 if (Pread(Proc
, &strbuf
, sizeof (strbuf
), offset
) == sizeof (strbuf
))
1738 print_strbuf(pri
, &strbuf
, name
, dump
);
1743 show_strbuf32(private_t
*pri
, long offset
, const char *name
, int dump
)
1745 struct strbuf32 strbuf
;
1747 if (Pread(Proc
, &strbuf
, sizeof (strbuf
), offset
) == sizeof (strbuf
))
1748 print_strbuf32(pri
, &strbuf
, name
, dump
);
1753 show_gp_msg(private_t
*pri
, int what
)
1757 int fdp1
= pri
->sys_args
[0] + 1;
1762 if (pri
->Errno
== 0 && prismember(&readfd
, fdp1
))
1767 if (prismember(&writefd
, fdp1
))
1772 /* enter region of lengthy output */
1777 if (pri
->sys_nargs
>= 2 && (offset
= pri
->sys_args
[1]) != 0) {
1778 if (data_model
== PR_MODEL_LP64
)
1779 show_strbuf(pri
, offset
, "ctl", dump
);
1781 show_strbuf32(pri
, offset
, "ctl", dump
);
1783 if (pri
->sys_nargs
>= 3 && (offset
= pri
->sys_args
[2]) != 0) {
1784 if (data_model
== PR_MODEL_LP64
)
1785 show_strbuf(pri
, offset
, "dat", dump
);
1787 show_strbuf32(pri
, offset
, "dat", dump
);
1790 if (pri
->sys_nargs
>= 2 && (offset
= pri
->sys_args
[1]) != 0)
1791 show_strbuf(pri
, offset
, "ctl", dump
);
1792 if (pri
->sys_nargs
>= 3 && (offset
= pri
->sys_args
[2]) != 0)
1793 show_strbuf(pri
, offset
, "dat", dump
);
1796 /* exit region of lengthy output */
1802 show_int(private_t
*pri
, long offset
, const char *name
)
1807 Pread(Proc
, &value
, sizeof (value
), offset
) == sizeof (value
))
1808 (void) printf("%s\t%s:\t%d\n",
1815 show_hhex_int(private_t
*pri
, long offset
, const char *name
)
1819 if (Pread(Proc
, &value
, sizeof (value
), offset
) == sizeof (value
))
1820 (void) printf("%s\t%s:\t0x%.4X\n",
1826 #define ALL_POLL_FLAGS (POLLIN|POLLPRI|POLLOUT| \
1827 POLLRDNORM|POLLRDBAND|POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
1830 pollevent(private_t
*pri
, int arg
)
1832 char *str
= pri
->code_buf
;
1836 if (arg
& ~ALL_POLL_FLAGS
) {
1837 (void) sprintf(str
, "0x%-5X", arg
);
1838 return ((const char *)str
);
1843 (void) strcat(str
, "|POLLIN");
1845 (void) strcat(str
, "|POLLPRI");
1847 (void) strcat(str
, "|POLLOUT");
1848 if (arg
& POLLRDNORM
)
1849 (void) strcat(str
, "|POLLRDNORM");
1850 if (arg
& POLLRDBAND
)
1851 (void) strcat(str
, "|POLLRDBAND");
1852 if (arg
& POLLWRBAND
)
1853 (void) strcat(str
, "|POLLWRBAND");
1855 (void) strcat(str
, "|POLLERR");
1857 (void) strcat(str
, "|POLLHUP");
1859 (void) strcat(str
, "|POLLNVAL");
1861 return ((const char *)(str
+1));
1865 show_one_pollfd(private_t
*pri
, struct pollfd
*ppollfd
)
1868 * can't print both events and revents in same printf.
1869 * pollevent() returns a pointer to a TSD location.
1871 (void) printf("%s\tfd=%-2d ev=%s",
1872 pri
->pname
, ppollfd
->fd
, pollevent(pri
, ppollfd
->events
));
1873 (void) printf(" rev=%s\n", pollevent(pri
, ppollfd
->revents
));
1877 show_all_pollfds(private_t
*pri
, long offset
, int nfds
)
1879 struct pollfd pollfd
[2];
1882 for (; nfds
&& !interrupt
; nfds
--, offset
+= sizeof (struct pollfd
)) {
1883 if (Pread(Proc
, &pollfd
[0], sizeof (struct pollfd
), offset
) !=
1884 sizeof (struct pollfd
))
1887 if (skip
>= 0 && pollfd
[0].fd
== pollfd
[1].fd
&&
1888 pollfd
[0].events
== pollfd
[1].events
&&
1889 pollfd
[0].revents
== pollfd
[1].revents
) {
1895 (void) printf("%s\t...last pollfd structure"
1896 " repeated %d time%s...\n",
1897 pri
->pname
, skip
, (skip
== 1 ? "" : "s"));
1900 show_one_pollfd(pri
, &pollfd
[0]);
1901 pollfd
[1] = pollfd
[0];
1906 "%s\t...last pollfd structure repeated %d time%s...\n",
1907 pri
->pname
, skip
, (skip
== 1 ? "" : "s"));
1911 show_pollsys(private_t
*pri
)
1917 if (pri
->sys_nargs
< 2)
1920 offset
= pri
->sys_args
[0];
1921 nfds
= pri
->sys_args
[1];
1923 /* enter region of lengthy output */
1924 if (offset
!= 0 && nfds
> 32) {
1929 if (offset
!= 0 && nfds
> 0)
1930 show_all_pollfds(pri
, offset
, nfds
);
1932 if (pri
->sys_nargs
> 2)
1933 show_timestruc(pri
, (long)pri
->sys_args
[2], "timeout");
1935 if (pri
->sys_nargs
> 3)
1936 show_sigset(pri
, (long)pri
->sys_args
[3], "sigmask");
1938 /* exit region of lengthy output */
1944 show_perm64(private_t
*pri
, struct ipc_perm64
*ip
)
1946 (void) printf("%s\tu=%-5u g=%-5u cu=%-5u cg=%-5u z=%-5d "
1947 "m=0%.6o key=%d projid=%-5d\n",
1953 (int)ip
->ipcx_zoneid
,
1954 (unsigned int)ip
->ipcx_mode
,
1956 (int)ip
->ipcx_projid
);
1960 show_perm(private_t
*pri
, struct ipc_perm
*ip
)
1963 "%s\tu=%-5u g=%-5u cu=%-5u cg=%-5u m=0%.6o seq=%u key=%d\n",
1976 show_perm32(private_t
*pri
, struct ipc_perm32
*ip
)
1979 "%s\tu=%-5u g=%-5u cu=%-5u cg=%-5u m=0%.6o seq=%u key=%d\n",
1992 show_msgctl64(private_t
*pri
, long offset
)
1994 struct msqid_ds64 msgq
;
1997 Pread(Proc
, &msgq
, sizeof (msgq
), offset
) == sizeof (msgq
)) {
1998 show_perm64(pri
, &msgq
.msgx_perm
);
2000 (void) printf("%s\tbytes=%-5llu msgs=%-5llu maxby=%-5llu "
2001 "lspid=%-5d lrpid=%-5d\n", pri
->pname
,
2002 (unsigned long long)msgq
.msgx_cbytes
,
2003 (unsigned long long)msgq
.msgx_qnum
,
2004 (unsigned long long)msgq
.msgx_qbytes
,
2005 (int)msgq
.msgx_lspid
,
2006 (int)msgq
.msgx_lrpid
);
2008 prtime(pri
, " st = ", (time_t)msgq
.msgx_stime
);
2009 prtime(pri
, " rt = ", (time_t)msgq
.msgx_rtime
);
2010 prtime(pri
, " ct = ", (time_t)msgq
.msgx_ctime
);
2015 show_msgctl(private_t
*pri
, long offset
)
2017 struct msqid_ds msgq
;
2020 Pread(Proc
, &msgq
, sizeof (msgq
), offset
) == sizeof (msgq
)) {
2021 show_perm(pri
, &msgq
.msg_perm
);
2024 "%s\tbytes=%-5lu msgs=%-5lu maxby=%-5lu lspid=%-5u lrpid=%-5u\n",
2029 (int)msgq
.msg_lspid
,
2030 (int)msgq
.msg_lrpid
);
2032 prtime(pri
, " st = ", msgq
.msg_stime
);
2033 prtime(pri
, " rt = ", msgq
.msg_rtime
);
2034 prtime(pri
, " ct = ", msgq
.msg_ctime
);
2040 show_msgctl32(private_t
*pri
, long offset
)
2042 struct msqid_ds32 msgq
;
2045 Pread(Proc
, &msgq
, sizeof (msgq
), offset
) == sizeof (msgq
)) {
2046 show_perm32(pri
, &msgq
.msg_perm
);
2049 "%s\tbytes=%-5u msgs=%-5u maxby=%-5u lspid=%-5u lrpid=%-5u\n",
2057 prtime(pri
, " st = ", msgq
.msg_stime
);
2058 prtime(pri
, " rt = ", msgq
.msg_rtime
);
2059 prtime(pri
, " ct = ", msgq
.msg_ctime
);
2065 show_msgbuf(private_t
*pri
, long offset
, long msgsz
)
2070 Pread(Proc
, &msgb
, sizeof (msgb
.mtype
), offset
) ==
2071 sizeof (msgb
.mtype
)) {
2072 /* enter region of lengthy output */
2073 if (msgsz
> MYBUFSIZ
/ 4)
2076 (void) printf("%s\tmtype=%lu mtext[]=\n",
2080 (long)(offset
+ sizeof (msgb
.mtype
)), msgsz
);
2082 /* exit region of lengthy output */
2083 if (msgsz
> MYBUFSIZ
/ 4)
2090 show_msgbuf32(private_t
*pri
, long offset
, long msgsz
)
2092 struct ipcmsgbuf32 msgb
;
2095 Pread(Proc
, &msgb
, sizeof (msgb
.mtype
), offset
) ==
2096 sizeof (msgb
.mtype
)) {
2097 /* enter region of lengthy output */
2098 if (msgsz
> MYBUFSIZ
/ 4)
2101 (void) printf("%s\tmtype=%u mtext[]=\n",
2105 (long)(offset
+ sizeof (msgb
.mtype
)), msgsz
);
2107 /* exit region of lengthy output */
2108 if (msgsz
> MYBUFSIZ
/ 4)
2116 show_msgsys(private_t
*pri
, long msgsz
)
2118 switch (pri
->sys_args
[0]) {
2119 case 0: /* msgget() */
2121 case 1: /* msgctl() */
2122 if (pri
->sys_nargs
> 3) {
2123 switch (pri
->sys_args
[2]) {
2129 if (data_model
== PR_MODEL_LP64
)
2131 (long)pri
->sys_args
[3]);
2134 (long)pri
->sys_args
[3]);
2141 show_msgctl64(pri
, (long)pri
->sys_args
[3]);
2146 case 2: /* msgrcv() */
2147 if (!pri
->Errno
&& pri
->sys_nargs
> 2) {
2148 if (data_model
== PR_MODEL_LP64
)
2149 show_msgbuf(pri
, pri
->sys_args
[2], msgsz
);
2151 show_msgbuf32(pri
, pri
->sys_args
[2], msgsz
);
2154 case 3: /* msgsnd() */
2155 if (pri
->sys_nargs
> 3) {
2156 if (data_model
== PR_MODEL_LP64
)
2157 show_msgbuf(pri
, pri
->sys_args
[2],
2160 show_msgbuf32(pri
, pri
->sys_args
[2],
2164 case 4: /* msgids() */
2165 case 5: /* msgsnap() */
2166 default: /* unexpected subcode */
2172 show_msgsys(private_t
*pri
, long msgsz
)
2174 switch (pri
->sys_args
[0]) {
2175 case 0: /* msgget() */
2177 case 1: /* msgctl() */
2178 if (pri
->sys_nargs
> 3) {
2179 switch (pri
->sys_args
[2]) {
2185 show_msgctl(pri
, (long)pri
->sys_args
[3]);
2192 show_msgctl64(pri
, (long)pri
->sys_args
[3]);
2197 case 2: /* msgrcv() */
2198 if (!pri
->Errno
&& pri
->sys_nargs
> 2)
2199 show_msgbuf(pri
, pri
->sys_args
[2], msgsz
);
2201 case 3: /* msgsnd() */
2202 if (pri
->sys_nargs
> 3)
2203 show_msgbuf(pri
, pri
->sys_args
[2],
2206 case 4: /* msgids() */
2207 case 5: /* msgsnap() */
2208 default: /* unexpected subcode */
2215 show_semctl64(private_t
*pri
, long offset
)
2217 struct semid_ds64 semds
;
2220 Pread(Proc
, &semds
, sizeof (semds
), offset
) == sizeof (semds
)) {
2221 show_perm64(pri
, &semds
.semx_perm
);
2223 (void) printf("%s\tnsems=%u\n", pri
->pname
, semds
.semx_nsems
);
2225 prtime(pri
, " ot = ", (time_t)semds
.semx_otime
);
2226 prtime(pri
, " ct = ", (time_t)semds
.semx_ctime
);
2231 show_semctl(private_t
*pri
, long offset
)
2233 struct semid_ds semds
;
2236 Pread(Proc
, &semds
, sizeof (semds
), offset
) == sizeof (semds
)) {
2237 show_perm(pri
, &semds
.sem_perm
);
2239 (void) printf("%s\tnsems=%u\n",
2243 prtime(pri
, " ot = ", semds
.sem_otime
);
2244 prtime(pri
, " ct = ", semds
.sem_ctime
);
2250 show_semctl32(private_t
*pri
, long offset
)
2252 struct semid_ds32 semds
;
2255 Pread(Proc
, &semds
, sizeof (semds
), offset
) == sizeof (semds
)) {
2256 show_perm32(pri
, &semds
.sem_perm
);
2258 (void) printf("%s\tnsems=%u\n",
2262 prtime(pri
, " ot = ", semds
.sem_otime
);
2263 prtime(pri
, " ct = ", semds
.sem_ctime
);
2269 show_semop(private_t
*pri
, long offset
, long nsops
, long timeout
)
2271 struct sembuf sembuf
;
2277 if (nsops
> 40) /* let's not be ridiculous */
2280 for (; nsops
> 0 && !interrupt
; --nsops
, offset
+= sizeof (sembuf
)) {
2281 if (Pread(Proc
, &sembuf
, sizeof (sembuf
), offset
) !=
2285 (void) printf("%s\tsemnum=%-5u semop=%-5d semflg=",
2290 if (sembuf
.sem_flg
== 0)
2291 (void) printf("0\n");
2292 else if ((str
= semflags(pri
, sembuf
.sem_flg
)) != NULL
)
2293 (void) printf("%s\n", str
);
2295 (void) printf("0%.6o\n", sembuf
.sem_flg
);
2298 show_timestruc(pri
, timeout
, "timeout");
2302 show_semsys(private_t
*pri
)
2304 switch (pri
->sys_args
[0]) {
2305 case 0: /* semctl() */
2306 if (pri
->sys_nargs
> 4) {
2307 switch (pri
->sys_args
[3]) {
2314 if (data_model
== PR_MODEL_LP64
)
2316 (long)pri
->sys_args
[4]);
2319 (long)pri
->sys_args
[4]);
2321 show_semctl(pri
, (long)pri
->sys_args
[4]);
2329 show_semctl64(pri
, (long)pri
->sys_args
[4]);
2334 case 1: /* semget() */
2336 case 2: /* semop() */
2337 if (pri
->sys_nargs
> 3)
2338 show_semop(pri
, (long)pri
->sys_args
[2],
2339 pri
->sys_args
[3], 0);
2341 case 3: /* semids() */
2343 case 4: /* semtimedop() */
2344 if (pri
->sys_nargs
> 4)
2345 show_semop(pri
, (long)pri
->sys_args
[2],
2346 pri
->sys_args
[3], pri
->sys_args
[4]);
2348 default: /* unexpected subcode */
2354 show_shmctl64(private_t
*pri
, long offset
)
2356 struct shmid_ds64 shmds
;
2359 Pread(Proc
, &shmds
, sizeof (shmds
), offset
) == sizeof (shmds
)) {
2360 show_perm64(pri
, &shmds
.shmx_perm
);
2363 "%s\tsize=%-6llu lpid=%-5d cpid=%-5d na=%-5llu cna=%llu\n",
2365 (unsigned long long)shmds
.shmx_segsz
,
2366 (int)shmds
.shmx_lpid
,
2367 (int)shmds
.shmx_cpid
,
2368 (unsigned long long)shmds
.shmx_nattch
,
2369 (unsigned long long)shmds
.shmx_cnattch
);
2371 prtime(pri
, " at = ", (time_t)shmds
.shmx_atime
);
2372 prtime(pri
, " dt = ", (time_t)shmds
.shmx_dtime
);
2373 prtime(pri
, " ct = ", (time_t)shmds
.shmx_ctime
);
2378 show_shmctl(private_t
*pri
, long offset
)
2380 struct shmid_ds shmds
;
2383 Pread(Proc
, &shmds
, sizeof (shmds
), offset
) == sizeof (shmds
)) {
2384 show_perm(pri
, &shmds
.shm_perm
);
2387 "%s\tsize=%-6lu lpid=%-5u cpid=%-5u na=%-5lu cna=%lu\n",
2389 (ulong_t
)shmds
.shm_segsz
,
2390 (int)shmds
.shm_lpid
,
2391 (int)shmds
.shm_cpid
,
2395 prtime(pri
, " at = ", shmds
.shm_atime
);
2396 prtime(pri
, " dt = ", shmds
.shm_dtime
);
2397 prtime(pri
, " ct = ", shmds
.shm_ctime
);
2403 show_shmctl32(private_t
*pri
, long offset
)
2405 struct shmid_ds32 shmds
;
2408 Pread(Proc
, &shmds
, sizeof (shmds
), offset
) == sizeof (shmds
)) {
2409 show_perm32(pri
, &shmds
.shm_perm
);
2412 "%s\tsize=%-6u lpid=%-5u cpid=%-5u na=%-5u cna=%u\n",
2420 prtime(pri
, " at = ", shmds
.shm_atime
);
2421 prtime(pri
, " dt = ", shmds
.shm_dtime
);
2422 prtime(pri
, " ct = ", shmds
.shm_ctime
);
2428 show_shmsys(private_t
*pri
)
2430 switch (pri
->sys_args
[0]) {
2431 case 0: /* shmat() */
2433 case 1: /* shmctl() */
2434 if (pri
->sys_nargs
> 3) {
2435 switch (pri
->sys_args
[2]) {
2442 if (data_model
== PR_MODEL_LP64
)
2444 (long)pri
->sys_args
[3]);
2447 (long)pri
->sys_args
[3]);
2449 show_shmctl(pri
, (long)pri
->sys_args
[3]);
2457 show_shmctl64(pri
, (long)pri
->sys_args
[3]);
2462 case 2: /* shmdt() */
2463 case 3: /* shmget() */
2464 case 4: /* shmids() */
2465 default: /* unexpected subcode */
2471 show_groups(private_t
*pri
, long offset
, long count
)
2478 if (count
> 0 && offset
!= 0 &&
2479 Pread(Proc
, &groups
[0], count
*sizeof (int), offset
) ==
2480 count
*sizeof (int)) {
2483 (void) printf("%s\t", pri
->pname
);
2484 for (n
= 0; !interrupt
&& n
< count
; n
++) {
2485 if (n
!= 0 && n
%10 == 0)
2486 (void) printf("\n%s\t", pri
->pname
);
2487 (void) printf(" %5d", groups
[n
]);
2489 (void) fputc('\n', stdout
);
2494 * This assumes that a sigset_t is simply an array of ints.
2497 sigset_string(private_t
*pri
, sigset_t
*sp
)
2499 char *s
= pri
->code_buf
;
2500 int n
= sizeof (*sp
) / sizeof (int32_t);
2501 int32_t *lp
= (int32_t *)sp
;
2504 int32_t val
= *lp
++;
2507 s
+= sprintf(s
, " 0");
2509 s
+= sprintf(s
, " 0x%.8X", val
);
2512 return (pri
->code_buf
);
2516 show_sigset(private_t
*pri
, long offset
, const char *name
)
2521 Pread(Proc
, &sigset
, sizeof (sigset
), offset
) == sizeof (sigset
)) {
2522 (void) printf("%s\t%s =%s\n",
2523 pri
->pname
, name
, sigset_string(pri
, &sigset
));
2529 show_sigaltstack32(private_t
*pri
, long offset
, const char *name
)
2531 struct sigaltstack32 altstack
;
2534 Pread(Proc
, &altstack
, sizeof (altstack
), offset
) ==
2535 sizeof (altstack
)) {
2536 (void) printf("%s\t%s: sp=0x%.8X size=%u flags=0x%.4X\n",
2547 show_sigaltstack(private_t
*pri
, long offset
, const char *name
)
2549 struct sigaltstack altstack
;
2552 if (data_model
!= PR_MODEL_LP64
) {
2553 show_sigaltstack32(pri
, offset
, name
);
2558 Pread(Proc
, &altstack
, sizeof (altstack
), offset
) ==
2559 sizeof (altstack
)) {
2560 (void) printf("%s\t%s: sp=0x%.8lX size=%lu flags=0x%.4X\n",
2563 (ulong_t
)altstack
.ss_sp
,
2564 (ulong_t
)altstack
.ss_size
,
2571 show_sigaction32(private_t
*pri
, long offset
, const char *name
, long odisp
)
2573 struct sigaction32 sigaction
;
2576 Pread(Proc
, &sigaction
, sizeof (sigaction
), offset
) ==
2577 sizeof (sigaction
)) {
2578 /* This is stupid, we shouldn't have to do this */
2580 sigaction
.sa_handler
= (caddr32_t
)odisp
;
2582 "%s %s: hand = 0x%.8X mask =%s flags = 0x%.4X\n",
2585 sigaction
.sa_handler
,
2586 sigset_string(pri
, (sigset_t
*)&sigaction
.sa_mask
),
2587 sigaction
.sa_flags
);
2593 show_sigaction(private_t
*pri
, long offset
, const char *name
, long odisp
)
2595 struct sigaction sigaction
;
2598 if (data_model
!= PR_MODEL_LP64
) {
2599 show_sigaction32(pri
, offset
, name
, odisp
);
2604 Pread(Proc
, &sigaction
, sizeof (sigaction
), offset
) ==
2605 sizeof (sigaction
)) {
2606 /* This is stupid, we shouldn't have to do this */
2608 sigaction
.sa_handler
= (void (*)())odisp
;
2610 "%s %s: hand = 0x%.8lX mask =%s flags = 0x%.4X\n",
2613 (long)sigaction
.sa_handler
,
2614 sigset_string(pri
, &sigaction
.sa_mask
),
2615 sigaction
.sa_flags
);
2621 print_siginfo32(private_t
*pri
, const siginfo32_t
*sip
)
2623 const char *code
= NULL
;
2625 (void) printf("%s siginfo: %s", pri
->pname
,
2626 signame(pri
, sip
->si_signo
));
2628 if (sip
->si_signo
!= 0 && SI_FROMUSER(sip
) && sip
->si_pid
!= 0) {
2629 (void) printf(" pid=%d uid=%d", sip
->si_pid
, sip
->si_uid
);
2630 if (sip
->si_code
!= 0)
2631 (void) printf(" code=%d", sip
->si_code
);
2632 (void) fputc('\n', stdout
);
2636 switch (sip
->si_signo
) {
2638 (void) fputc('\n', stdout
);
2652 switch (sip
->si_signo
) {
2654 switch (sip
->si_code
) {
2655 case ILL_ILLOPC
: code
= "ILL_ILLOPC"; break;
2656 case ILL_ILLOPN
: code
= "ILL_ILLOPN"; break;
2657 case ILL_ILLADR
: code
= "ILL_ILLADR"; break;
2658 case ILL_ILLTRP
: code
= "ILL_ILLTRP"; break;
2659 case ILL_PRVOPC
: code
= "ILL_PRVOPC"; break;
2660 case ILL_PRVREG
: code
= "ILL_PRVREG"; break;
2661 case ILL_COPROC
: code
= "ILL_COPROC"; break;
2662 case ILL_BADSTK
: code
= "ILL_BADSTK"; break;
2666 switch (sip
->si_code
) {
2667 case TRAP_BRKPT
: code
= "TRAP_BRKPT"; break;
2668 case TRAP_TRACE
: code
= "TRAP_TRACE"; break;
2669 case TRAP_RWATCH
: code
= "TRAP_RWATCH"; break;
2670 case TRAP_WWATCH
: code
= "TRAP_WWATCH"; break;
2671 case TRAP_XWATCH
: code
= "TRAP_XWATCH"; break;
2672 case TRAP_DTRACE
: code
= "TRAP_DTRACE"; break;
2676 switch (sip
->si_code
) {
2677 case FPE_INTDIV
: code
= "FPE_INTDIV"; break;
2678 case FPE_INTOVF
: code
= "FPE_INTOVF"; break;
2679 case FPE_FLTDIV
: code
= "FPE_FLTDIV"; break;
2680 case FPE_FLTOVF
: code
= "FPE_FLTOVF"; break;
2681 case FPE_FLTUND
: code
= "FPE_FLTUND"; break;
2682 case FPE_FLTRES
: code
= "FPE_FLTRES"; break;
2683 case FPE_FLTINV
: code
= "FPE_FLTINV"; break;
2684 case FPE_FLTSUB
: code
= "FPE_FLTSUB"; break;
2685 #if defined(FPE_FLTDEN)
2686 case FPE_FLTDEN
: code
= "FPE_FLTDEN"; break;
2691 switch (sip
->si_code
) {
2692 case SEGV_MAPERR
: code
= "SEGV_MAPERR"; break;
2693 case SEGV_ACCERR
: code
= "SEGV_ACCERR"; break;
2697 switch (sip
->si_code
) {
2699 case EMT_TAGOVF
: code
= "EMT_TAGOVF"; break;
2701 case EMT_CPCOVF
: code
= "EMT_CPCOVF"; break;
2705 switch (sip
->si_code
) {
2706 case BUS_ADRALN
: code
= "BUS_ADRALN"; break;
2707 case BUS_ADRERR
: code
= "BUS_ADRERR"; break;
2708 case BUS_OBJERR
: code
= "BUS_OBJERR"; break;
2712 switch (sip
->si_code
) {
2713 case CLD_EXITED
: code
= "CLD_EXITED"; break;
2714 case CLD_KILLED
: code
= "CLD_KILLED"; break;
2715 case CLD_DUMPED
: code
= "CLD_DUMPED"; break;
2716 case CLD_TRAPPED
: code
= "CLD_TRAPPED"; break;
2717 case CLD_STOPPED
: code
= "CLD_STOPPED"; break;
2718 case CLD_CONTINUED
: code
= "CLD_CONTINUED"; break;
2722 switch (sip
->si_code
) {
2723 case POLL_IN
: code
= "POLL_IN"; break;
2724 case POLL_OUT
: code
= "POLL_OUT"; break;
2725 case POLL_MSG
: code
= "POLL_MSG"; break;
2726 case POLL_ERR
: code
= "POLL_ERR"; break;
2727 case POLL_PRI
: code
= "POLL_PRI"; break;
2728 case POLL_HUP
: code
= "POLL_HUP"; break;
2734 (void) sprintf(pri
->code_buf
, "code=%d", sip
->si_code
);
2735 code
= (const char *)pri
->code_buf
;
2738 switch (sip
->si_signo
) {
2745 (void) printf(" %s addr=0x%.8X",
2750 (void) printf(" %s pid=%d status=0x%.4X",
2757 (void) printf(" %s fd=%d band=%d",
2764 if (sip
->si_errno
!= 0) {
2765 const char *ename
= errname(sip
->si_errno
);
2767 (void) printf(" errno=%d", sip
->si_errno
);
2769 (void) printf("(%s)", ename
);
2772 (void) fputc('\n', stdout
);
2777 print_siginfo(private_t
*pri
, const siginfo_t
*sip
)
2779 const char *code
= NULL
;
2781 (void) printf("%s siginfo: %s", pri
->pname
,
2782 signame(pri
, sip
->si_signo
));
2784 if (sip
->si_signo
!= 0 && SI_FROMUSER(sip
) && sip
->si_pid
!= 0) {
2785 (void) printf(" pid=%d uid=%u",
2788 if (sip
->si_code
!= 0)
2789 (void) printf(" code=%d", sip
->si_code
);
2790 (void) fputc('\n', stdout
);
2794 switch (sip
->si_signo
) {
2796 (void) fputc('\n', stdout
);
2810 switch (sip
->si_signo
) {
2812 switch (sip
->si_code
) {
2813 case ILL_ILLOPC
: code
= "ILL_ILLOPC"; break;
2814 case ILL_ILLOPN
: code
= "ILL_ILLOPN"; break;
2815 case ILL_ILLADR
: code
= "ILL_ILLADR"; break;
2816 case ILL_ILLTRP
: code
= "ILL_ILLTRP"; break;
2817 case ILL_PRVOPC
: code
= "ILL_PRVOPC"; break;
2818 case ILL_PRVREG
: code
= "ILL_PRVREG"; break;
2819 case ILL_COPROC
: code
= "ILL_COPROC"; break;
2820 case ILL_BADSTK
: code
= "ILL_BADSTK"; break;
2824 switch (sip
->si_code
) {
2825 case TRAP_BRKPT
: code
= "TRAP_BRKPT"; break;
2826 case TRAP_TRACE
: code
= "TRAP_TRACE"; break;
2827 case TRAP_RWATCH
: code
= "TRAP_RWATCH"; break;
2828 case TRAP_WWATCH
: code
= "TRAP_WWATCH"; break;
2829 case TRAP_XWATCH
: code
= "TRAP_XWATCH"; break;
2830 case TRAP_DTRACE
: code
= "TRAP_DTRACE"; break;
2834 switch (sip
->si_code
) {
2835 case FPE_INTDIV
: code
= "FPE_INTDIV"; break;
2836 case FPE_INTOVF
: code
= "FPE_INTOVF"; break;
2837 case FPE_FLTDIV
: code
= "FPE_FLTDIV"; break;
2838 case FPE_FLTOVF
: code
= "FPE_FLTOVF"; break;
2839 case FPE_FLTUND
: code
= "FPE_FLTUND"; break;
2840 case FPE_FLTRES
: code
= "FPE_FLTRES"; break;
2841 case FPE_FLTINV
: code
= "FPE_FLTINV"; break;
2842 case FPE_FLTSUB
: code
= "FPE_FLTSUB"; break;
2843 #if defined(FPE_FLTDEN)
2844 case FPE_FLTDEN
: code
= "FPE_FLTDEN"; break;
2849 switch (sip
->si_code
) {
2850 case SEGV_MAPERR
: code
= "SEGV_MAPERR"; break;
2851 case SEGV_ACCERR
: code
= "SEGV_ACCERR"; break;
2855 switch (sip
->si_code
) {
2857 case EMT_TAGOVF
: code
= "EMT_TAGOVF"; break;
2859 case EMT_CPCOVF
: code
= "EMT_CPCOVF"; break;
2863 switch (sip
->si_code
) {
2864 case BUS_ADRALN
: code
= "BUS_ADRALN"; break;
2865 case BUS_ADRERR
: code
= "BUS_ADRERR"; break;
2866 case BUS_OBJERR
: code
= "BUS_OBJERR"; break;
2870 switch (sip
->si_code
) {
2871 case CLD_EXITED
: code
= "CLD_EXITED"; break;
2872 case CLD_KILLED
: code
= "CLD_KILLED"; break;
2873 case CLD_DUMPED
: code
= "CLD_DUMPED"; break;
2874 case CLD_TRAPPED
: code
= "CLD_TRAPPED"; break;
2875 case CLD_STOPPED
: code
= "CLD_STOPPED"; break;
2876 case CLD_CONTINUED
: code
= "CLD_CONTINUED"; break;
2880 switch (sip
->si_code
) {
2881 case POLL_IN
: code
= "POLL_IN"; break;
2882 case POLL_OUT
: code
= "POLL_OUT"; break;
2883 case POLL_MSG
: code
= "POLL_MSG"; break;
2884 case POLL_ERR
: code
= "POLL_ERR"; break;
2885 case POLL_PRI
: code
= "POLL_PRI"; break;
2886 case POLL_HUP
: code
= "POLL_HUP"; break;
2892 (void) sprintf(pri
->code_buf
, "code=%d", sip
->si_code
);
2893 code
= (const char *)pri
->code_buf
;
2896 switch (sip
->si_signo
) {
2903 (void) printf(" %s addr=0x%.8lX",
2905 (long)sip
->si_addr
);
2908 (void) printf(" %s pid=%d status=0x%.4X",
2915 (void) printf(" %s fd=%d band=%ld",
2922 if (sip
->si_errno
!= 0) {
2923 const char *ename
= errname(sip
->si_errno
);
2925 (void) printf(" errno=%d", sip
->si_errno
);
2927 (void) printf("(%s)", ename
);
2930 (void) fputc('\n', stdout
);
2935 show_siginfo32(private_t
*pri
, long offset
)
2937 struct siginfo32 siginfo
;
2940 Pread(Proc
, &siginfo
, sizeof (siginfo
), offset
) == sizeof (siginfo
))
2941 print_siginfo32(pri
, &siginfo
);
2946 show_siginfo(private_t
*pri
, long offset
)
2948 struct siginfo siginfo
;
2951 if (data_model
!= PR_MODEL_LP64
) {
2952 show_siginfo32(pri
, offset
);
2957 Pread(Proc
, &siginfo
, sizeof (siginfo
), offset
) == sizeof (siginfo
))
2958 print_siginfo(pri
, &siginfo
);
2962 show_bool(private_t
*pri
, long offset
, int count
)
2964 int serial
= (count
> MYBUFSIZ
/ 4);
2966 /* enter region of lengthy output */
2972 int nb
= (count
< 32)? count
: 32;
2975 if (Pread(Proc
, buf
, (size_t)nb
, offset
) != nb
)
2978 (void) printf("%s ", pri
->pname
);
2979 for (i
= 0; i
< nb
; i
++)
2980 (void) printf(" %d", buf
[i
]);
2981 (void) fputc('\n', stdout
);
2987 /* exit region of lengthy output */
2994 show_iovec32(private_t
*pri
, long offset
, int niov
, int showbuf
, long count
)
2996 iovec32_t iovec
[16];
2999 int serial
= (count
> MYBUFSIZ
/ 4 && showbuf
);
3001 if (niov
> 16) /* is this the real limit? */
3004 if (offset
!= 0 && niov
> 0 &&
3005 Pread(Proc
, &iovec
[0], niov
*sizeof (iovec32_t
), offset
)
3006 == niov
*sizeof (iovec32_t
)) {
3007 /* enter region of lengthy output */
3011 for (ip
= &iovec
[0]; niov
-- && !interrupt
; ip
++) {
3012 (void) printf("%s\tiov_base = 0x%.8X iov_len = %d\n",
3016 if ((nb
= count
) > 0) {
3017 if (nb
> ip
->iov_len
)
3022 if (showbuf
&& nb
> 0)
3023 showbuffer(pri
, (long)ip
->iov_base
, nb
);
3026 /* exit region of lengthy output */
3034 show_iovec(private_t
*pri
, long offset
, long niov
, int showbuf
, long count
)
3039 int serial
= (count
> MYBUFSIZ
/ 4 && showbuf
);
3042 if (data_model
!= PR_MODEL_LP64
) {
3043 show_iovec32(pri
, offset
, niov
, showbuf
, count
);
3047 if (niov
> 16) /* is this the real limit? */
3050 if (offset
!= 0 && niov
> 0 &&
3051 Pread(Proc
, &iovec
[0], niov
*sizeof (iovec_t
), offset
)
3052 == niov
*sizeof (iovec_t
)) {
3053 /* enter region of lengthy output */
3057 for (ip
= &iovec
[0]; niov
-- && !interrupt
; ip
++) {
3058 (void) printf("%s\tiov_base = 0x%.8lX iov_len = %lu\n",
3062 if ((nb
= count
) > 0) {
3063 if (nb
> ip
->iov_len
)
3068 if (showbuf
&& nb
> 0)
3069 showbuffer(pri
, (long)ip
->iov_base
, nb
);
3072 /* exit region of lengthy output */
3079 show_dents(private_t
*pri
, long offset
, long count
)
3081 long long buf
[MYBUFSIZ
/ sizeof (long long)];
3083 int serial
= (count
> 100);
3088 /* enter region of lengthy output */
3092 while (count
> 0 && !interrupt
) {
3093 int nb
= count
< MYBUFSIZ
? (int)count
: MYBUFSIZ
;
3095 if ((nb
= Pread(Proc
, &buf
[0], (size_t)nb
, offset
)) <= 0)
3098 dp
= (struct dirent
*)&buf
[0];
3099 if (nb
< (int)(dp
->d_name
- (char *)dp
))
3101 if ((unsigned)nb
< dp
->d_reclen
) {
3102 /* getdents() error? */
3104 "%s ino=%-5llu off=%-4lld rlen=%-3d\n",
3106 (long long)dp
->d_ino
,
3107 (long long)dp
->d_off
,
3112 while (!interrupt
&&
3113 nb
>= (int)(dp
->d_name
- (char *)dp
) &&
3114 (unsigned)nb
>= dp
->d_reclen
) {
3116 "%s ino=%-5llu off=%-4lld rlen=%-3d \"%.*s\"\n",
3118 (long long)dp
->d_ino
,
3119 (long long)dp
->d_off
,
3121 dp
->d_reclen
- (int)(dp
->d_name
- (char *)dp
),
3124 count
-= dp
->d_reclen
;
3125 offset
+= dp
->d_reclen
;
3126 /* LINTED improper alignment */
3127 dp
= (struct dirent
*)((char *)dp
+ dp
->d_reclen
);
3131 /* exit region of lengthy output */
3137 show_rlimit(private_t
*pri
, long offset
)
3139 struct rlimit rlimit
;
3142 Pread(Proc
, &rlimit
, sizeof (rlimit
), offset
) == sizeof (rlimit
)) {
3143 (void) printf("%s\t", pri
->pname
);
3144 switch (rlimit
.rlim_cur
) {
3146 (void) fputs("cur = RLIM_INFINITY", stdout
);
3148 case RLIM_SAVED_MAX
:
3149 (void) fputs("cur = RLIM_SAVED_MAX", stdout
);
3151 case RLIM_SAVED_CUR
:
3152 (void) fputs("cur = RLIM_SAVED_CUR", stdout
);
3155 (void) printf("cur = %llu",
3156 (unsigned long long)rlimit
.rlim_cur
);
3159 switch (rlimit
.rlim_max
) {
3161 (void) fputs(" max = RLIM_INFINITY\n", stdout
);
3163 case RLIM_SAVED_MAX
:
3164 (void) fputs(" max = RLIM_SAVED_MAX\n", stdout
);
3166 case RLIM_SAVED_CUR
:
3167 (void) fputs(" max = RLIM_SAVED_CUR\n", stdout
);
3170 (void) printf(" max = %llu\n",
3171 (unsigned long long)rlimit
.rlim_max
);
3178 show_uname(private_t
*pri
, long offset
)
3180 struct utsname ubuf
;
3183 Pread(Proc
, &ubuf
, sizeof (ubuf
), offset
) == sizeof (ubuf
)) {
3185 "%s\tsys=%s nod=%s rel=%s ver=%s mch=%s\n",
3196 show_adjtime(private_t
*pri
, long off1
, long off2
)
3198 show_timeval(pri
, off1
, " delta");
3199 show_timeval(pri
, off2
, "olddelta");
3203 show_sockaddr(private_t
*pri
,
3204 const char *str
, long addroff
, long lenoff
, long len
)
3207 * A buffer large enough for PATH_MAX size AF_UNIX address, which is
3208 * also large enough to store a sockaddr_in or a sockaddr_in6.
3210 long buf
[(sizeof (short) + PATH_MAX
+ sizeof (long) - 1)
3212 struct sockaddr
*sa
= (struct sockaddr
*)buf
;
3213 struct sockaddr_in
*sin
= (struct sockaddr_in
*)buf
;
3214 struct sockaddr_un
*soun
= (struct sockaddr_un
*)buf
;
3215 struct sockaddr_in6
*sin6
= (struct sockaddr_in6
*)buf
;
3216 char addrbuf
[INET6_ADDRSTRLEN
];
3220 if (Pread(Proc
, &ilen
, sizeof (ilen
), lenoff
) != sizeof (ilen
))
3225 if (len
>= sizeof (buf
)) /* protect against ridiculous length */
3226 len
= sizeof (buf
) - 1;
3227 if (Pread(Proc
, buf
, len
, addroff
) != len
)
3230 switch (sa
->sa_family
) {
3232 (void) printf("%s\tAF_INET6 %s = %s port = %u\n",
3234 inet_ntop(AF_INET6
, &sin6
->sin6_addr
, addrbuf
,
3236 ntohs(sin6
->sin6_port
));
3237 (void) printf("%s\tscope id = %u source id = 0x%x\n"
3238 "%s\tflow class = 0x%02x flow label = 0x%05x\n",
3239 pri
->pname
, ntohl(sin6
->sin6_scope_id
),
3240 ntohl(sin6
->__sin6_src_id
),
3242 ntohl((sin6
->sin6_flowinfo
& IPV6_FLOWINFO_TCLASS
) >> 20),
3243 ntohl(sin6
->sin6_flowinfo
& IPV6_FLOWINFO_FLOWLABEL
));
3246 (void) printf("%s\tAF_%s %s = %s port = %u\n",
3248 str
, inet_ntop(AF_INET
, &sin
->sin_addr
, addrbuf
,
3249 sizeof (addrbuf
)), ntohs(sin
->sin_port
));
3252 len
-= sizeof (soun
->sun_family
);
3254 /* Null terminate */
3255 soun
->sun_path
[len
] = '\0';
3256 (void) printf("%s\tAF_UNIX %s = %s\n", pri
->pname
,
3257 str
, soun
->sun_path
);
3264 show_msghdr(private_t
*pri
, long offset
)
3266 const lwpstatus_t
*Lsp
= pri
->lwpstat
;
3267 int what
= Lsp
->pr_what
;
3268 int err
= pri
->Errno
;
3270 int showbuf
= FALSE
;
3271 int i
= pri
->sys_args
[0]+1;
3272 long nb
= (what
== SYS_recvmsg
)? pri
->Rval1
: 32*1024;
3274 if (Pread(Proc
, &msg
, sizeof (msg
), offset
) != sizeof (msg
))
3277 if (msg
.msg_name
!= NULL
&& msg
.msg_namelen
!= 0)
3278 show_sockaddr(pri
, "msg_name",
3279 (long)msg
.msg_name
, 0, (long)msg
.msg_namelen
);
3282 * Print the iovec if the syscall was successful and the fd is
3283 * part of the set being traced.
3285 if ((what
== SYS_recvmsg
&& !err
&&
3286 prismember(&readfd
, i
)) ||
3287 (what
== SYS_sendmsg
&&
3288 prismember(&writefd
, i
)))
3291 show_iovec(pri
, (long)msg
.msg_iov
, msg
.msg_iovlen
, showbuf
, nb
);
3297 show_msghdr32(private_t
*pri
, long offset
)
3301 uint32_t msg_namelen
;
3305 const lwpstatus_t
*Lsp
= pri
->lwpstat
;
3306 int what
= Lsp
->pr_what
;
3307 int err
= pri
->Errno
;
3308 int showbuf
= FALSE
;
3309 int i
= pri
->sys_args
[0]+1;
3310 long nb
= (what
== SYS_recvmsg
)? pri
->Rval1
: 32*1024;
3312 if (Pread(Proc
, &msg
, sizeof (msg
), offset
) != sizeof (msg
))
3315 if (msg
.msg_name
!= 0 && msg
.msg_namelen
!= 0)
3316 show_sockaddr(pri
, "msg_name",
3317 (long)msg
.msg_name
, 0, (long)msg
.msg_namelen
);
3319 * Print the iovec if the syscall was successful and the fd is
3320 * part of the set being traced.
3322 if ((what
== SYS_recvmsg
&& !err
&&
3323 prismember(&readfd
, i
)) ||
3324 (what
== SYS_sendmsg
&&
3325 prismember(&writefd
, i
)))
3328 show_iovec32(pri
, (long)msg
.msg_iov
, msg
.msg_iovlen
, showbuf
, nb
);
3334 show_doorargs(private_t
*pri
, long offset
)
3338 if (Pread(Proc
, &args
, sizeof (args
), offset
) == sizeof (args
)) {
3339 (void) printf("%s\tdata_ptr=0x%lX data_size=%lu\n",
3341 (ulong_t
)args
.data_ptr
,
3342 (ulong_t
)args
.data_size
);
3343 (void) printf("%s\tdesc_ptr=0x%lX desc_num=%u\n",
3345 (ulong_t
)args
.desc_ptr
,
3347 (void) printf("%s\trbuf=0x%lX rsize=%lu\n",
3350 (ulong_t
)args
.rsize
);
3355 show_ucred_privsets(private_t
*pri
, ucred_t
*uc
)
3358 const priv_set_t
*s
;
3362 while ((sn
= priv_getsetbynum(i
++)) != NULL
) {
3363 s
= ucred_getprivset(uc
, sn
);
3368 (void) printf("%s\t%c: %s\n",
3371 str
= priv_set_to_str(s
, ',', PRIV_STR_SHORT
));
3378 show_ucred(private_t
*pri
, long offset
)
3380 ucred_t
*uc
= _ucred_alloc();
3386 sz
= Pread(Proc
, uc
, uc
->uc_size
, offset
);
3389 * A new uc_size is read, it could be smaller than the previously
3390 * value. We accept short reads that fill the whole header.
3392 if (sz
>= sizeof (ucred_t
) && sz
>= uc
->uc_size
) {
3393 (void) printf("%s\teuid=%u egid=%u\n",
3397 (void) printf("%s\truid=%u rgid=%u\n",
3401 (void) printf("%s\tpid=%d zoneid=%d\n",
3403 (int)ucred_getpid(uc
),
3404 (int)ucred_getzoneid(uc
));
3405 show_ucred_privsets(pri
, uc
);
3411 show_privset(private_t
*pri
, long offset
, size_t size
, char *label
)
3413 priv_set_t
*tmp
= priv_allocset();
3419 sz
= Pread(Proc
, tmp
, size
, offset
);
3422 char *str
= priv_set_to_str(tmp
, ',', PRIV_STR_SHORT
);
3424 (void) printf("%s\t%s%s\n", pri
->pname
, label
, str
);
3432 show_doorinfo(private_t
*pri
, long offset
)
3437 if (Pread(Proc
, &info
, sizeof (info
), offset
) != sizeof (info
))
3439 (void) printf("%s\ttarget=%d proc=0x%llX data=0x%llX\n",
3441 (int)info
.di_target
,
3444 attr
= info
.di_attributes
;
3445 (void) printf("%s\tattributes=%s\n", pri
->pname
, door_flags(pri
, attr
));
3446 (void) printf("%s\tuniquifier=%llu\n", pri
->pname
, info
.di_uniquifier
);
3450 show_doorparam(private_t
*pri
, long offset
)
3454 if (Pread(Proc
, &val
, sizeof (val
), offset
) == sizeof (val
)) {
3455 (void) printf("%s\tvalue=%lu\n",
3464 show_doorargs32(private_t
*pri
, long offset
)
3466 struct door_arg32 args
;
3468 if (Pread(Proc
, &args
, sizeof (args
), offset
) == sizeof (args
)) {
3469 (void) printf("%s\tdata_ptr=%X data_size=%u\n",
3473 (void) printf("%s\tdesc_ptr=0x%X desc_num=%u\n",
3477 (void) printf("%s\trbuf=0x%X rsize=%u\n",
3485 show_doorparam32(private_t
*pri
, long offset
)
3489 if (Pread(Proc
, &val
, sizeof (val
), offset
) == sizeof (val
)) {
3490 (void) printf("%s\tvalue=%u\n",
3499 show_doors(private_t
*pri
)
3501 switch (pri
->sys_args
[5]) {
3504 if (data_model
== PR_MODEL_LP64
)
3505 show_doorargs(pri
, (long)pri
->sys_args
[1]);
3507 show_doorargs32(pri
, (long)pri
->sys_args
[1]);
3509 show_doorargs(pri
, (long)pri
->sys_args
[1]);
3514 show_ucred(pri
, (long)pri
->sys_args
[0]);
3518 show_doorinfo(pri
, (long)pri
->sys_args
[1]);
3523 if (data_model
== PR_MODEL_LP64
)
3524 show_doorparam(pri
, (long)pri
->sys_args
[2]);
3526 show_doorparam32(pri
, (long)pri
->sys_args
[2]);
3528 show_doorparam(pri
, (long)pri
->sys_args
[2]);
3536 show_portargs(private_t
*pri
, long offset
)
3540 if (Pread(Proc
, &args
, sizeof (args
), offset
) == sizeof (args
)) {
3541 (void) printf("%s\tevents=0x%x source=%u\n",
3544 args
.portev_source
);
3545 (void) printf("%s\tobject=0x%p user=0x%p\n",
3547 (void *)args
.portev_object
,
3548 (void *)args
.portev_user
);
3556 show_portargs32(private_t
*pri
, long offset
)
3558 port_event32_t args
;
3560 if (Pread(Proc
, &args
, sizeof (args
), offset
) == sizeof (args
)) {
3561 (void) printf("%s\tevents=0x%x source=%u\n",
3564 args
.portev_source
);
3565 (void) printf("%s\tobject=0x%x user=0x%x\n",
3575 show_ports(private_t
*pri
)
3577 switch (pri
->sys_args
[0]) {
3580 if (data_model
== PR_MODEL_LP64
)
3581 show_portargs(pri
, (long)pri
->sys_args
[2]);
3583 show_portargs32(pri
, (long)pri
->sys_args
[2]);
3585 show_portargs(pri
, (long)pri
->sys_args
[2]);
3591 #define MAX_SNDFL_PRD 16
3596 show_ksendfilevec32(private_t
*pri
, int fd
,
3597 ksendfilevec32_t
*sndvec
, int sfvcnt
)
3599 ksendfilevec32_t
*snd_ptr
, snd
[MAX_SNDFL_PRD
];
3603 while (sfvcnt
> 0) {
3604 cpy_rqst
= MIN(sfvcnt
, MAX_SNDFL_PRD
);
3606 cpy_rqst
*= sizeof (snd
[0]);
3608 if (Pread(Proc
, snd
, cpy_rqst
, (uintptr_t)sndvec
) != cpy_rqst
)
3615 "sfv_fd=%d\tsfv_flag=0x%x\t"
3616 "sfv_off=%d\tsfv_len=%u\n",
3622 if (snd_ptr
->sfv_fd
== SFV_FD_SELF
&&
3623 prismember(&writefd
, fd
)) {
3625 (long)snd_ptr
->sfv_off
& 0xffffffff,
3626 (long)snd_ptr
->sfv_len
);
3629 cpy_rqst
-= sizeof (snd
[0]);
3633 sndvec
+= MAX_SNDFL_PRD
;
3639 show_ksendfilevec64(private_t
*pri
, int fd
,
3640 ksendfilevec64_t
*sndvec
, int sfvcnt
)
3642 ksendfilevec64_t
*snd_ptr
, snd
[MAX_SNDFL_PRD
];
3646 while (sfvcnt
> 0) {
3647 cpy_rqst
= MIN(sfvcnt
, MAX_SNDFL_PRD
);
3649 cpy_rqst
*= sizeof (snd
[0]);
3651 if (Pread(Proc
, snd
, cpy_rqst
, (uintptr_t)sndvec
) != cpy_rqst
)
3658 "sfv_fd=%d\tsfv_flag=0x%x\t"
3659 "sfv_off=%ld\tsfv_len=%u\n",
3665 if (snd_ptr
->sfv_fd
== SFV_FD_SELF
&&
3666 prismember(&writefd
, fd
)) {
3668 (long)snd_ptr
->sfv_off
& 0xffffffff,
3669 (long)snd_ptr
->sfv_len
);
3672 cpy_rqst
-= sizeof (snd
[0]);
3676 sndvec
+= MAX_SNDFL_PRD
;
3685 show_sendfilevec(private_t
*pri
, int fd
, sendfilevec_t
*sndvec
, int sfvcnt
)
3687 sendfilevec_t
*snd_ptr
, snd
[MAX_SNDFL_PRD
];
3691 if (data_model
!= PR_MODEL_LP64
) {
3692 show_ksendfilevec32(pri
, fd
,
3693 (ksendfilevec32_t
*)sndvec
, sfvcnt
);
3698 while (sfvcnt
> 0) {
3699 cpy_rqst
= MIN(sfvcnt
, MAX_SNDFL_PRD
);
3701 cpy_rqst
*= sizeof (snd
[0]);
3703 if (Pread(Proc
, snd
, cpy_rqst
, (uintptr_t)sndvec
) != cpy_rqst
)
3710 "sfv_fd=%d\tsfv_flag=0x%x\t"
3711 "sfv_off=%ld\tsfv_len=%lu\n",
3715 (ulong_t
)snd_ptr
->sfv_len
);
3717 if (snd_ptr
->sfv_fd
== SFV_FD_SELF
&&
3718 prismember(&writefd
, fd
)) {
3719 showbuffer(pri
, (long)snd_ptr
->sfv_off
,
3720 (long)snd_ptr
->sfv_len
);
3723 cpy_rqst
-= sizeof (snd
[0]);
3727 sndvec
+= MAX_SNDFL_PRD
;
3734 show_sendfilevec64(private_t
*pri
, int fd
, sendfilevec64_t
*sndvec
, int sfvcnt
)
3736 sendfilevec64_t
*snd_ptr
, snd
[MAX_SNDFL_PRD
];
3740 if (data_model
!= PR_MODEL_LP64
) {
3741 show_ksendfilevec64(pri
, fd
,
3742 (ksendfilevec64_t
*)sndvec
, sfvcnt
);
3748 while (sfvcnt
> 0) {
3749 cpy_rqst
= MIN(sfvcnt
, MAX_SNDFL_PRD
);
3751 cpy_rqst
*= sizeof (snd
[0]);
3753 if (Pread(Proc
, snd
, cpy_rqst
, (uintptr_t)sndvec
) != cpy_rqst
)
3761 "sfv_fd=%d\tsfv_flag=0x%x\t"
3762 "sfv_off=%ld\tsfv_len=%lu\n",
3764 "sfv_fd=%d\tsfv_flag=0x%x\t"
3765 "sfv_off=%lld\tsfv_len=%lu\n",
3770 (ulong_t
)snd_ptr
->sfv_len
);
3772 if (snd_ptr
->sfv_fd
== SFV_FD_SELF
&&
3773 prismember(&writefd
, fd
)) {
3774 showbuffer(pri
, (long)snd_ptr
->sfv_off
,
3775 (long)snd_ptr
->sfv_len
);
3778 cpy_rqst
-= sizeof (snd
[0]);
3782 sndvec
+= MAX_SNDFL_PRD
;
3788 show_memcntl_mha(private_t
*pri
, long offset
)
3790 struct memcntl_mha mha
;
3791 const char *s
= NULL
;
3793 if (Pread(Proc
, &mha
, sizeof (mha
), offset
) == sizeof (mha
)) {
3794 switch (mha
.mha_cmd
) {
3795 case MHA_MAPSIZE_VA
: s
= "MHA_MAPSIZE_VA"; break;
3796 case MHA_MAPSIZE_BSSBRK
: s
= "MHA_MAPSIZE_BSSBRK"; break;
3797 case MHA_MAPSIZE_STACK
: s
= "MHA_MAPSIZE_STACK"; break;
3800 (void) printf("%s\tmha_cmd=%s mha_flags=0x%x"
3801 " mha_pagesize=%lu\n",
3802 pri
->pname
, s
, mha
.mha_flags
,
3803 (ulong_t
)mha
.mha_pagesize
);
3805 (void) printf("%s\tmha_cmd=0x%.8x mha_flags=0x%x"
3806 " mha_pagesize=%lu\n",
3807 pri
->pname
, mha
.mha_cmd
, mha
.mha_flags
,
3808 (ulong_t
)mha
.mha_pagesize
);
3815 show_memcntl_mha32(private_t
*pri
, long offset
)
3817 struct memcntl_mha32 mha32
;
3818 const char *s
= NULL
;
3820 if (Pread(Proc
, &mha32
, sizeof (mha32
), offset
) ==
3822 switch (mha32
.mha_cmd
) {
3823 case MHA_MAPSIZE_VA
: s
= "MHA_MAPSIZE_VA"; break;
3824 case MHA_MAPSIZE_BSSBRK
: s
= "MHA_MAPSIZE_BSSBRK"; break;
3825 case MHA_MAPSIZE_STACK
: s
= "MHA_MAPSIZE_STACK"; break;
3828 (void) printf("%s\tmha_cmd=%s mha_flags=0x%x"
3829 " mha_pagesize=%u\n",
3830 pri
->pname
, s
, mha32
.mha_flags
, mha32
.mha_pagesize
);
3832 (void) printf("%s\tmha_cmd=0x%.8x mha_flags=0x%x"
3833 " mha_pagesize=%u\n",
3834 pri
->pname
, mha32
.mha_cmd
, mha32
.mha_flags
,
3835 mha32
.mha_pagesize
);
3842 show_memcntl(private_t
*pri
)
3845 if ((int)pri
->sys_args
[2] != MC_HAT_ADVISE
)
3848 if (data_model
== PR_MODEL_LP64
)
3849 show_memcntl_mha(pri
, (long)pri
->sys_args
[3]);
3851 show_memcntl_mha32(pri
, (long)pri
->sys_args
[3]);
3853 show_memcntl_mha(pri
, (long)pri
->sys_args
[3]);
3858 show_ids(private_t
*pri
, long offset
, int count
)
3860 id_t buf
[MYBUFSIZ
/ sizeof (id_t
)];
3862 int serial
= (count
> MYBUFSIZ
/ 48);
3867 /* enter region of lengthy output */
3871 while (count
> 0 && !interrupt
) {
3872 ssize_t nb
= (count
* sizeof (id_t
) < MYBUFSIZ
)?
3873 count
* sizeof (id_t
) : MYBUFSIZ
;
3875 if ((nb
= Pread(Proc
, &buf
[0], (size_t)nb
, offset
)) < 0 ||
3880 while (!interrupt
&& nb
>= sizeof (id_t
)) {
3881 (void) printf("%s\t%8d\n", pri
->pname
, (int)*idp
);
3882 offset
+= sizeof (id_t
);
3883 nb
-= sizeof (id_t
);
3889 /* exit region of lengthy output */
3895 show_ntp_gettime(private_t
*pri
)
3897 struct ntptimeval ntv
;
3900 if (pri
->sys_nargs
< 1 || (offset
= pri
->sys_args
[0]) == 0)
3903 if (data_model
== PR_MODEL_NATIVE
) {
3904 if (Pread(Proc
, &ntv
, sizeof (ntv
), offset
)
3908 struct ntptimeval32 ntv32
;
3910 if (Pread(Proc
, &ntv32
, sizeof (ntv32
), offset
)
3914 TIMEVAL32_TO_TIMEVAL(&ntv
.time
, &ntv32
.time
);
3915 ntv
.maxerror
= ntv32
.maxerror
;
3916 ntv
.esterror
= ntv32
.esterror
;
3919 (void) printf("\ttime: %ld.%6.6ld sec\n",
3920 ntv
.time
.tv_sec
, ntv
.time
.tv_usec
);
3921 (void) printf("\tmaxerror: %11d usec\n", ntv
.maxerror
);
3922 (void) printf("\testerror: %11d usec\n", ntv
.esterror
);
3926 get_timex_modes(private_t
*pri
, uint32_t val
)
3928 char *str
= pri
->code_buf
;
3932 if (val
& MOD_OFFSET
)
3933 used
= strlcat(str
, "|MOD_OFFSET", sizeof (pri
->code_buf
));
3934 if (val
& MOD_FREQUENCY
)
3935 used
= strlcat(str
, "|MOD_FREQUENCY", sizeof (pri
->code_buf
));
3936 if (val
& MOD_MAXERROR
)
3937 used
= strlcat(str
, "|MOD_MAXERROR", sizeof (pri
->code_buf
));
3938 if (val
& MOD_ESTERROR
)
3939 used
= strlcat(str
, "|MOD_ESTERROR", sizeof (pri
->code_buf
));
3940 if (val
& MOD_STATUS
)
3941 used
= strlcat(str
, "|MOD_STATUS", sizeof (pri
->code_buf
));
3942 if (val
& MOD_TIMECONST
)
3943 used
= strlcat(str
, "|MOD_TIMECONST", sizeof (pri
->code_buf
));
3945 used
= strlcat(str
, "|MOD_CLKB", sizeof (pri
->code_buf
));
3947 used
= strlcat(str
, "|MOD_CLKA", sizeof (pri
->code_buf
));
3949 if (used
== 0 || used
>= sizeof (pri
->code_buf
))
3950 (void) snprintf(str
, sizeof (pri
->code_buf
), " 0x%.4x", val
);
3956 get_timex_status(private_t
*pri
, int32_t val
)
3958 char *str
= pri
->code_buf
;
3963 used
= strlcat(str
, "|STA_PLL", sizeof (pri
->code_buf
));
3964 if (val
& STA_PPSFREQ
)
3965 used
= strlcat(str
, "|STA_PPSFREQ", sizeof (pri
->code_buf
));
3966 if (val
& STA_PPSTIME
)
3967 used
= strlcat(str
, "|STA_PPSTIME", sizeof (pri
->code_buf
));
3969 used
= strlcat(str
, "|STA_FLL", sizeof (pri
->code_buf
));
3972 used
= strlcat(str
, "|STA_INS", sizeof (pri
->code_buf
));
3974 used
= strlcat(str
, "|STA_DEL", sizeof (pri
->code_buf
));
3975 if (val
& STA_UNSYNC
)
3976 used
= strlcat(str
, "|STA_UNSYNC", sizeof (pri
->code_buf
));
3977 if (val
& STA_FREQHOLD
)
3978 used
= strlcat(str
, "|STA_FREQHOLD", sizeof (pri
->code_buf
));
3980 if (val
& STA_PPSSIGNAL
)
3981 used
= strlcat(str
, "|STA_PPSSIGNAL", sizeof (pri
->code_buf
));
3982 if (val
& STA_PPSJITTER
)
3983 used
= strlcat(str
, "|STA_PPSJITTER", sizeof (pri
->code_buf
));
3984 if (val
& STA_PPSWANDER
)
3985 used
= strlcat(str
, "|STA_PPSWANDER", sizeof (pri
->code_buf
));
3986 if (val
& STA_PPSERROR
)
3987 used
= strlcat(str
, "|STA_PPSERROR", sizeof (pri
->code_buf
));
3989 if (val
& STA_CLOCKERR
)
3990 used
= strlcat(str
, "|STA_CLOCKERR", sizeof (pri
->code_buf
));
3992 if (used
== 0 || used
>= sizeof (pri
->code_buf
))
3993 (void) snprintf(str
, sizeof (pri
->code_buf
), " 0x%.4x", val
);
3999 show_ntp_adjtime(private_t
*pri
)
4004 if (pri
->sys_nargs
< 1 || (offset
= pri
->sys_args
[0]) == 0)
4007 if (Pread(Proc
, &timex
, sizeof (timex
), offset
) != sizeof (timex
))
4010 (void) printf("\tmodes: %s\n", get_timex_modes(pri
, timex
.modes
));
4011 (void) printf("\toffset: %11d usec\n", timex
.offset
);
4012 (void) printf("\tfreq: %11d scaled ppm\n", timex
.freq
);
4013 (void) printf("\tmaxerror: %11d usec\n", timex
.maxerror
);
4014 (void) printf("\testerror: %11d usec\n", timex
.esterror
);
4015 (void) printf("\tstatus: %s\n", get_timex_status(pri
, timex
.status
));
4016 (void) printf("\tconstant: %11d\n", timex
.constant
);
4017 (void) printf("\tprecision: %11d usec\n", timex
.precision
);
4018 (void) printf("\ttolerance: %11d scaled ppm\n", timex
.tolerance
);
4019 (void) printf("\tppsfreq: %11d scaled ppm\n", timex
.ppsfreq
);
4020 (void) printf("\tjitter: %11d usec\n", timex
.jitter
);
4021 (void) printf("\tshift: %11d sec\n", timex
.shift
);
4022 (void) printf("\tstabil: %11d scaled ppm\n", timex
.stabil
);
4023 (void) printf("\tjitcnt: %11d\n", timex
.jitcnt
);
4024 (void) printf("\tcalcnt: %11d\n", timex
.calcnt
);
4025 (void) printf("\terrcnt: %11d\n", timex
.errcnt
);
4026 (void) printf("\tstbcnt: %11d\n", timex
.stbcnt
);
4030 show_getrusage(long offset
)
4033 if (Pread(Proc
, &r
, sizeof (r
), offset
) != sizeof (r
))
4035 (void) printf("\t user time: %ld.%6.6ld sec\n",
4037 r
.ru_utime
.tv_usec
);
4038 (void) printf("\t system time: %ld.%6.6ld sec\n",
4040 r
.ru_stime
.tv_usec
);
4041 (void) printf("\t max rss: <unimpl> %ld\n",
4043 (void) printf("\t shared data: <unimpl> %ld\n",
4045 (void) printf("\t unshared data: <unimpl> %ld\n",
4047 (void) printf("\t unshared stack: <unimpl> %ld\n",
4049 (void) printf("\t minor faults: %ld\n",
4051 (void) printf("\t major faults: %ld\n",
4053 (void) printf("\t # of swaps: %ld\n",
4055 (void) printf("\t blocked inputs: %ld\n",
4057 (void) printf("\t blocked outputs: %ld\n",
4059 (void) printf("\t msgs sent: %ld\n",
4061 (void) printf("\t msgs rcv'd: %ld\n",
4063 (void) printf("\t signals rcv'd: %ld\n",
4065 (void) printf("\tvol cntxt swtchs: %ld\n",
4067 (void) printf("\tinv cntxt swtchs: %ld\n",
4073 show_getrusage32(long offset
)
4076 if (Pread(Proc
, &r
, sizeof (r
), offset
) != sizeof (r
))
4078 (void) printf("\t user time: %d.%6.6d sec\n",
4080 r
.ru_utime
.tv_usec
);
4081 (void) printf("\t system time: %d.%6.6d sec\n",
4083 r
.ru_stime
.tv_usec
);
4084 (void) printf("\t max rss: <unimpl> %d\n",
4086 (void) printf("\t shared data: <unimpl> %d\n",
4088 (void) printf("\t unshared data: <unimpl> %d\n",
4090 (void) printf("\t unshared stack: <unimpl> %d\n",
4092 (void) printf("\t minor faults: %d\n",
4094 (void) printf("\t major faults: %d\n",
4096 (void) printf("\t # of swaps: %d\n",
4098 (void) printf("\t blocked inputs: %d\n",
4100 (void) printf("\t blocked outputs: %d\n",
4102 (void) printf("\t msgs sent: %d\n",
4104 (void) printf("\t msgs rcv'd: %d\n",
4106 (void) printf("\t signals rcv'd: %d\n",
4108 (void) printf("\tvol cntxt swtchs: %d\n",
4110 (void) printf("\tinv cntxt swtchs: %d\n",
4116 * Utility function to print a packed nvlist by unpacking
4117 * and calling the libnvpair pretty printer. Frees all
4118 * allocated memory internally.
4121 show_packed_nvlist(private_t
*pri
, uintptr_t offset
, size_t size
)
4123 nvlist_t
*nvl
= NULL
;
4127 if ((offset
== 0) || (size
== 0)) {
4131 buf
= my_malloc(size
, "nvlist decode buffer");
4132 readsize
= Pread(Proc
, buf
, size
, offset
);
4133 if (readsize
!= size
) {
4134 (void) printf("%s\t<?>", pri
->pname
);
4138 result
= nvlist_unpack(buf
, size
, &nvl
, 0);
4140 dump_nvlist(nvl
, 8);
4143 (void) printf("%s\tunpack of nvlist"
4144 " failed: %d\n", pri
->pname
, result
);
4151 show_zone_create_args(private_t
*pri
, long offset
)
4154 char zone_name
[ZONENAME_MAX
];
4155 char zone_root
[MAXPATHLEN
];
4156 char *zone_zfs
= NULL
;
4158 if (Pread(Proc
, &args
, sizeof (args
), offset
) == sizeof (args
)) {
4160 if (Pread_string(Proc
, zone_name
, sizeof (zone_name
),
4161 (uintptr_t)args
.zone_name
) == -1)
4162 (void) strcpy(zone_name
, "<?>");
4164 if (Pread_string(Proc
, zone_root
, sizeof (zone_root
),
4165 (uintptr_t)args
.zone_root
) == -1)
4166 (void) strcpy(zone_root
, "<?>");
4168 if (args
.zfsbufsz
> 0) {
4169 zone_zfs
= malloc(MIN(4, args
.zfsbufsz
));
4170 if (zone_zfs
!= NULL
) {
4171 if (Pread(Proc
, zone_zfs
, args
.zfsbufsz
,
4172 (uintptr_t)args
.zfsbuf
) == -1)
4173 (void) strcpy(zone_zfs
, "<?>");
4179 (void) printf("%s\t zone_name: %s\n", pri
->pname
,
4181 (void) printf("%s\t zone_root: %s\n", pri
->pname
,
4184 show_privset(pri
, (uintptr_t)args
.zone_privs
,
4185 args
.zone_privssz
, " zone_privs: ");
4187 (void) printf("%s\t rctlbuf: 0x%p\n", pri
->pname
,
4188 (void *)args
.rctlbuf
);
4189 (void) printf("%s\t rctlbufsz: %lu\n", pri
->pname
,
4190 (ulong_t
)args
.rctlbufsz
);
4192 show_packed_nvlist(pri
, (uintptr_t)args
.rctlbuf
,
4195 (void) printf("%s\t zfs: %s\n", pri
->pname
, zone_zfs
);
4197 (void) printf("%s\textended_error: 0x%p\n", pri
->pname
,
4198 (void *)args
.extended_error
);
4200 if (args
.zfsbufsz
> 0)
4209 show_zone_create_args32(private_t
*pri
, long offset
)
4212 char zone_name
[ZONENAME_MAX
];
4213 char zone_root
[MAXPATHLEN
];
4214 char *zone_zfs
= NULL
;
4216 if (Pread(Proc
, &args
, sizeof (args
), offset
) == sizeof (args
)) {
4218 if (Pread_string(Proc
, zone_name
, sizeof (zone_name
),
4219 (uintptr_t)args
.zone_name
) == -1)
4220 (void) strcpy(zone_name
, "<?>");
4222 if (Pread_string(Proc
, zone_root
, sizeof (zone_root
),
4223 (uintptr_t)args
.zone_root
) == -1)
4224 (void) strcpy(zone_root
, "<?>");
4226 if (args
.zfsbufsz
> 0) {
4227 zone_zfs
= malloc(MIN(4, args
.zfsbufsz
));
4228 if (zone_zfs
!= NULL
) {
4229 if (Pread(Proc
, zone_zfs
, args
.zfsbufsz
,
4230 (uintptr_t)args
.zfsbuf
) == -1)
4231 (void) strcpy(zone_zfs
, "<?>");
4237 (void) printf("%s\t zone_name: %s\n", pri
->pname
,
4239 (void) printf("%s\t zone_root: %s\n", pri
->pname
,
4242 show_privset(pri
, (uintptr_t)args
.zone_privs
,
4243 args
.zone_privssz
, " zone_privs: ");
4245 (void) printf("%s\t rctlbuf: 0x%x\n", pri
->pname
,
4246 (caddr32_t
)args
.rctlbuf
);
4247 (void) printf("%s\t rctlbufsz: %lu\n", pri
->pname
,
4248 (ulong_t
)args
.rctlbufsz
);
4250 show_packed_nvlist(pri
, (uintptr_t)args
.rctlbuf
,
4253 (void) printf("%s\t zfs: %s\n", pri
->pname
, zone_zfs
);
4255 (void) printf("%s\textended_error: 0x%x\n", pri
->pname
,
4256 (caddr32_t
)args
.extended_error
);
4258 if (args
.zfsbufsz
> 0)
4266 show_zones(private_t
*pri
)
4268 switch (pri
->sys_args
[0]) {
4271 if (data_model
== PR_MODEL_LP64
)
4272 show_zone_create_args(pri
, (long)pri
->sys_args
[1]);
4274 show_zone_create_args32(pri
, (long)pri
->sys_args
[1]);
4276 show_zone_create_args(pri
, (long)pri
->sys_args
[1]);
4283 show_rctlblk(private_t
*pri
, long _rctlblk
)
4286 int size
= rctlblk_size();
4290 blk
= my_malloc(size
, "rctlblk decode buffer");
4291 readsize
= Pread(Proc
, blk
, size
, _rctlblk
);
4292 if (readsize
!= size
) {
4293 (void) printf("%s\t\t<?>", pri
->pname
);
4295 (void) printf("%s\t\t Privilege: 0x%x\n",
4297 rctlblk_get_privilege(blk
));
4298 (void) printf("%s\t\t Value: %lld\n",
4300 rctlblk_get_value(blk
));
4301 (void) printf("%s\t\tEnforced Value: %lld\n",
4303 rctlblk_get_enforced_value(blk
));
4307 act
= rctlblk_get_local_action(blk
, &sig
);
4309 s
= rctl_local_action(pri
, act
);
4311 (void) printf("%s\t\t Local action: 0x%x\n",
4314 (void) printf("%s\t\t Local action: %s\n",
4318 if (act
& RCTL_LOCAL_SIGNAL
) {
4319 (void) printf("%s\t\t "
4321 pri
->pname
, signame(pri
, sig
));
4325 s
= rctl_local_flags(pri
, rctlblk_get_local_flags(blk
));
4327 (void) printf("%s\t\t Local flags: 0x%x\n",
4328 pri
->pname
, rctlblk_get_local_flags(blk
));
4330 (void) printf("%s\t\t Local flags: %s\n",
4335 (void) printf("%s\t\t Recipient PID: %d\n",
4337 rctlblk_get_recipient_pid(blk
));
4339 (void) printf("%s\t\t Recipient PID: %ld\n",
4341 rctlblk_get_recipient_pid(blk
));
4343 (void) printf("%s\t\t Firing Time: %lld\n",
4345 rctlblk_get_firing_time(blk
));
4351 show_rctls(private_t
*pri
)
4355 switch (pri
->sys_args
[0]) {
4356 case 0: /* getrctl */
4357 case 1: /* setrctl */
4359 * If these offsets look a little odd, remember that they're
4360 * into the _raw_ system call
4362 (void) printf("%s\tOld rctlblk: 0x%lx\n", pri
->pname
,
4364 if (pri
->sys_args
[2] != 0) {
4365 show_rctlblk(pri
, pri
->sys_args
[2]);
4367 (void) printf("%s\tNew rctlblk: 0x%lx\n", pri
->pname
,
4369 if (pri
->sys_args
[3] != 0) {
4370 show_rctlblk(pri
, pri
->sys_args
[3]);
4373 case 4: /* setprojrctl */
4374 for (entry
= 0; entry
< pri
->sys_args
[4]; entry
++) {
4375 (void) printf("%s\tNew rctlblk[%d]: 0x%lx\n",
4377 (long)RCTLBLK_INC(pri
->sys_args
[3], entry
));
4378 if (RCTLBLK_INC(pri
->sys_args
[3], entry
) != NULL
) {
4380 (long)RCTLBLK_INC(pri
->sys_args
[3], entry
));
4387 show_utimesys(private_t
*pri
)
4389 switch (pri
->sys_args
[0]) {
4390 case 0: /* futimens() */
4391 if (pri
->sys_nargs
> 2)
4392 show_utimens(pri
, (long)pri
->sys_args
[2]);
4394 case 1: /* utimensat */
4395 if (pri
->sys_nargs
> 3)
4396 show_utimens(pri
, (long)pri
->sys_args
[3]);
4398 default: /* unexpected subcode */
4405 show_sockconfig_filter_prop32(private_t
*pri
, long addr
)
4407 struct sockconfig_filter_props32 props
;
4408 const char *s
= NULL
;
4409 char buf
[MAX(FILNAME_MAX
, MODMAXNAMELEN
)];
4410 sof_socktuple32_t
*tup
;
4414 if (Pread(Proc
, &props
, sizeof (props
), addr
) == sizeof (props
)) {
4415 if (Pread_string(Proc
, buf
, sizeof (buf
),
4416 (uintptr_t)props
.sfp_modname
) == -1)
4417 (void) strcpy(buf
, "<?>");
4418 (void) printf("%s\tmodule name: %s\n", pri
->pname
, buf
);
4419 (void) printf("%s\tattach semantics: %s", pri
->pname
,
4420 props
.sfp_autoattach
? "automatic" : "progammatic");
4421 if (props
.sfp_autoattach
) {
4423 switch (props
.sfp_hint
) {
4424 case SOF_HINT_TOP
: s
= "top"; break;
4425 case SOF_HINT_BOTTOM
: s
= "bottom"; break;
4426 case SOF_HINT_BEFORE
:
4427 case SOF_HINT_AFTER
:
4428 s
= (props
.sfp_hint
== SOF_HINT_BEFORE
) ?
4430 if (Pread_string(Proc
, buf
, sizeof (buf
),
4431 (uintptr_t)props
.sfp_hintarg
) == -1)
4432 (void) strcpy(buf
, "<?>");
4435 (void) printf(", placement: %s %s", s
, buf
);
4438 (void) printf("\n");
4439 (void) printf("%s\tsocket tuples:\n", pri
->pname
);
4440 if (props
.sfp_socktuple_cnt
== 0) {
4441 (void) printf("\t\t<empty>\n");
4444 sz
= props
.sfp_socktuple_cnt
* sizeof (*tup
);
4445 tup
= my_malloc(sz
, "socket tuple buffer");
4446 if (Pread(Proc
, tup
, sz
, (uintptr_t)props
.sfp_socktuple
) == sz
)
4447 for (i
= 0; i
< props
.sfp_socktuple_cnt
; i
++) {
4449 "\t\tfamily: %d, type: %d, proto: %d\n",
4450 tup
[i
].sofst_family
, tup
[i
].sofst_type
,
4451 tup
[i
].sofst_protocol
);
4457 show_sockconfig_filter_prop(private_t
*pri
, long addr
)
4459 struct sockconfig_filter_props props
;
4460 const char *s
= NULL
;
4461 char buf
[MAX(FILNAME_MAX
, MODMAXNAMELEN
)];
4462 sof_socktuple_t
*tup
;
4466 if (Pread(Proc
, &props
, sizeof (props
), addr
) == sizeof (props
)) {
4467 if (Pread_string(Proc
, buf
, sizeof (buf
),
4468 (uintptr_t)props
.sfp_modname
) == -1)
4469 (void) strcpy(buf
, "<?>");
4470 (void) printf("%s\tmodule name: %s\n", pri
->pname
, buf
);
4471 (void) printf("%s\tattach semantics: %s", pri
->pname
,
4472 props
.sfp_autoattach
? "automatic" : "progammatic");
4473 if (props
.sfp_autoattach
) {
4475 switch (props
.sfp_hint
) {
4476 case SOF_HINT_TOP
: s
= "top"; break;
4477 case SOF_HINT_BOTTOM
: s
= "bottom"; break;
4478 case SOF_HINT_BEFORE
:
4479 case SOF_HINT_AFTER
:
4480 s
= (props
.sfp_hint
== SOF_HINT_BEFORE
) ?
4482 if (Pread_string(Proc
, buf
, sizeof (buf
),
4483 (uintptr_t)props
.sfp_hintarg
) == -1)
4484 (void) strcpy(buf
, "<?>");
4487 (void) printf(", placement: %s", s
);
4490 (void) printf("\n");
4491 (void) printf("%s\tsocket tuples:\n", pri
->pname
);
4492 if (props
.sfp_socktuple_cnt
== 0) {
4493 (void) printf("\t\t<empty>\n");
4496 sz
= props
.sfp_socktuple_cnt
* sizeof (*tup
);
4497 tup
= my_malloc(sz
, "socket tuple buffer");
4498 if (Pread(Proc
, tup
, sz
, (uintptr_t)props
.sfp_socktuple
) == sz
)
4499 for (i
= 0; i
< props
.sfp_socktuple_cnt
; i
++) {
4501 "\t\tfamily: %d, type: %d, proto: %d\n",
4502 tup
[i
].sofst_family
, tup
[i
].sofst_type
,
4503 tup
[i
].sofst_protocol
);
4509 show_sockconfig(private_t
*pri
)
4511 switch (pri
->sys_args
[0]) {
4512 case SOCKCONFIG_ADD_FILTER
:
4514 if (data_model
== PR_MODEL_LP64
)
4515 show_sockconfig_filter_prop(pri
,
4516 (long)pri
->sys_args
[2]);
4518 show_sockconfig_filter_prop32(pri
,
4519 (long)pri
->sys_args
[2]);
4521 show_sockconfig_filter_prop(pri
, (long)pri
->sys_args
[2]);
4530 show_zfs_ioc(private_t
*pri
, long addr
)
4532 static const zfs_share_t zero_share
= {0};
4533 static const dmu_objset_stats_t zero_objstats
= {0};
4534 static const struct drr_begin zero_drrbegin
= {0};
4535 static const zinject_record_t zero_injectrec
= {0};
4536 static const zfs_stat_t zero_zstat
= {0};
4539 if (Pread(Proc
, &zc
, sizeof (zc
), addr
) != sizeof (zc
)) {
4540 (void) printf(" zfs_ioctl read failed\n");
4545 (void) printf(" zc_name=%s\n", zc
.zc_name
);
4547 (void) printf(" zc_value=%s\n", zc
.zc_value
);
4548 if (zc
.zc_string
[0])
4549 (void) printf(" zc_string=%s\n", zc
.zc_string
);
4550 if (zc
.zc_guid
!= 0) {
4551 (void) printf(" zc_guid=%llu\n",
4552 (u_longlong_t
)zc
.zc_guid
);
4554 if (zc
.zc_nvlist_conf_size
) {
4555 (void) printf(" nvlist_conf:\n");
4556 show_packed_nvlist(pri
, zc
.zc_nvlist_conf
,
4557 zc
.zc_nvlist_conf_size
);
4559 if (zc
.zc_nvlist_src_size
) {
4560 (void) printf(" nvlist_src:\n");
4561 show_packed_nvlist(pri
, zc
.zc_nvlist_src
,
4562 zc
.zc_nvlist_src_size
);
4564 if (zc
.zc_nvlist_dst_size
) {
4565 (void) printf(" nvlist_dst:\n");
4566 show_packed_nvlist(pri
, zc
.zc_nvlist_dst
,
4567 zc
.zc_nvlist_dst_size
);
4569 if (zc
.zc_cookie
!= 0) {
4570 (void) printf(" zc_cookie=%llu\n",
4571 (u_longlong_t
)zc
.zc_cookie
);
4573 if (zc
.zc_objset_type
!= 0) {
4574 (void) printf(" zc_objset_type=%llu\n",
4575 (u_longlong_t
)zc
.zc_objset_type
);
4577 if (zc
.zc_perm_action
!= 0) {
4578 (void) printf(" zc_perm_action=%llu\n",
4579 (u_longlong_t
)zc
.zc_perm_action
);
4581 if (zc
.zc_history
!= 0) {
4582 (void) printf(" zc_history=%llu\n",
4583 (u_longlong_t
)zc
.zc_history
);
4585 if (zc
.zc_obj
!= 0) {
4586 (void) printf(" zc_obj=%llu\n",
4587 (u_longlong_t
)zc
.zc_obj
);
4589 if (zc
.zc_iflags
!= 0) {
4590 (void) printf(" zc_obj=0x%llx\n",
4591 (u_longlong_t
)zc
.zc_iflags
);
4594 if (memcmp(&zc
.zc_share
, &zero_share
, sizeof (zc
.zc_share
))) {
4595 zfs_share_t
*z
= &zc
.zc_share
;
4596 (void) printf(" zc_share:\n");
4597 if (z
->z_exportdata
) {
4598 (void) printf("\tz_exportdata=0x%llx\n",
4599 (u_longlong_t
)z
->z_exportdata
);
4601 if (z
->z_sharedata
) {
4602 (void) printf("\tz_sharedata=0x%llx\n",
4603 (u_longlong_t
)z
->z_sharedata
);
4605 if (z
->z_sharetype
) {
4606 (void) printf("\tz_sharetype=%llu\n",
4607 (u_longlong_t
)z
->z_sharetype
);
4609 if (z
->z_sharemax
) {
4610 (void) printf("\tz_sharemax=%llu\n",
4611 (u_longlong_t
)z
->z_sharemax
);
4615 if (memcmp(&zc
.zc_objset_stats
, &zero_objstats
,
4616 sizeof (zc
.zc_objset_stats
))) {
4617 dmu_objset_stats_t
*dds
= &zc
.zc_objset_stats
;
4618 (void) printf(" zc_objset_stats:\n");
4619 if (dds
->dds_num_clones
) {
4620 (void) printf("\tdds_num_clones=%llu\n",
4621 (u_longlong_t
)dds
->dds_num_clones
);
4623 if (dds
->dds_creation_txg
) {
4624 (void) printf("\tdds_creation_txg=%llu\n",
4625 (u_longlong_t
)dds
->dds_creation_txg
);
4627 if (dds
->dds_guid
) {
4628 (void) printf("\tdds_guid=%llu\n",
4629 (u_longlong_t
)dds
->dds_guid
);
4632 (void) printf("\tdds_type=%u\n", dds
->dds_type
);
4633 if (dds
->dds_is_snapshot
) {
4634 (void) printf("\tdds_is_snapshot=%u\n",
4635 dds
->dds_is_snapshot
);
4637 if (dds
->dds_inconsistent
) {
4638 (void) printf("\tdds_inconsitent=%u\n",
4639 dds
->dds_inconsistent
);
4641 if (dds
->dds_origin
[0]) {
4642 (void) printf("\tdds_origin=%s\n", dds
->dds_origin
);
4646 if (memcmp(&zc
.zc_begin_record
, &zero_drrbegin
,
4647 sizeof (zc
.zc_begin_record
))) {
4648 struct drr_begin
*drr
= &zc
.zc_begin_record
.drr_u
.drr_begin
;
4649 (void) printf(" zc_begin_record:\n");
4650 if (drr
->drr_magic
) {
4651 (void) printf("\tdrr_magic=%llu\n",
4652 (u_longlong_t
)drr
->drr_magic
);
4654 if (drr
->drr_versioninfo
) {
4655 (void) printf("\tdrr_versioninfo=%llu\n",
4656 (u_longlong_t
)drr
->drr_versioninfo
);
4658 if (drr
->drr_creation_time
) {
4659 (void) printf("\tdrr_creation_time=%llu\n",
4660 (u_longlong_t
)drr
->drr_creation_time
);
4663 (void) printf("\tdrr_type=%u\n", drr
->drr_type
);
4665 (void) printf("\tdrr_flags=0x%x\n", drr
->drr_flags
);
4666 if (drr
->drr_toguid
) {
4667 (void) printf("\tdrr_toguid=%llu\n",
4668 (u_longlong_t
)drr
->drr_toguid
);
4670 if (drr
->drr_fromguid
) {
4671 (void) printf("\tdrr_fromguid=%llu\n",
4672 (u_longlong_t
)drr
->drr_fromguid
);
4674 if (drr
->drr_toname
[0]) {
4675 (void) printf("\tdrr_toname=%s\n", drr
->drr_toname
);
4679 if (memcmp(&zc
.zc_inject_record
, &zero_injectrec
,
4680 sizeof (zc
.zc_inject_record
))) {
4681 zinject_record_t
*zi
= &zc
.zc_inject_record
;
4682 (void) printf(" zc_inject_record:\n");
4683 if (zi
->zi_objset
) {
4684 (void) printf("\tzi_objset=%llu\n",
4685 (u_longlong_t
)zi
->zi_objset
);
4687 if (zi
->zi_object
) {
4688 (void) printf("\tzi_object=%llu\n",
4689 (u_longlong_t
)zi
->zi_object
);
4692 (void) printf("\tzi_start=%llu\n",
4693 (u_longlong_t
)zi
->zi_start
);
4696 (void) printf("\tzi_end=%llu\n",
4697 (u_longlong_t
)zi
->zi_end
);
4700 (void) printf("\tzi_guid=%llu\n",
4701 (u_longlong_t
)zi
->zi_guid
);
4704 (void) printf("\tzi_level=%lu\n",
4705 (ulong_t
)zi
->zi_level
);
4708 (void) printf("\tzi_error=%lu\n",
4709 (ulong_t
)zi
->zi_error
);
4712 (void) printf("\tzi_type=%llu\n",
4713 (u_longlong_t
)zi
->zi_type
);
4716 (void) printf("\tzi_freq=%lu\n",
4717 (ulong_t
)zi
->zi_freq
);
4719 if (zi
->zi_failfast
) {
4720 (void) printf("\tzi_failfast=%lu\n",
4721 (ulong_t
)zi
->zi_failfast
);
4724 (void) printf("\tzi_func=%s\n", zi
->zi_func
);
4725 if (zi
->zi_iotype
) {
4726 (void) printf("\tzi_iotype=%lu\n",
4727 (ulong_t
)zi
->zi_iotype
);
4729 if (zi
->zi_duration
) {
4730 (void) printf("\tzi_duration=%ld\n",
4731 (long)zi
->zi_duration
);
4734 (void) printf("\tzi_timer=%llu\n",
4735 (u_longlong_t
)zi
->zi_timer
);
4739 if (zc
.zc_defer_destroy
) {
4740 (void) printf(" zc_defer_destroy=%d\n",
4741 (int)zc
.zc_defer_destroy
);
4744 (void) printf(" zc_flags=0x%x\n",
4747 if (zc
.zc_action_handle
) {
4748 (void) printf(" zc_action_handle=%llu\n",
4749 (u_longlong_t
)zc
.zc_action_handle
);
4751 if (zc
.zc_cleanup_fd
>= 0)
4752 (void) printf(" zc_cleanup_fd=%d\n", zc
.zc_cleanup_fd
);
4753 if (zc
.zc_sendobj
) {
4754 (void) printf(" zc_sendobj=%llu\n",
4755 (u_longlong_t
)zc
.zc_sendobj
);
4757 if (zc
.zc_fromobj
) {
4758 (void) printf(" zc_fromobj=%llu\n",
4759 (u_longlong_t
)zc
.zc_fromobj
);
4761 if (zc
.zc_createtxg
) {
4762 (void) printf(" zc_createtxg=%llu\n",
4763 (u_longlong_t
)zc
.zc_createtxg
);
4766 if (memcmp(&zc
.zc_stat
, &zero_zstat
, sizeof (zc
.zc_stat
))) {
4767 zfs_stat_t
*zs
= &zc
.zc_stat
;
4768 (void) printf(" zc_stat:\n");
4770 (void) printf("\tzs_gen=%llu\n",
4771 (u_longlong_t
)zs
->zs_gen
);
4774 (void) printf("\tzs_mode=%llu\n",
4775 (u_longlong_t
)zs
->zs_mode
);
4778 (void) printf("\tzs_links=%llu\n",
4779 (u_longlong_t
)zs
->zs_links
);
4781 if (zs
->zs_ctime
[0]) {
4782 (void) printf("\tzs_ctime[0]=%llu\n",
4783 (u_longlong_t
)zs
->zs_ctime
[0]);
4785 if (zs
->zs_ctime
[1]) {
4786 (void) printf("\tzs_ctime[1]=%llu\n",
4787 (u_longlong_t
)zs
->zs_ctime
[1]);
4792 /* expound verbosely upon syscall arguments */
4795 expound(private_t
*pri
, long r0
, int raw
)
4797 const lwpstatus_t
*Lsp
= pri
->lwpstat
;
4798 int lp64
= (data_model
== PR_MODEL_LP64
);
4799 int what
= Lsp
->pr_what
;
4800 int err
= pri
->Errno
; /* don't display output parameters */
4801 /* for a failed system call */
4803 /* We are a 32-bit truss; we can't grok a 64-bit process */
4807 /* for reporting sleeping system calls */
4808 if (what
== 0 && (Lsp
->pr_flags
& (PR_ASLEEP
|PR_VFORKP
)))
4809 what
= Lsp
->pr_syscall
;
4812 case SYS_gettimeofday
:
4814 show_timeofday(pri
);
4817 if (!err
&& pri
->sys_nargs
> 1)
4818 show_itimerval(pri
, (long)pri
->sys_args
[1],
4822 if (pri
->sys_nargs
> 1)
4823 show_itimerval(pri
, (long)pri
->sys_args
[1],
4825 if (!err
&& pri
->sys_nargs
> 2)
4826 show_itimerval(pri
, (long)pri
->sys_args
[2],
4841 show_utssys(pri
, r0
);
4843 show_utssys32(pri
, r0
);
4845 show_utssys(pri
, r0
);
4849 if (pri
->sys_nargs
>= 3) /* each case must decide for itself */
4850 show_ioctl(pri
, pri
->sys_args
[1],
4851 (long)pri
->sys_args
[2]);
4854 if (!err
&& pri
->sys_nargs
>= 3)
4855 show_stat(pri
, (long)pri
->sys_args
[2]);
4860 if (!err
&& pri
->sys_nargs
>= 2)
4861 show_stat(pri
, (long)pri
->sys_args
[1]);
4879 show_msgsys(pri
, r0
); /* each case must decide for itself */
4882 show_semsys(pri
); /* each case must decide for itself */
4885 show_shmsys(pri
); /* each case must decide for itself */
4888 if (err
|| pri
->sys_nargs
<= 1 || r0
<= 0)
4890 show_dents(pri
, (long)pri
->sys_args
[1], r0
);
4893 show_gp_msg(pri
, what
);
4894 if (pri
->sys_nargs
> 3)
4895 show_hhex_int(pri
, (long)pri
->sys_args
[3], "flags");
4898 show_gp_msg(pri
, what
);
4899 if (pri
->sys_nargs
> 3)
4900 show_hhex_int(pri
, (long)pri
->sys_args
[3], "band");
4901 if (pri
->sys_nargs
> 4)
4902 show_hhex_int(pri
, (long)pri
->sys_args
[4], "flags");
4906 show_gp_msg(pri
, what
);
4912 if (pri
->sys_nargs
> 1 && (r0
= pri
->sys_args
[0]) > 0)
4913 show_groups(pri
, (long)pri
->sys_args
[1], r0
);
4916 if (!err
&& pri
->sys_nargs
> 1 && pri
->sys_args
[0] > 0)
4917 show_groups(pri
, (long)pri
->sys_args
[1], r0
);
4919 case SYS_sigprocmask
:
4920 if (pri
->sys_nargs
> 1)
4921 show_sigset(pri
, (long)pri
->sys_args
[1], " set");
4922 if (!err
&& pri
->sys_nargs
> 2)
4923 show_sigset(pri
, (long)pri
->sys_args
[2], "oset");
4925 case SYS_sigsuspend
:
4926 case SYS_sigtimedwait
:
4927 if (pri
->sys_nargs
> 0)
4928 show_sigset(pri
, (long)pri
->sys_args
[0], "sigmask");
4929 if (!err
&& pri
->sys_nargs
> 1)
4930 show_siginfo(pri
, (long)pri
->sys_args
[1]);
4931 if (pri
->sys_nargs
> 2)
4932 show_timestruc(pri
, (long)pri
->sys_args
[2], "timeout");
4934 case SYS_sigaltstack
:
4935 if (pri
->sys_nargs
> 0)
4936 show_sigaltstack(pri
, (long)pri
->sys_args
[0],
4938 if (!err
&& pri
->sys_nargs
> 1)
4939 show_sigaltstack(pri
, (long)pri
->sys_args
[1],
4943 if (pri
->sys_nargs
> 1)
4944 show_sigaction(pri
, (long)pri
->sys_args
[1],
4946 if (!err
&& pri
->sys_nargs
> 2)
4947 show_sigaction(pri
, (long)pri
->sys_args
[2],
4951 if (pri
->sys_nargs
> 1)
4952 show_siginfo(pri
, (long)pri
->sys_args
[1]);
4955 if (pri
->sys_nargs
> 1)
4956 show_siginfo(pri
, (long)pri
->sys_args
[1]);
4957 if (pri
->sys_nargs
> 2)
4958 show_sigset(pri
, (long)pri
->sys_args
[2], "sigmask");
4960 case SYS_sigpending
:
4961 if (!err
&& pri
->sys_nargs
> 1)
4962 show_sigset(pri
, (long)pri
->sys_args
[1], "sigmask");
4965 if (!err
&& pri
->sys_nargs
> 2)
4966 show_siginfo(pri
, (long)pri
->sys_args
[2]);
4968 case SYS_sigsendsys
:
4969 if (pri
->sys_nargs
> 0)
4970 show_procset(pri
, (long)pri
->sys_args
[0]);
4972 case SYS_priocntlsys
:
4973 if (pri
->sys_nargs
> 1)
4974 show_procset(pri
, (long)pri
->sys_args
[1]);
4977 if (!err
&& pri
->sys_nargs
> 2)
4978 show_bool(pri
, (long)pri
->sys_args
[2],
4979 (pri
->sys_args
[1] + pagesize
- 1) / pagesize
);
4983 if (pri
->sys_nargs
> 2) {
4984 int i
= pri
->sys_args
[0]+1;
4985 int showbuf
= FALSE
;
4986 long nb
= (what
== SYS_readv
)? r0
: 32*1024;
4988 if ((what
== SYS_readv
&& !err
&&
4989 prismember(&readfd
, i
)) ||
4990 (what
== SYS_writev
&&
4991 prismember(&writefd
, i
)))
4993 show_iovec(pri
, (long)pri
->sys_args
[1],
4994 pri
->sys_args
[2], showbuf
, nb
);
5002 if (pri
->sys_nargs
<= 1)
5004 show_rlimit(pri
, (long)pri
->sys_args
[1]);
5006 if (!err
&& pri
->sys_nargs
> 0)
5007 show_uname(pri
, (long)pri
->sys_args
[0]);
5010 if (!err
&& pri
->sys_nargs
> 1)
5011 show_adjtime(pri
, (long)pri
->sys_args
[0],
5012 (long)pri
->sys_args
[1]);
5015 if (!err
&& pri
->sys_nargs
> 0)
5016 show_timestruc(pri
, (long)pri
->sys_args
[0], "cpu time");
5019 if (!err
&& pri
->sys_nargs
> 1)
5020 show_int(pri
, (long)pri
->sys_args
[1], "lwpid");
5022 case SYS_lwp_mutex_wakeup
:
5023 case SYS_lwp_mutex_unlock
:
5024 case SYS_lwp_mutex_trylock
:
5025 case SYS_lwp_mutex_register
:
5026 if (pri
->sys_nargs
> 0)
5027 show_mutex(pri
, (long)pri
->sys_args
[0]);
5029 case SYS_lwp_mutex_timedlock
:
5030 if (pri
->sys_nargs
> 0)
5031 show_mutex(pri
, (long)pri
->sys_args
[0]);
5032 if (pri
->sys_nargs
> 1)
5033 show_timestruc(pri
, (long)pri
->sys_args
[1], "timeout");
5035 case SYS_lwp_cond_wait
:
5036 if (pri
->sys_nargs
> 0)
5037 show_condvar(pri
, (long)pri
->sys_args
[0]);
5038 if (pri
->sys_nargs
> 1)
5039 show_mutex(pri
, (long)pri
->sys_args
[1]);
5040 if (pri
->sys_nargs
> 2)
5041 show_timestruc(pri
, (long)pri
->sys_args
[2], "timeout");
5043 case SYS_lwp_cond_signal
:
5044 case SYS_lwp_cond_broadcast
:
5045 if (pri
->sys_nargs
> 0)
5046 show_condvar(pri
, (long)pri
->sys_args
[0]);
5048 case SYS_lwp_sema_trywait
:
5049 case SYS_lwp_sema_post
:
5050 if (pri
->sys_nargs
> 0)
5051 show_sema(pri
, (long)pri
->sys_args
[0]);
5053 case SYS_lwp_sema_timedwait
:
5054 if (pri
->sys_nargs
> 0)
5055 show_sema(pri
, (long)pri
->sys_args
[0]);
5056 if (pri
->sys_nargs
> 1)
5057 show_timestruc(pri
, (long)pri
->sys_args
[1], "timeout");
5059 case SYS_lwp_rwlock_sys
:
5060 if (pri
->sys_nargs
> 1)
5061 show_rwlock(pri
, (long)pri
->sys_args
[1]);
5062 if (pri
->sys_nargs
> 2 &&
5063 (pri
->sys_args
[0] == 0 || pri
->sys_args
[0] == 1))
5064 show_timestruc(pri
, (long)pri
->sys_args
[2], "timeout");
5066 case SYS_lwp_create
:
5067 /* XXX print some values in ucontext ??? */
5068 if (!err
&& pri
->sys_nargs
> 2)
5069 show_int(pri
, (long)pri
->sys_args
[2], "lwpid");
5072 if (pri
->sys_args
[0] == AIOWAIT
&& !err
&& pri
->sys_nargs
> 1)
5073 show_timeval(pri
, (long)pri
->sys_args
[1], "timeout");
5076 if (pri
->sys_nargs
> 0)
5077 show_timestruc(pri
, (long)pri
->sys_args
[0], "tmout");
5078 if (pri
->sys_nargs
> 1 && (err
== 0 || err
== EINTR
))
5079 show_timestruc(pri
, (long)pri
->sys_args
[1], "resid");
5082 switch (pri
->sys_args
[0]) {
5083 case PRIVSYS_SETPPRIV
:
5084 case PRIVSYS_GETPPRIV
:
5086 show_privset(pri
, (long)pri
->sys_args
[3],
5087 (size_t)pri
->sys_args
[4], "");
5091 switch (pri
->sys_args
[0]) {
5092 case UCREDSYS_UCREDGET
:
5093 case UCREDSYS_GETPEERUCRED
:
5095 show_ucred(pri
, (long)pri
->sys_args
[2]);
5101 if (pri
->sys_nargs
> 2)
5102 show_sockaddr(pri
, "name", (long)pri
->sys_args
[1],
5103 0, (long)pri
->sys_args
[2]);
5106 if (pri
->sys_nargs
> 5)
5107 show_sockaddr(pri
, "to", (long)pri
->sys_args
[4], 0,
5111 if (!err
&& pri
->sys_nargs
> 2)
5112 show_sockaddr(pri
, "name", (long)pri
->sys_args
[1],
5113 (long)pri
->sys_args
[2], 0);
5115 case SYS_getsockname
:
5116 case SYS_getpeername
:
5117 if (!err
&& pri
->sys_nargs
> 2)
5118 show_sockaddr(pri
, "name", (long)pri
->sys_args
[1],
5119 (long)pri
->sys_args
[2], 0);
5122 if (!err
&& pri
->sys_nargs
> 5)
5123 show_sockaddr(pri
, "from", (long)pri
->sys_args
[4],
5124 (long)pri
->sys_args
[5], 0);
5131 if (pri
->sys_nargs
<= 2)
5135 show_msghdr(pri
, pri
->sys_args
[1]);
5137 show_msghdr32(pri
, pri
->sys_args
[1]);
5139 show_msghdr(pri
, pri
->sys_args
[1]);
5146 if (pri
->sys_nargs
!= 5)
5149 if (pri
->sys_args
[0] == SENDFILEV
) {
5150 show_sendfilevec(pri
, (int)pri
->sys_args
[1],
5151 (sendfilevec_t
*)pri
->sys_args
[2],
5152 (int)pri
->sys_args
[3]);
5153 } else if (pri
->sys_args
[0] == SENDFILEV64
) {
5154 show_sendfilevec64(pri
, (int)pri
->sys_args
[1],
5155 (sendfilevec64_t
*)pri
->sys_args
[2],
5156 (int)pri
->sys_args
[3]);
5164 * subcode 0: lwp_park(timespec_t *, id_t)
5165 * subcode 4: lwp_set_park(timespec_t *, id_t)
5167 if (pri
->sys_nargs
> 1 &&
5168 (pri
->sys_args
[0] == 0 || pri
->sys_args
[0] == 4))
5169 show_timestruc(pri
, (long)pri
->sys_args
[1], "timeout");
5170 /* subcode 2: lwp_unpark_all(id_t *, int) */
5171 if (pri
->sys_nargs
> 2 && pri
->sys_args
[0] == 2)
5172 show_ids(pri
, (long)pri
->sys_args
[1],
5173 (int)pri
->sys_args
[2]);
5175 case SYS_ntp_gettime
:
5177 show_ntp_gettime(pri
);
5179 case SYS_ntp_adjtime
:
5181 show_ntp_adjtime(pri
);
5185 if (pri
->sys_args
[0] == _RUSAGESYS_GETRUSAGE
) {
5188 show_getrusage32(pri
->sys_args
[1]);
5191 show_getrusage(pri
->sys_args
[1]);
5206 case SYS_sockconfig
:
5207 show_sockconfig(pri
);