feature_tests.h: always use largefile interfaces
[unleashed/lotheac.git] / usr / src / cmd / truss / expound.c
blobbba14672308ec2aa72ab8ccc41667e59e5bdeae8
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
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 */
32 #define _SYSCALL32
34 #include <stdio.h>
35 #include <stdlib.h>
36 #include <unistd.h>
37 #include <ctype.h>
38 #include <sys/types.h>
39 #include <sys/mman.h>
40 #include <libproc.h>
41 #include <string.h>
42 #include <limits.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>
48 #include <sys/ipc.h>
49 #include <sys/ipc_impl.h>
50 #include <sys/msg.h>
51 #include <sys/msg_impl.h>
52 #include <sys/sem.h>
53 #include <sys/sem_impl.h>
54 #include <sys/shm.h>
55 #include <sys/shm_impl.h>
56 #include <sys/dirent.h>
57 #include <ustat.h>
58 #include <fcntl.h>
59 #include <time.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>
66 #include <stropts.h>
67 #include <poll.h>
68 #include <sys/uio.h>
69 #include <sys/resource.h>
70 #include <sys/statvfs.h>
71 #include <sys/time.h>
72 #include <sys/aio.h>
73 #include <sys/socket.h>
74 #include <netinet/in.h>
75 #include <sys/un.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>
83 #include <priv.h>
84 #include <ucred.h>
85 #include <sys/ucred.h>
86 #include <sys/port_impl.h>
87 #include <sys/zone.h>
88 #include <sys/priv_impl.h>
89 #include <sys/priv.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>
97 #include "ramdata.h"
98 #include "systable.h"
99 #include "proto.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);
105 static void
106 mk_ctime(char *str, size_t maxsize, time_t value)
108 (void) strftime(str, maxsize, "%b %e %H:%M:%S %Z %Y",
109 localtime(&value));
112 void
113 prtime(private_t *pri, const char *name, time_t value)
115 char str[80];
117 mk_ctime(str, sizeof (str), value);
118 (void) printf("%s\t%s%s [ %lu ]\n",
119 pri->pname,
120 name,
121 str,
122 value);
125 void
126 prtimeval(private_t *pri, const char *name, struct timeval *value)
128 char str[80];
130 mk_ctime(str, sizeof (str), value->tv_sec);
131 (void) printf("%s\t%s%s [ %lu.%6.6lu ]\n",
132 pri->pname,
133 name,
134 str,
135 value->tv_sec,
136 value->tv_usec);
139 void
140 prtimestruc(private_t *pri, const char *name, timestruc_t *value)
142 char str[80];
144 mk_ctime(str, sizeof (str), value->tv_sec);
145 (void) printf("%s\t%s%s [ %lu.%9.9lu ]\n",
146 pri->pname,
147 name,
148 str,
149 value->tv_sec,
150 value->tv_nsec);
153 static void
154 show_utimens(private_t *pri, long offset)
156 struct {
157 timespec_t atime;
158 timespec_t mtime;
159 } utimbuf;
161 if (offset == 0)
162 return;
164 if (data_model == PR_MODEL_NATIVE) {
165 if (Pread(Proc, &utimbuf, sizeof (utimbuf), offset)
166 != sizeof (utimbuf))
167 return;
168 } else {
169 struct {
170 timespec32_t atime;
171 timespec32_t mtime;
172 } utimbuf32;
174 if (Pread(Proc, &utimbuf32, sizeof (utimbuf32), offset)
175 != sizeof (utimbuf32))
176 return;
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);
187 else
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);
193 else
194 prtimestruc(pri, "mt = ", &utimbuf.mtime);
197 void
198 show_timeofday(private_t *pri)
200 struct timeval tod;
201 long offset;
203 if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == 0)
204 return;
206 if (data_model == PR_MODEL_NATIVE) {
207 if (Pread(Proc, &tod, sizeof (tod), offset)
208 != sizeof (tod))
209 return;
210 } else {
211 struct timeval32 tod32;
213 if (Pread(Proc, &tod32, sizeof (tod32), offset)
214 != sizeof (tod32))
215 return;
217 TIMEVAL32_TO_TIMEVAL(&tod, &tod32);
220 prtimeval(pri, "time: ", &tod);
223 void
224 show_itimerval(private_t *pri, long offset, const char *name)
226 struct itimerval itimerval;
228 if (offset == 0)
229 return;
231 if (data_model == PR_MODEL_NATIVE) {
232 if (Pread(Proc, &itimerval, sizeof (itimerval), offset)
233 != sizeof (itimerval))
234 return;
235 } else {
236 struct itimerval32 itimerval32;
238 if (Pread(Proc, &itimerval32, sizeof (itimerval32), offset)
239 != sizeof (itimerval32))
240 return;
242 ITIMERVAL32_TO_ITIMERVAL(&itimerval, &itimerval32);
245 (void) printf(
246 "%s\t%s: interval: %4ld.%6.6ld sec value: %4ld.%6.6ld sec\n",
247 pri->pname,
248 name,
249 itimerval.it_interval.tv_sec,
250 itimerval.it_interval.tv_usec,
251 itimerval.it_value.tv_sec,
252 itimerval.it_value.tv_usec);
255 void
256 show_timeval(private_t *pri, long offset, const char *name)
258 struct timeval timeval;
260 if (offset == 0)
261 return;
263 if (data_model == PR_MODEL_NATIVE) {
264 if (Pread(Proc, &timeval, sizeof (timeval), offset)
265 != sizeof (timeval))
266 return;
267 } else {
268 struct timeval32 timeval32;
270 if (Pread(Proc, &timeval32, sizeof (timeval32), offset)
271 != sizeof (timeval32))
272 return;
274 TIMEVAL32_TO_TIMEVAL(&timeval, &timeval32);
277 (void) printf(
278 "%s\t%s: %ld.%6.6ld sec\n",
279 pri->pname,
280 name,
281 timeval.tv_sec,
282 timeval.tv_usec);
285 void
286 show_timestruc(private_t *pri, long offset, const char *name)
288 timestruc_t timestruc;
290 if (offset == 0)
291 return;
293 if (data_model == PR_MODEL_NATIVE) {
294 if (Pread(Proc, &timestruc, sizeof (timestruc), offset)
295 != sizeof (timestruc))
296 return;
297 } else {
298 timestruc32_t timestruc32;
300 if (Pread(Proc, &timestruc32, sizeof (timestruc32), offset)
301 != sizeof (timestruc32))
302 return;
304 TIMESPEC32_TO_TIMESPEC(&timestruc, &timestruc32);
307 (void) printf(
308 "%s\t%s: %ld.%9.9ld sec\n",
309 pri->pname,
310 name,
311 timestruc.tv_sec,
312 timestruc.tv_nsec);
315 void
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]);
324 void
325 show_times(private_t *pri)
327 long hz = sysconf(_SC_CLK_TCK);
328 long offset;
329 struct tms tms;
331 if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == 0)
332 return;
334 if (data_model == PR_MODEL_NATIVE) {
335 if (Pread(Proc, &tms, sizeof (tms), offset)
336 != sizeof (tms))
337 return;
338 } else {
339 struct tms32 tms32;
341 if (Pread(Proc, &tms32, sizeof (tms32), offset)
342 != sizeof (tms32))
343 return;
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;
357 (void) printf(
358 "%s\tutim=%-6lu stim=%-6lu cutim=%-6lu cstim=%-6lu (HZ=%ld)\n",
359 pri->pname,
360 tms.tms_utime,
361 tms.tms_stime,
362 tms.tms_cutime,
363 tms.tms_cstime,
364 hz);
367 /* XX64 -- definition of 'struct ustat' is strange -- check out the defn */
368 void
369 show_ustat(private_t *pri, long offset)
371 struct ustat ubuf;
373 if (offset != 0 &&
374 Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) {
375 (void) printf(
376 "%s\ttfree=%-6ld tinode=%-5lu fname=%-6.6s fpack=%-.6s\n",
377 pri->pname,
378 ubuf.f_tfree,
379 ubuf.f_tinode,
380 ubuf.f_fname,
381 ubuf.f_fpack);
385 #ifdef _LP64
386 void
387 show_ustat32(private_t *pri, long offset)
389 struct ustat32 ubuf;
391 if (offset != 0 &&
392 Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) {
393 (void) printf(
394 "%s\ttfree=%-6d tinode=%-5u fname=%-6.6s fpack=%-.6s\n",
395 pri->pname,
396 ubuf.f_tfree,
397 ubuf.f_tinode,
398 ubuf.f_fname,
399 ubuf.f_fpack);
402 #endif /* _LP64 */
404 void
405 show_fusers(private_t *pri, long offset, long nproc)
407 f_user_t fubuf;
408 int serial = (nproc > 4);
410 if (offset == 0)
411 return;
413 /* enter region of lengthy output */
414 if (serial)
415 Eserialize();
417 while (nproc > 0 &&
418 Pread(Proc, &fubuf, sizeof (fubuf), offset) == sizeof (fubuf)) {
419 (void) printf("%s\tpid=%-5d uid=%-5u flags=%s\n",
420 pri->pname,
421 (int)fubuf.fu_pid,
422 fubuf.fu_uid,
423 fuflags(pri, fubuf.fu_flags));
424 nproc--;
425 offset += sizeof (fubuf);
428 /* exit region of lengthy output */
429 if (serial)
430 Xserialize();
433 void
434 show_utssys(private_t *pri, long r0)
436 if (pri->sys_nargs >= 3) {
437 switch (pri->sys_args[2]) {
438 case UTS_USTAT:
439 show_ustat(pri, (long)pri->sys_args[0]);
440 break;
441 case UTS_FUSERS:
442 show_fusers(pri, (long)pri->sys_args[3], r0);
443 break;
448 #ifdef _LP64
449 void
450 show_utssys32(private_t *pri, long r0)
452 if (pri->sys_nargs >= 3) {
453 switch (pri->sys_args[2]) {
454 case UTS_USTAT:
455 show_ustat32(pri, (long)pri->sys_args[0]);
456 break;
457 case UTS_FUSERS:
458 show_fusers(pri, (long)pri->sys_args[3], r0);
459 break;
463 #endif /* _LP64 */
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 */
471 const char *
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");
478 else
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);
500 void
501 show_mutex(private_t *pri, long offset)
503 lwp_mutex_t mutex;
505 if (Pread(Proc, &mutex, sizeof (mutex), offset) == sizeof (mutex)) {
506 (void) printf("%s\tmutex type: %s\n",
507 pri->pname,
508 synch_type(pri, mutex.mutex_type));
512 void
513 show_condvar(private_t *pri, long offset)
515 lwp_cond_t condvar;
517 if (Pread(Proc, &condvar, sizeof (condvar), offset)
518 == sizeof (condvar)) {
519 (void) printf("%s\tcondvar type: %s\n",
520 pri->pname,
521 synch_type(pri, condvar.cond_type));
525 void
526 show_sema(private_t *pri, long offset)
528 lwp_sema_t sema;
530 if (Pread(Proc, &sema, sizeof (sema), offset) == sizeof (sema)) {
531 (void) printf("%s\tsema type: %s count = %u\n",
532 pri->pname,
533 synch_type(pri, sema.sema_type),
534 sema.sema_count);
538 void
539 show_rwlock(private_t *pri, long offset)
541 lwp_rwlock_t rwlock;
543 if (Pread(Proc, &rwlock, sizeof (rwlock), offset) == sizeof (rwlock)) {
544 (void) printf("%s\trwlock type: %s readers = %d\n",
545 pri->pname,
546 synch_type(pri, rwlock.rwlock_type),
547 rwlock.rwlock_readers);
551 /* represent character as itself ('c') or octal (012) */
552 char *
553 show_char(char *buf, int c)
555 const char *fmt;
557 if (c >= ' ' && c < 0177)
558 fmt = "'%c'";
559 else
560 fmt = "%.3o";
562 (void) sprintf(buf, fmt, c&0xff);
563 return (buf);
566 void
567 show_termio(private_t *pri, long offset)
569 struct termio termio;
570 char cbuf[8];
571 int i;
573 if (Pread(Proc, &termio, sizeof (termio), offset) == sizeof (termio)) {
574 (void) printf(
575 "%s\tiflag=0%.6o oflag=0%.6o cflag=0%.6o lflag=0%.6o line=%d\n",
576 pri->pname,
577 termio.c_iflag,
578 termio.c_oflag,
579 termio.c_cflag,
580 termio.c_lflag,
581 termio.c_line);
582 (void) printf("%s\t cc: ", pri->pname);
583 for (i = 0; i < NCC; i++)
584 (void) printf(" %s",
585 show_char(cbuf, (int)termio.c_cc[i]));
586 (void) fputc('\n', stdout);
590 void
591 show_termios(private_t *pri, long offset)
593 struct termios termios;
594 char cbuf[8];
595 int i;
597 if (Pread(Proc, &termios, sizeof (termios), offset)
598 == sizeof (termios)) {
599 (void) printf(
600 "%s\tiflag=0%.6o oflag=0%.6o cflag=0%.6o lflag=0%.6o\n",
601 pri->pname,
602 termios.c_iflag,
603 termios.c_oflag,
604 termios.c_cflag,
605 termios.c_lflag);
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);
610 (void) printf(" %s",
611 show_char(cbuf, (int)termios.c_cc[i]));
613 (void) fputc('\n', stdout);
617 void
618 show_termiox(private_t *pri, long offset)
620 struct termiox termiox;
621 int i;
623 if (Pread(Proc, &termiox, sizeof (termiox), offset)
624 == sizeof (termiox)) {
625 (void) printf("%s\thflag=0%.3o cflag=0%.3o rflag=0%.3o",
626 pri->pname,
627 termiox.x_hflag,
628 termiox.x_cflag,
629 termiox.x_rflag[0]);
630 for (i = 1; i < NFF; i++)
631 (void) printf(",0%.3o", termiox.x_rflag[i]);
632 (void) printf(" sflag=0%.3o\n",
633 termiox.x_sflag);
637 void
638 show_sgttyb(private_t *pri, long offset)
640 struct sgttyb sgttyb;
642 if (Pread(Proc, &sgttyb, sizeof (sgttyb), offset) == sizeof (sgttyb)) {
643 char erase[8];
644 char kill[8];
646 (void) printf(
647 "%s\tispeed=%-2d ospeed=%-2d erase=%s kill=%s flags=0x%.8x\n",
648 pri->pname,
649 sgttyb.sg_ispeed&0xff,
650 sgttyb.sg_ospeed&0xff,
651 show_char(erase, sgttyb.sg_erase),
652 show_char(kill, sgttyb.sg_kill),
653 sgttyb.sg_flags);
657 void
658 show_ltchars(private_t *pri, long offset)
660 struct ltchars ltchars;
661 char *p;
662 char cbuf[8];
663 int i;
665 if (Pread(Proc, &ltchars, sizeof (ltchars), offset)
666 == sizeof (ltchars)) {
667 (void) printf("%s\t cc: ", pri->pname);
668 for (p = (char *)&ltchars, i = 0; i < sizeof (ltchars); i++)
669 (void) printf(" %s", show_char(cbuf, (int)*p++));
670 (void) fputc('\n', stdout);
674 void
675 show_tchars(private_t *pri, long offset)
677 struct tchars tchars;
678 char *p;
679 char cbuf[8];
680 int i;
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);
690 void
691 show_termcb(private_t *pri, long offset)
693 struct termcb termcb;
695 if (Pread(Proc, &termcb, sizeof (termcb), offset) == sizeof (termcb)) {
696 (void) printf(
697 "%s\tflgs=0%.2o termt=%d crow=%d ccol=%d vrow=%d lrow=%d\n",
698 pri->pname,
699 termcb.st_flgs&0xff,
700 termcb.st_termt&0xff,
701 termcb.st_crow&0xff,
702 termcb.st_ccol&0xff,
703 termcb.st_vrow&0xff,
704 termcb.st_lrow&0xff);
708 /* integer value pointed to by ioctl() arg */
709 void
710 show_strint(private_t *pri, int code, long offset)
712 int val;
714 if (Pread(Proc, &val, sizeof (val), offset) == sizeof (val)) {
715 const char *s = NULL;
717 switch (code) { /* interpret these symbolically */
718 case I_GRDOPT:
719 s = strrdopt(val);
720 break;
721 case I_GETSIG:
722 s = strevents(pri, val);
723 break;
724 case TIOCFLUSH:
725 s = tiocflush(pri, val);
726 break;
729 if (s == NULL)
730 (void) printf("%s\t0x%.8lX: %d\n",
731 pri->pname, offset, val);
732 else
733 (void) printf("%s\t0x%.8lX: %s\n",
734 pri->pname, offset, s);
738 void
739 show_strioctl(private_t *pri, long offset)
741 struct strioctl strioctl;
743 if (Pread(Proc, &strioctl, sizeof (strioctl), offset) ==
744 sizeof (strioctl)) {
745 (void) printf(
746 "%s\tcmd=%s timout=%d len=%d dp=0x%.8lX\n",
747 pri->pname,
748 ioctlname(pri, strioctl.ic_cmd),
749 strioctl.ic_timout,
750 strioctl.ic_len,
751 (long)strioctl.ic_dp);
753 if (pri->recur++ == 0) /* avoid indefinite recursion */
754 show_ioctl(pri, strioctl.ic_cmd,
755 (long)strioctl.ic_dp);
756 --pri->recur;
760 #ifdef _LP64
761 void
762 show_strioctl32(private_t *pri, long offset)
764 struct strioctl32 strioctl;
766 if (Pread(Proc, &strioctl, sizeof (strioctl), offset) ==
767 sizeof (strioctl)) {
768 (void) printf(
769 "%s\tcmd=%s timout=%d len=%d dp=0x%.8lX\n",
770 pri->pname,
771 ioctlname(pri, strioctl.ic_cmd),
772 strioctl.ic_timout,
773 strioctl.ic_len,
774 (long)strioctl.ic_dp);
776 if (pri->recur++ == 0) /* avoid indefinite recursion */
777 show_ioctl(pri, strioctl.ic_cmd,
778 (long)strioctl.ic_dp);
779 --pri->recur;
782 #endif /* _LP64 */
784 void
785 print_strbuf(private_t *pri, struct strbuf *sp, const char *name, int dump)
787 (void) printf(
788 "%s\t%s: maxlen=%-4d len=%-4d buf=0x%.8lX",
789 pri->pname,
790 name,
791 sp->maxlen,
792 sp->len,
793 (long)sp->buf);
795 * Should we show the buffer contents?
796 * Keyed to the '-r fds' and '-w fds' options?
798 if (sp->buf == NULL || sp->len <= 0)
799 (void) fputc('\n', stdout);
800 else {
801 int nb = (sp->len > 8)? 8 : sp->len;
802 char buffer[8];
803 char obuf[40];
805 if (Pread(Proc, buffer, (size_t)nb, (long)sp->buf) == nb) {
806 (void) strcpy(obuf, ": \"");
807 showbytes(buffer, nb, obuf+3);
808 (void) strcat(obuf,
809 (nb == sp->len)?
810 (const char *)"\"" : (const char *)"\"..");
811 (void) fputs(obuf, stdout);
813 (void) fputc('\n', stdout);
814 if (dump && sp->len > 8)
815 showbuffer(pri, (long)sp->buf, (long)sp->len);
819 #ifdef _LP64
820 void
821 print_strbuf32(private_t *pri, struct strbuf32 *sp, const char *name, int dump)
823 (void) printf(
824 "%s\t%s: maxlen=%-4d len=%-4d buf=0x%.8lX",
825 pri->pname,
826 name,
827 sp->maxlen,
828 sp->len,
829 (long)sp->buf);
831 * Should we show the buffer contents?
832 * Keyed to the '-r fds' and '-w fds' options?
834 if (sp->buf == (uintptr_t)NULL || sp->len <= 0)
835 (void) fputc('\n', stdout);
836 else {
837 int nb = (sp->len > 8)? 8 : sp->len;
838 char buffer[8];
839 char obuf[40];
841 if (Pread(Proc, buffer, (size_t)nb, (long)sp->buf) == nb) {
842 (void) strcpy(obuf, ": \"");
843 showbytes(buffer, nb, obuf+3);
844 (void) strcat(obuf,
845 (nb == sp->len)?
846 (const char *)"\"" : (const char *)"\"..");
847 (void) fputs(obuf, stdout);
849 (void) fputc('\n', stdout);
850 if (dump && sp->len > 8)
851 showbuffer(pri, (long)sp->buf, (long)sp->len);
854 #endif /* _LP64 */
856 /* strpeek and strfdinsert flags word */
857 const char *
858 strflags(private_t *pri, int flags)
860 const char *s;
862 switch (flags) {
863 case 0:
864 s = "0";
865 break;
866 case RS_HIPRI:
867 s = "RS_HIPRI";
868 break;
869 default:
870 (void) sprintf(pri->code_buf, "0x%.4X", flags);
871 s = pri->code_buf;
874 return (s);
877 void
878 show_strpeek(private_t *pri, long offset)
880 struct strpeek strpeek;
882 if (Pread(Proc, &strpeek, sizeof (strpeek), offset)
883 == sizeof (strpeek)) {
885 print_strbuf(pri, &strpeek.ctlbuf, "ctl", FALSE);
886 print_strbuf(pri, &strpeek.databuf, "dat", FALSE);
888 (void) printf("%s\tflags=%s\n",
889 pri->pname,
890 strflags(pri, strpeek.flags));
894 #ifdef _LP64
895 void
896 show_strpeek32(private_t *pri, long offset)
898 struct strpeek32 strpeek;
900 if (Pread(Proc, &strpeek, sizeof (strpeek), offset)
901 == sizeof (strpeek)) {
903 print_strbuf32(pri, &strpeek.ctlbuf, "ctl", FALSE);
904 print_strbuf32(pri, &strpeek.databuf, "dat", FALSE);
906 (void) printf("%s\tflags=%s\n",
907 pri->pname,
908 strflags(pri, strpeek.flags));
911 #endif /* _LP64 */
913 void
914 show_strfdinsert(private_t *pri, long offset)
916 struct strfdinsert strfdinsert;
918 if (Pread(Proc, &strfdinsert, sizeof (strfdinsert), offset) ==
919 sizeof (strfdinsert)) {
921 print_strbuf(pri, &strfdinsert.ctlbuf, "ctl", FALSE);
922 print_strbuf(pri, &strfdinsert.databuf, "dat", FALSE);
924 (void) printf("%s\tflags=%s fildes=%d offset=%d\n",
925 pri->pname,
926 strflags(pri, strfdinsert.flags),
927 strfdinsert.fildes,
928 strfdinsert.offset);
932 #ifdef _LP64
933 void
934 show_strfdinsert32(private_t *pri, long offset)
936 struct strfdinsert32 strfdinsert;
938 if (Pread(Proc, &strfdinsert, sizeof (strfdinsert), offset) ==
939 sizeof (strfdinsert)) {
941 print_strbuf32(pri, &strfdinsert.ctlbuf, "ctl", FALSE);
942 print_strbuf32(pri, &strfdinsert.databuf, "dat", FALSE);
944 (void) printf("%s\tflags=%s fildes=%d offset=%d\n",
945 pri->pname,
946 strflags(pri, strfdinsert.flags),
947 strfdinsert.fildes,
948 strfdinsert.offset);
951 #endif /* _LP64 */
953 void
954 show_strrecvfd(private_t *pri, long offset)
956 struct strrecvfd strrecvfd;
958 if (Pread(Proc, &strrecvfd, sizeof (strrecvfd), offset) ==
959 sizeof (strrecvfd)) {
960 (void) printf(
961 "%s\tfd=%-5d uid=%-5u gid=%u\n",
962 pri->pname,
963 strrecvfd.fd,
964 strrecvfd.uid,
965 strrecvfd.gid);
969 void
970 show_strlist(private_t *pri, long offset)
972 struct str_list strlist;
973 struct str_mlist list;
974 int count;
976 if (Pread(Proc, &strlist, sizeof (strlist), offset) ==
977 sizeof (strlist)) {
978 (void) printf("%s\tnmods=%d modlist=0x%.8lX\n",
979 pri->pname,
980 strlist.sl_nmods,
981 (long)strlist.sl_modlist);
983 count = strlist.sl_nmods;
984 offset = (long)strlist.sl_modlist;
985 while (!interrupt && --count >= 0) {
986 if (Pread(Proc, &list, sizeof (list), offset) !=
987 sizeof (list))
988 break;
989 (void) printf("%s\t\t\"%.*s\"\n",
990 pri->pname,
991 (int)sizeof (list.l_name),
992 list.l_name);
993 offset += sizeof (struct str_mlist);
998 #ifdef _LP64
999 void
1000 show_strlist32(private_t *pri, long offset)
1002 struct str_list32 strlist;
1003 struct str_mlist list;
1004 int count;
1006 if (Pread(Proc, &strlist, sizeof (strlist), offset) ==
1007 sizeof (strlist)) {
1008 (void) printf("%s\tnmods=%d modlist=0x%.8lX\n",
1009 pri->pname,
1010 strlist.sl_nmods,
1011 (long)strlist.sl_modlist);
1013 count = strlist.sl_nmods;
1014 offset = (long)strlist.sl_modlist;
1015 while (!interrupt && --count >= 0) {
1016 if (Pread(Proc, &list, sizeof (list), offset) !=
1017 sizeof (list))
1018 break;
1019 (void) printf("%s\t\t\"%.*s\"\n",
1020 pri->pname,
1021 (int)sizeof (list.l_name),
1022 list.l_name);
1023 offset += sizeof (struct str_mlist);
1027 #endif /* _LP64 */
1029 void
1030 show_jwinsize(private_t *pri, long offset)
1032 struct jwinsize jwinsize;
1034 if (Pread(Proc, &jwinsize, sizeof (jwinsize), offset) ==
1035 sizeof (jwinsize)) {
1036 (void) printf(
1037 "%s\tbytesx=%-3u bytesy=%-3u bitsx=%-3u bitsy=%-3u\n",
1038 pri->pname,
1039 (unsigned)jwinsize.bytesx,
1040 (unsigned)jwinsize.bytesy,
1041 (unsigned)jwinsize.bitsx,
1042 (unsigned)jwinsize.bitsy);
1046 void
1047 show_winsize(private_t *pri, long offset)
1049 struct winsize winsize;
1051 if (Pread(Proc, &winsize, sizeof (winsize), offset)
1052 == sizeof (winsize)) {
1053 (void) printf(
1054 "%s\trow=%-3d col=%-3d xpixel=%-3d ypixel=%-3d\n",
1055 pri->pname,
1056 winsize.ws_row,
1057 winsize.ws_col,
1058 winsize.ws_xpixel,
1059 winsize.ws_ypixel);
1063 struct audio_stuff {
1064 uint_t bit;
1065 const char *str;
1068 const struct audio_stuff audio_output_ports[] = {
1069 { AUDIO_SPEAKER, "SPEAKER" },
1070 { AUDIO_HEADPHONE, "HEADPHONE" },
1071 { AUDIO_LINE_OUT, "LINE_OUT" },
1072 { AUDIO_SPDIF_OUT, "SPDIF_OUT" },
1073 { AUDIO_AUX1_OUT, "AUX1_OUT" },
1074 { AUDIO_AUX2_OUT, "AUX2_OUT" },
1075 { 0, NULL }
1078 const struct audio_stuff audio_input_ports[] = {
1079 { AUDIO_MICROPHONE, "MICROPHONE" },
1080 { AUDIO_LINE_IN, "LINE_IN" },
1081 { AUDIO_CD, "CD" },
1082 { AUDIO_SPDIF_IN, "SPDIF_IN" },
1083 { AUDIO_AUX1_IN, "AUX1_IN" },
1084 { AUDIO_AUX2_IN, "AUX2_IN" },
1085 { AUDIO_CODEC_LOOPB_IN, "CODEC_LOOPB_IN" },
1086 { AUDIO_SUNVTS, "SUNVTS" },
1087 { 0, NULL }
1090 static const struct audio_stuff audio_hw_features[] = {
1091 { AUDIO_HWFEATURE_DUPLEX, "DUPLEX" },
1092 { AUDIO_HWFEATURE_MSCODEC, "MSCODEC" },
1093 { AUDIO_HWFEATURE_IN2OUT, "IN2OUT" },
1094 { AUDIO_HWFEATURE_PLAY, "PLAY" },
1095 { AUDIO_HWFEATURE_RECORD, "RECORD" },
1096 { 0, NULL }
1099 static const struct audio_stuff audio_sw_features[] = {
1100 { AUDIO_SWFEATURE_MIXER, "MIXER" },
1101 { 0, NULL }
1104 void
1105 show_audio_features(const private_t *pri,
1106 const struct audio_stuff *audio_porttab, uint_t features,
1107 const char *name)
1109 (void) printf("%s\t%s=", pri->pname, name);
1110 if (features == 0) {
1111 (void) printf("0\n");
1112 return;
1115 for (; audio_porttab->bit != 0; ++audio_porttab) {
1116 if (features & audio_porttab->bit) {
1117 (void) printf(audio_porttab->str);
1118 features &= ~audio_porttab->bit;
1119 if (features)
1120 (void) putchar('|');
1123 if (features)
1124 (void) printf("0x%x", features);
1125 (void) putchar('\n');
1128 void
1129 show_audio_ports(private_t *pri, const char *mode,
1130 const char *field, uint_t ports)
1132 const struct audio_stuff *audio_porttab;
1134 (void) printf("%s\t%s\t%s=", pri->pname, mode, field);
1135 if (ports == 0) {
1136 (void) printf("0\n");
1137 return;
1139 if (*mode == 'p')
1140 audio_porttab = audio_output_ports;
1141 else
1142 audio_porttab = audio_input_ports;
1143 for (; audio_porttab->bit != 0; ++audio_porttab) {
1144 if (ports & audio_porttab->bit) {
1145 (void) printf(audio_porttab->str);
1146 ports &= ~audio_porttab->bit;
1147 if (ports)
1148 (void) putchar('|');
1151 if (ports)
1152 (void) printf("0x%x", ports);
1153 (void) putchar('\n');
1156 void
1157 show_audio_prinfo(private_t *pri, const char *mode, struct audio_prinfo *au_pr)
1159 const char *s;
1162 * The following values describe the audio data encoding.
1165 (void) printf("%s\t%s\tsample_rate=%u channels=%u precision=%u\n",
1166 pri->pname, mode,
1167 au_pr->sample_rate,
1168 au_pr->channels,
1169 au_pr->precision);
1171 s = NULL;
1172 switch (au_pr->encoding) {
1173 case AUDIO_ENCODING_NONE: s = "NONE"; break;
1174 case AUDIO_ENCODING_ULAW: s = "ULAW"; break;
1175 case AUDIO_ENCODING_ALAW: s = "ALAW"; break;
1176 case AUDIO_ENCODING_LINEAR: s = "LINEAR"; break;
1177 case AUDIO_ENCODING_DVI: s = "DVI"; break;
1178 case AUDIO_ENCODING_LINEAR8: s = "LINEAR8"; break;
1180 if (s)
1181 (void) printf("%s\t%s\tencoding=%s\n", pri->pname, mode, s);
1182 else {
1183 (void) printf("%s\t%s\tencoding=%u\n",
1184 pri->pname, mode, au_pr->encoding);
1188 * The following values control audio device configuration
1191 (void) printf(
1192 "%s\t%s\tgain=%u buffer_size=%u\n",
1193 pri->pname, mode,
1194 au_pr->gain,
1195 au_pr->buffer_size);
1196 show_audio_ports(pri, mode, "port", au_pr->port);
1197 show_audio_ports(pri, mode, "avail_ports", au_pr->avail_ports);
1198 show_audio_ports(pri, mode, "mod_ports", au_pr->mod_ports);
1201 * The following values describe driver state
1204 (void) printf("%s\t%s\tsamples=%u eof=%u pause=%u error=%u\n",
1205 pri->pname, mode,
1206 au_pr->samples,
1207 au_pr->eof,
1208 au_pr->pause,
1209 au_pr->error);
1210 (void) printf("%s\t%s\twaiting=%u balance=%u minordev=%u\n",
1211 pri->pname, mode,
1212 au_pr->waiting,
1213 au_pr->balance,
1214 au_pr->minordev);
1217 * The following values are read-only state flags
1219 (void) printf("%s\t%s\topen=%u active=%u\n",
1220 pri->pname, mode,
1221 au_pr->open,
1222 au_pr->active);
1225 void
1226 show_audio_info(private_t *pri, long offset)
1228 struct audio_info au;
1230 if (Pread(Proc, &au, sizeof (au), offset) == sizeof (au)) {
1231 show_audio_prinfo(pri, "play", &au.play);
1232 show_audio_prinfo(pri, "record", &au.record);
1233 (void) printf("%s\tmonitor_gain=%u output_muted=%u\n",
1234 pri->pname, au.monitor_gain, au.output_muted);
1235 show_audio_features(pri, audio_hw_features, au.hw_features,
1236 "hw_features");
1237 show_audio_features(pri, audio_sw_features, au.sw_features,
1238 "sw_features");
1239 show_audio_features(pri, audio_sw_features,
1240 au.sw_features_enabled, "sw_features_enabled");
1244 void
1245 show_ioctl(private_t *pri, int code, long offset)
1247 int lp64 = (data_model == PR_MODEL_LP64);
1248 int err = pri->Errno; /* don't display output parameters */
1249 /* for a failed system call */
1250 #ifndef _LP64
1251 if (lp64)
1252 return;
1253 #endif
1254 if (offset == 0)
1255 return;
1257 switch (code) {
1258 case TCGETA:
1259 if (err)
1260 break;
1261 /*FALLTHROUGH*/
1262 case TCSETA:
1263 case TCSETAW:
1264 case TCSETAF:
1265 show_termio(pri, offset);
1266 break;
1267 case TCGETS:
1268 if (err)
1269 break;
1270 /*FALLTHROUGH*/
1271 case TCSETS:
1272 case TCSETSW:
1273 case TCSETSF:
1274 show_termios(pri, offset);
1275 break;
1276 case TCGETX:
1277 if (err)
1278 break;
1279 /*FALLTHROUGH*/
1280 case TCSETX:
1281 case TCSETXW:
1282 case TCSETXF:
1283 show_termiox(pri, offset);
1284 break;
1285 case TIOCGETP:
1286 if (err)
1287 break;
1288 /*FALLTHROUGH*/
1289 case TIOCSETN:
1290 case TIOCSETP:
1291 show_sgttyb(pri, offset);
1292 break;
1293 case TIOCGLTC:
1294 if (err)
1295 break;
1296 /*FALLTHROUGH*/
1297 case TIOCSLTC:
1298 show_ltchars(pri, offset);
1299 break;
1300 case TIOCGETC:
1301 if (err)
1302 break;
1303 /*FALLTHROUGH*/
1304 case TIOCSETC:
1305 show_tchars(pri, offset);
1306 break;
1307 case LDGETT:
1308 if (err)
1309 break;
1310 /*FALLTHROUGH*/
1311 case LDSETT:
1312 show_termcb(pri, offset);
1313 break;
1314 /* streams ioctl()s */
1315 #if 0
1316 /* these are displayed as strings in the arg list */
1317 /* by prt_ioa(). don't display them again here */
1318 case I_PUSH:
1319 case I_LOOK:
1320 case I_FIND:
1321 /* these are displayed as decimal in the arg list */
1322 /* by prt_ioa(). don't display them again here */
1323 case I_LINK:
1324 case I_UNLINK:
1325 case I_SENDFD:
1326 /* these are displayed symbolically in the arg list */
1327 /* by prt_ioa(). don't display them again here */
1328 case I_SRDOPT:
1329 case I_SETSIG:
1330 case I_FLUSH:
1331 break;
1332 /* this one just ignores the argument */
1333 case I_POP:
1334 break;
1335 #endif
1336 /* these return something in an int pointed to by arg */
1337 case I_NREAD:
1338 case I_GRDOPT:
1339 case I_GETSIG:
1340 case TIOCGSID:
1341 case TIOCGPGRP:
1342 case TIOCLGET:
1343 case FIONREAD:
1344 case FIORDCHK:
1345 if (err)
1346 break;
1347 /*FALLTHROUGH*/
1348 /* these pass something in an int pointed to by arg */
1349 case TIOCSPGRP:
1350 case TIOCFLUSH:
1351 case TIOCLBIS:
1352 case TIOCLBIC:
1353 case TIOCLSET:
1354 show_strint(pri, code, offset);
1355 break;
1356 /* these all point to structures */
1357 case I_STR:
1358 #ifdef _LP64
1359 if (lp64)
1360 show_strioctl(pri, offset);
1361 else
1362 show_strioctl32(pri, offset);
1363 #else
1364 show_strioctl(pri, offset);
1365 #endif
1366 break;
1367 case I_PEEK:
1368 #ifdef _LP64
1369 if (lp64)
1370 show_strpeek(pri, offset);
1371 else
1372 show_strpeek32(pri, offset);
1373 #else
1374 show_strpeek(pri, offset);
1375 #endif
1376 break;
1377 case I_FDINSERT:
1378 #ifdef _LP64
1379 if (lp64)
1380 show_strfdinsert(pri, offset);
1381 else
1382 show_strfdinsert32(pri, offset);
1383 #else
1384 show_strfdinsert(pri, offset);
1385 #endif
1386 break;
1387 case I_RECVFD:
1388 if (err)
1389 break;
1390 show_strrecvfd(pri, offset);
1391 break;
1392 case I_LIST:
1393 if (err)
1394 break;
1395 #ifdef _LP64
1396 if (lp64)
1397 show_strlist(pri, offset);
1398 else
1399 show_strlist32(pri, offset);
1400 #else
1401 show_strlist(pri, offset);
1402 #endif
1403 break;
1404 case JWINSIZE:
1405 if (err)
1406 break;
1407 show_jwinsize(pri, offset);
1408 break;
1409 case TIOCGWINSZ:
1410 if (err)
1411 break;
1412 /*FALLTHROUGH*/
1413 case TIOCSWINSZ:
1414 show_winsize(pri, offset);
1415 break;
1416 case AUDIO_GETINFO:
1417 case (int)AUDIO_SETINFO:
1418 show_audio_info(pri, offset);
1419 break;
1421 default:
1422 if ((code & ~0xff) == ZFS_IOC) {
1423 show_zfs_ioc(pri, offset);
1424 break;
1427 if (code & IOC_INOUT) {
1428 const char *str = ioctldatastruct(code);
1430 (void) printf("\t\t%s",
1431 (code & IOC_INOUT) == IOC_INOUT ? "write/read" :
1432 code & IOC_IN ? "write" : "read");
1433 if (str != NULL) {
1434 (void) printf(" (struct %s)\n", str);
1435 } else {
1436 (void) printf(" %d bytes\n",
1437 (code >> 16) & IOCPARM_MASK);
1443 void
1444 show_statvfs(private_t *pri)
1446 long offset;
1447 struct statvfs statvfs;
1448 char *cp;
1450 if (pri->sys_nargs > 1 && (offset = pri->sys_args[1]) != 0 &&
1451 Pread(Proc, &statvfs, sizeof (statvfs), offset)
1452 == sizeof (statvfs)) {
1453 (void) printf(
1454 "%s\tbsize=%-10lu frsize=%-9lu blocks=%-8llu bfree=%-9llu\n",
1455 pri->pname,
1456 statvfs.f_bsize,
1457 statvfs.f_frsize,
1458 (u_longlong_t)statvfs.f_blocks,
1459 (u_longlong_t)statvfs.f_bfree);
1460 (void) printf(
1461 "%s\tbavail=%-9llu files=%-10llu ffree=%-9llu favail=%-9llu\n",
1462 pri->pname,
1463 (u_longlong_t)statvfs.f_bavail,
1464 (u_longlong_t)statvfs.f_files,
1465 (u_longlong_t)statvfs.f_ffree,
1466 (u_longlong_t)statvfs.f_favail);
1467 (void) printf(
1468 "%s\tfsid=0x%-9.4lX basetype=%-7.16s namemax=%ld\n",
1469 pri->pname,
1470 statvfs.f_fsid,
1471 statvfs.f_basetype,
1472 (long)statvfs.f_namemax);
1473 (void) printf(
1474 "%s\tflag=%s\n",
1475 pri->pname,
1476 svfsflags(pri, (ulong_t)statvfs.f_flag));
1477 cp = statvfs.f_fstr + strlen(statvfs.f_fstr);
1478 if (cp < statvfs.f_fstr + sizeof (statvfs.f_fstr) - 1 &&
1479 *(cp+1) != '\0')
1480 *cp = ' ';
1481 (void) printf("%s\tfstr=\"%.*s\"\n",
1482 pri->pname,
1483 (int)sizeof (statvfs.f_fstr),
1484 statvfs.f_fstr);
1488 #ifdef _LP64
1489 void
1490 show_statvfs32(private_t *pri)
1492 long offset;
1493 struct statvfs32 statvfs;
1494 char *cp;
1496 if (pri->sys_nargs > 1 && (offset = pri->sys_args[1]) != 0 &&
1497 Pread(Proc, &statvfs, sizeof (statvfs), offset)
1498 == sizeof (statvfs)) {
1499 (void) printf(
1500 "%s\tbsize=%-10u frsize=%-9u blocks=%-8u bfree=%-9u\n",
1501 pri->pname,
1502 statvfs.f_bsize,
1503 statvfs.f_frsize,
1504 statvfs.f_blocks,
1505 statvfs.f_bfree);
1506 (void) printf(
1507 "%s\tbavail=%-9u files=%-10u ffree=%-9u favail=%-9u\n",
1508 pri->pname,
1509 statvfs.f_bavail,
1510 statvfs.f_files,
1511 statvfs.f_ffree,
1512 statvfs.f_favail);
1513 (void) printf(
1514 "%s\tfsid=0x%-9.4X basetype=%-7.16s namemax=%d\n",
1515 pri->pname,
1516 statvfs.f_fsid,
1517 statvfs.f_basetype,
1518 (int)statvfs.f_namemax);
1519 (void) printf(
1520 "%s\tflag=%s\n",
1521 pri->pname,
1522 svfsflags(pri, (ulong_t)statvfs.f_flag));
1523 cp = statvfs.f_fstr + strlen(statvfs.f_fstr);
1524 if (cp < statvfs.f_fstr + sizeof (statvfs.f_fstr) - 1 &&
1525 *(cp+1) != '\0')
1526 *cp = ' ';
1527 (void) printf("%s\tfstr=\"%.*s\"\n",
1528 pri->pname,
1529 (int)sizeof (statvfs.f_fstr),
1530 statvfs.f_fstr);
1533 #endif /* _LP64 */
1535 void
1536 show_statvfs64(private_t *pri)
1538 long offset;
1539 struct statvfs64_32 statvfs;
1540 char *cp;
1542 if (pri->sys_nargs > 1 && (offset = pri->sys_args[1]) != 0 &&
1543 Pread(Proc, &statvfs, sizeof (statvfs), offset)
1544 == sizeof (statvfs)) {
1545 (void) printf(
1546 "%s\tbsize=%-10u frsize=%-9u blocks=%-8llu bfree=%-9llu\n",
1547 pri->pname,
1548 statvfs.f_bsize,
1549 statvfs.f_frsize,
1550 (u_longlong_t)statvfs.f_blocks,
1551 (u_longlong_t)statvfs.f_bfree);
1552 (void) printf(
1553 "%s\tbavail=%-9llu files=%-10llu ffree=%-9llu favail=%-9llu\n",
1554 pri->pname,
1555 (u_longlong_t)statvfs.f_bavail,
1556 (u_longlong_t)statvfs.f_files,
1557 (u_longlong_t)statvfs.f_ffree,
1558 (u_longlong_t)statvfs.f_favail);
1559 (void) printf(
1560 "%s\tfsid=0x%-9.4X basetype=%-7.16s namemax=%d\n",
1561 pri->pname,
1562 statvfs.f_fsid,
1563 statvfs.f_basetype,
1564 (int)statvfs.f_namemax);
1565 (void) printf(
1566 "%s\tflag=%s\n",
1567 pri->pname,
1568 svfsflags(pri, (ulong_t)statvfs.f_flag));
1569 cp = statvfs.f_fstr + strlen(statvfs.f_fstr);
1570 if (cp < statvfs.f_fstr + sizeof (statvfs.f_fstr) - 1 &&
1571 *(cp+1) != '\0')
1572 *cp = ' ';
1573 (void) printf("%s\tfstr=\"%.*s\"\n",
1574 pri->pname,
1575 (int)sizeof (statvfs.f_fstr),
1576 statvfs.f_fstr);
1580 void
1581 show_statfs(private_t *pri)
1583 long offset;
1584 struct statfs statfs;
1586 if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != 0 &&
1587 Pread(Proc, &statfs, sizeof (statfs), offset) == sizeof (statfs)) {
1588 (void) printf(
1589 "%s\tfty=%d bsz=%ld fsz=%ld blk=%ld bfr=%ld fil=%lu ffr=%lu\n",
1590 pri->pname,
1591 statfs.f_fstyp,
1592 statfs.f_bsize,
1593 statfs.f_frsize,
1594 statfs.f_blocks,
1595 statfs.f_bfree,
1596 statfs.f_files,
1597 statfs.f_ffree);
1598 (void) printf("%s\t fname=%.6s fpack=%.6s\n",
1599 pri->pname,
1600 statfs.f_fname,
1601 statfs.f_fpack);
1605 #ifdef _LP64
1606 void
1607 show_statfs32(private_t *pri)
1609 long offset;
1610 struct statfs32 statfs;
1612 if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != 0 &&
1613 Pread(Proc, &statfs, sizeof (statfs), offset) == sizeof (statfs)) {
1614 (void) printf(
1615 "%s\tfty=%d bsz=%d fsz=%d blk=%d bfr=%d fil=%u ffr=%u\n",
1616 pri->pname,
1617 statfs.f_fstyp,
1618 statfs.f_bsize,
1619 statfs.f_frsize,
1620 statfs.f_blocks,
1621 statfs.f_bfree,
1622 statfs.f_files,
1623 statfs.f_ffree);
1624 (void) printf("%s\t fname=%.6s fpack=%.6s\n",
1625 pri->pname,
1626 statfs.f_fname,
1627 statfs.f_fpack);
1630 #endif /* _LP64 */
1632 void
1633 show_flock32(private_t *pri, long offset)
1635 struct flock32 flock;
1637 if (Pread(Proc, &flock, sizeof (flock), offset) == sizeof (flock)) {
1638 const char *str = NULL;
1640 (void) printf("%s\ttyp=", pri->pname);
1642 switch (flock.l_type) {
1643 case F_RDLCK:
1644 str = "F_RDLCK";
1645 break;
1646 case F_WRLCK:
1647 str = "F_WRLCK";
1648 break;
1649 case F_UNLCK:
1650 str = "F_UNLCK";
1651 break;
1653 if (str != NULL)
1654 (void) printf("%s", str);
1655 else
1656 (void) printf("%-7d", flock.l_type);
1658 str = whencearg(flock.l_whence);
1659 if (str != NULL)
1660 (void) printf(" whence=%s", str);
1661 else
1662 (void) printf(" whence=%-8u", flock.l_whence);
1664 (void) printf(
1665 " start=%-5d len=%-5d sys=%-2u pid=%d\n",
1666 flock.l_start,
1667 flock.l_len,
1668 flock.l_sysid,
1669 flock.l_pid);
1673 void
1674 show_flock64(private_t *pri, long offset)
1676 struct flock64 flock;
1678 if (Pread(Proc, &flock, sizeof (flock), offset) == sizeof (flock)) {
1679 const char *str = NULL;
1681 (void) printf("%s\ttyp=", pri->pname);
1683 switch (flock.l_type) {
1684 case F_RDLCK:
1685 str = "F_RDLCK";
1686 break;
1687 case F_WRLCK:
1688 str = "F_WRLCK";
1689 break;
1690 case F_UNLCK:
1691 str = "F_UNLCK";
1692 break;
1694 if (str != NULL)
1695 (void) printf("%s", str);
1696 else
1697 (void) printf("%-7d", flock.l_type);
1699 str = whencearg(flock.l_whence);
1700 if (str != NULL)
1701 (void) printf(" whence=%s", str);
1702 else
1703 (void) printf(" whence=%-8u", flock.l_whence);
1705 (void) printf(
1706 " start=%-5lld len=%-5lld sys=%-2u pid=%d\n",
1707 (long long)flock.l_start,
1708 (long long)flock.l_len,
1709 flock.l_sysid,
1710 (int)flock.l_pid);
1714 void
1715 show_share(private_t *pri, long offset)
1717 struct fshare fshare;
1719 if (Pread(Proc, &fshare, sizeof (fshare), offset) == sizeof (fshare)) {
1720 const char *str = NULL;
1721 int manddny = 0;
1723 (void) printf("%s\taccess=", pri->pname);
1725 switch (fshare.f_access) {
1726 case F_RDACC:
1727 str = "F_RDACC";
1728 break;
1729 case F_WRACC:
1730 str = "F_WRACC";
1731 break;
1732 case F_RWACC:
1733 str = "F_RWACC";
1734 break;
1736 if (str != NULL)
1737 (void) printf("%s", str);
1738 else
1739 (void) printf("%-7d", fshare.f_access);
1741 str = NULL;
1742 if (fshare.f_deny & F_MANDDNY) {
1743 fshare.f_deny &= ~F_MANDDNY;
1744 manddny = 1;
1746 switch (fshare.f_deny) {
1747 case F_NODNY:
1748 str = "F_NODNY";
1749 break;
1750 case F_RDDNY:
1751 str = "F_RDDNY";
1752 break;
1753 case F_WRDNY:
1754 str = "F_WRDNY";
1755 break;
1756 case F_RWDNY:
1757 str = "F_RWDNY";
1758 break;
1759 case F_COMPAT:
1760 str = "F_COMPAT";
1761 break;
1763 if (str != NULL) {
1764 if (manddny)
1765 (void) printf(" deny=F_MANDDNY|%s", str);
1766 else
1767 (void) printf(" deny=%s", str);
1768 } else {
1769 (void) printf(" deny=0x%x", manddny?
1770 fshare.f_deny | F_MANDDNY : fshare.f_deny);
1773 (void) printf(" id=%x\n", fshare.f_id);
1777 void
1778 show_ffg(private_t *pri)
1780 (void) putchar('\t');
1781 (void) putchar('\t');
1782 prt_ffg(pri, 0, pri->Rval1);
1783 (void) puts(pri->sys_string);
1786 /* print values in fcntl() pointed-to structure */
1787 void
1788 show_fcntl(private_t *pri)
1790 long offset;
1792 if (pri->sys_nargs >= 2 && pri->sys_args[1] == F_GETFL) {
1793 show_ffg(pri);
1794 return;
1797 if (pri->sys_nargs < 3 || (offset = pri->sys_args[2]) == 0)
1798 return;
1800 switch (pri->sys_args[1]) {
1801 #ifdef _LP64
1802 case F_GETLK:
1803 case F_SETLK:
1804 case F_SETLKW:
1805 case F_FREESP:
1806 case F_ALLOCSP:
1807 case F_SETLK_NBMAND:
1808 case F_OFD_GETLK:
1809 case F_OFD_SETLK:
1810 case F_OFD_SETLKW:
1811 case F_FLOCK:
1812 case F_FLOCKW:
1813 if (data_model == PR_MODEL_LP64)
1814 show_flock64(pri, offset);
1815 else
1816 show_flock32(pri, offset);
1817 break;
1818 case 33: /* F_GETLK64 */
1819 case 34: /* F_SETLK64 */
1820 case 35: /* F_SETLKW64 */
1821 case 27: /* F_FREESP64 */
1822 case 28: /* F_ALLOCSP64 */
1823 case 44: /* F_SETLK64_NBMAND */
1824 case 50: /* F_OFD_GETLK64 */
1825 case 51: /* F_OFD_SETLK64 */
1826 case 52: /* F_OFD_SETLKW64 */
1827 case 55: /* F_FLOCK64 */
1828 case 56: /* F_FLOCKW64 */
1829 show_flock64(pri, offset);
1830 break;
1831 #else /* _LP64 */
1832 case F_GETLK64:
1833 case F_SETLK64:
1834 case F_SETLKW64:
1835 case F_FREESP64:
1836 case F_ALLOCSP64:
1837 case F_SETLK64_NBMAND:
1838 case F_OFD_GETLK64:
1839 case F_OFD_SETLK64:
1840 case F_OFD_SETLKW64:
1841 case F_FLOCK64:
1842 case F_FLOCKW64:
1843 show_flock64(pri, offset);
1844 break;
1845 #endif /* _LP64 */
1846 case F_SHARE:
1847 case F_UNSHARE:
1848 show_share(pri, offset);
1849 break;
1853 void
1854 show_strbuf(private_t *pri, long offset, const char *name, int dump)
1856 struct strbuf strbuf;
1858 if (Pread(Proc, &strbuf, sizeof (strbuf), offset) == sizeof (strbuf))
1859 print_strbuf(pri, &strbuf, name, dump);
1862 #ifdef _LP64
1863 void
1864 show_strbuf32(private_t *pri, long offset, const char *name, int dump)
1866 struct strbuf32 strbuf;
1868 if (Pread(Proc, &strbuf, sizeof (strbuf), offset) == sizeof (strbuf))
1869 print_strbuf32(pri, &strbuf, name, dump);
1871 #endif /* _LP64 */
1873 void
1874 show_gp_msg(private_t *pri, int what)
1876 long offset;
1877 int dump = FALSE;
1878 int fdp1 = pri->sys_args[0] + 1;
1880 switch (what) {
1881 case SYS_getmsg:
1882 case SYS_getpmsg:
1883 if (pri->Errno == 0 && prismember(&readfd, fdp1))
1884 dump = TRUE;
1885 break;
1886 case SYS_putmsg:
1887 case SYS_putpmsg:
1888 if (prismember(&writefd, fdp1))
1889 dump = TRUE;
1890 break;
1893 /* enter region of lengthy output */
1894 if (dump)
1895 Eserialize();
1897 #ifdef _LP64
1898 if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != 0) {
1899 if (data_model == PR_MODEL_LP64)
1900 show_strbuf(pri, offset, "ctl", dump);
1901 else
1902 show_strbuf32(pri, offset, "ctl", dump);
1904 if (pri->sys_nargs >= 3 && (offset = pri->sys_args[2]) != 0) {
1905 if (data_model == PR_MODEL_LP64)
1906 show_strbuf(pri, offset, "dat", dump);
1907 else
1908 show_strbuf32(pri, offset, "dat", dump);
1910 #else /* _LP64 */
1911 if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != 0)
1912 show_strbuf(pri, offset, "ctl", dump);
1913 if (pri->sys_nargs >= 3 && (offset = pri->sys_args[2]) != 0)
1914 show_strbuf(pri, offset, "dat", dump);
1915 #endif /* _LP64 */
1917 /* exit region of lengthy output */
1918 if (dump)
1919 Xserialize();
1922 void
1923 show_int(private_t *pri, long offset, const char *name)
1925 int value;
1927 if (offset != 0 &&
1928 Pread(Proc, &value, sizeof (value), offset) == sizeof (value))
1929 (void) printf("%s\t%s:\t%d\n",
1930 pri->pname,
1931 name,
1932 value);
1935 void
1936 show_hhex_int(private_t *pri, long offset, const char *name)
1938 int value;
1940 if (Pread(Proc, &value, sizeof (value), offset) == sizeof (value))
1941 (void) printf("%s\t%s:\t0x%.4X\n",
1942 pri->pname,
1943 name,
1944 value);
1947 #define ALL_POLL_FLAGS (POLLIN|POLLPRI|POLLOUT| \
1948 POLLRDNORM|POLLRDBAND|POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
1950 const char *
1951 pollevent(private_t *pri, int arg)
1953 char *str = pri->code_buf;
1955 if (arg == 0)
1956 return ("0");
1957 if (arg & ~ALL_POLL_FLAGS) {
1958 (void) sprintf(str, "0x%-5X", arg);
1959 return ((const char *)str);
1962 *str = '\0';
1963 if (arg & POLLIN)
1964 (void) strcat(str, "|POLLIN");
1965 if (arg & POLLPRI)
1966 (void) strcat(str, "|POLLPRI");
1967 if (arg & POLLOUT)
1968 (void) strcat(str, "|POLLOUT");
1969 if (arg & POLLRDNORM)
1970 (void) strcat(str, "|POLLRDNORM");
1971 if (arg & POLLRDBAND)
1972 (void) strcat(str, "|POLLRDBAND");
1973 if (arg & POLLWRBAND)
1974 (void) strcat(str, "|POLLWRBAND");
1975 if (arg & POLLERR)
1976 (void) strcat(str, "|POLLERR");
1977 if (arg & POLLHUP)
1978 (void) strcat(str, "|POLLHUP");
1979 if (arg & POLLNVAL)
1980 (void) strcat(str, "|POLLNVAL");
1982 return ((const char *)(str+1));
1985 static void
1986 show_one_pollfd(private_t *pri, struct pollfd *ppollfd)
1989 * can't print both events and revents in same printf.
1990 * pollevent() returns a pointer to a TSD location.
1992 (void) printf("%s\tfd=%-2d ev=%s",
1993 pri->pname, ppollfd->fd, pollevent(pri, ppollfd->events));
1994 (void) printf(" rev=%s\n", pollevent(pri, ppollfd->revents));
1997 static void
1998 show_all_pollfds(private_t *pri, long offset, int nfds)
2000 struct pollfd pollfd[2];
2001 int skip = -1;
2003 for (; nfds && !interrupt; nfds--, offset += sizeof (struct pollfd)) {
2004 if (Pread(Proc, &pollfd[0], sizeof (struct pollfd), offset) !=
2005 sizeof (struct pollfd))
2006 continue;
2008 if (skip >= 0 && pollfd[0].fd == pollfd[1].fd &&
2009 pollfd[0].events == pollfd[1].events &&
2010 pollfd[0].revents == pollfd[1].revents) {
2011 skip++;
2012 continue;
2015 if (skip > 0)
2016 (void) printf("%s\t...last pollfd structure"
2017 " repeated %d time%s...\n",
2018 pri->pname, skip, (skip == 1 ? "" : "s"));
2020 skip = 0;
2021 show_one_pollfd(pri, &pollfd[0]);
2022 pollfd[1] = pollfd[0];
2025 if (skip > 0)
2026 (void) printf(
2027 "%s\t...last pollfd structure repeated %d time%s...\n",
2028 pri->pname, skip, (skip == 1 ? "" : "s"));
2031 void
2032 show_pollsys(private_t *pri)
2034 long offset;
2035 int nfds;
2036 int serial = 0;
2038 if (pri->sys_nargs < 2)
2039 return;
2041 offset = pri->sys_args[0];
2042 nfds = pri->sys_args[1];
2044 /* enter region of lengthy output */
2045 if (offset != 0 && nfds > 32) {
2046 Eserialize();
2047 serial = 1;
2050 if (offset != 0 && nfds > 0)
2051 show_all_pollfds(pri, offset, nfds);
2053 if (pri->sys_nargs > 2)
2054 show_timestruc(pri, (long)pri->sys_args[2], "timeout");
2056 if (pri->sys_nargs > 3)
2057 show_sigset(pri, (long)pri->sys_args[3], "sigmask");
2059 /* exit region of lengthy output */
2060 if (serial)
2061 Xserialize();
2064 static void
2065 show_perm64(private_t *pri, struct ipc_perm64 *ip)
2067 (void) printf("%s\tu=%-5u g=%-5u cu=%-5u cg=%-5u z=%-5d "
2068 "m=0%.6o key=%d projid=%-5d\n",
2069 pri->pname,
2070 ip->ipcx_uid,
2071 ip->ipcx_gid,
2072 ip->ipcx_cuid,
2073 ip->ipcx_cgid,
2074 (int)ip->ipcx_zoneid,
2075 (unsigned int)ip->ipcx_mode,
2076 ip->ipcx_key,
2077 (int)ip->ipcx_projid);
2080 void
2081 show_perm(private_t *pri, struct ipc_perm *ip)
2083 (void) printf(
2084 "%s\tu=%-5u g=%-5u cu=%-5u cg=%-5u m=0%.6o seq=%u key=%d\n",
2085 pri->pname,
2086 ip->uid,
2087 ip->gid,
2088 ip->cuid,
2089 ip->cgid,
2090 (int)ip->mode,
2091 ip->seq,
2092 ip->key);
2095 #ifdef _LP64
2096 void
2097 show_perm32(private_t *pri, struct ipc_perm32 *ip)
2099 (void) printf(
2100 "%s\tu=%-5u g=%-5u cu=%-5u cg=%-5u m=0%.6o seq=%u key=%d\n",
2101 pri->pname,
2102 ip->uid,
2103 ip->gid,
2104 ip->cuid,
2105 ip->cgid,
2106 ip->mode,
2107 ip->seq,
2108 ip->key);
2110 #endif /* _LP64 */
2112 static void
2113 show_msgctl64(private_t *pri, long offset)
2115 struct msqid_ds64 msgq;
2117 if (offset != 0 &&
2118 Pread(Proc, &msgq, sizeof (msgq), offset) == sizeof (msgq)) {
2119 show_perm64(pri, &msgq.msgx_perm);
2121 (void) printf("%s\tbytes=%-5llu msgs=%-5llu maxby=%-5llu "
2122 "lspid=%-5d lrpid=%-5d\n", pri->pname,
2123 (unsigned long long)msgq.msgx_cbytes,
2124 (unsigned long long)msgq.msgx_qnum,
2125 (unsigned long long)msgq.msgx_qbytes,
2126 (int)msgq.msgx_lspid,
2127 (int)msgq.msgx_lrpid);
2129 prtime(pri, " st = ", (time_t)msgq.msgx_stime);
2130 prtime(pri, " rt = ", (time_t)msgq.msgx_rtime);
2131 prtime(pri, " ct = ", (time_t)msgq.msgx_ctime);
2135 void
2136 show_msgctl(private_t *pri, long offset)
2138 struct msqid_ds msgq;
2140 if (offset != 0 &&
2141 Pread(Proc, &msgq, sizeof (msgq), offset) == sizeof (msgq)) {
2142 show_perm(pri, &msgq.msg_perm);
2144 (void) printf(
2145 "%s\tbytes=%-5lu msgs=%-5lu maxby=%-5lu lspid=%-5u lrpid=%-5u\n",
2146 pri->pname,
2147 msgq.msg_cbytes,
2148 msgq.msg_qnum,
2149 msgq.msg_qbytes,
2150 (int)msgq.msg_lspid,
2151 (int)msgq.msg_lrpid);
2153 prtime(pri, " st = ", msgq.msg_stime);
2154 prtime(pri, " rt = ", msgq.msg_rtime);
2155 prtime(pri, " ct = ", msgq.msg_ctime);
2159 #ifdef _LP64
2160 void
2161 show_msgctl32(private_t *pri, long offset)
2163 struct msqid_ds32 msgq;
2165 if (offset != 0 &&
2166 Pread(Proc, &msgq, sizeof (msgq), offset) == sizeof (msgq)) {
2167 show_perm32(pri, &msgq.msg_perm);
2169 (void) printf(
2170 "%s\tbytes=%-5u msgs=%-5u maxby=%-5u lspid=%-5u lrpid=%-5u\n",
2171 pri->pname,
2172 msgq.msg_cbytes,
2173 msgq.msg_qnum,
2174 msgq.msg_qbytes,
2175 msgq.msg_lspid,
2176 msgq.msg_lrpid);
2178 prtime(pri, " st = ", msgq.msg_stime);
2179 prtime(pri, " rt = ", msgq.msg_rtime);
2180 prtime(pri, " ct = ", msgq.msg_ctime);
2183 #endif /* _LP64 */
2185 void
2186 show_msgbuf(private_t *pri, long offset, long msgsz)
2188 struct msgbuf msgb;
2190 if (offset != 0 &&
2191 Pread(Proc, &msgb, sizeof (msgb.mtype), offset) ==
2192 sizeof (msgb.mtype)) {
2193 /* enter region of lengthy output */
2194 if (msgsz > MYBUFSIZ / 4)
2195 Eserialize();
2197 (void) printf("%s\tmtype=%lu mtext[]=\n",
2198 pri->pname,
2199 msgb.mtype);
2200 showbuffer(pri,
2201 (long)(offset + sizeof (msgb.mtype)), msgsz);
2203 /* exit region of lengthy output */
2204 if (msgsz > MYBUFSIZ / 4)
2205 Xserialize();
2209 #ifdef _LP64
2210 void
2211 show_msgbuf32(private_t *pri, long offset, long msgsz)
2213 struct ipcmsgbuf32 msgb;
2215 if (offset != 0 &&
2216 Pread(Proc, &msgb, sizeof (msgb.mtype), offset) ==
2217 sizeof (msgb.mtype)) {
2218 /* enter region of lengthy output */
2219 if (msgsz > MYBUFSIZ / 4)
2220 Eserialize();
2222 (void) printf("%s\tmtype=%u mtext[]=\n",
2223 pri->pname,
2224 msgb.mtype);
2225 showbuffer(pri,
2226 (long)(offset + sizeof (msgb.mtype)), msgsz);
2228 /* exit region of lengthy output */
2229 if (msgsz > MYBUFSIZ / 4)
2230 Xserialize();
2233 #endif /* _LP64 */
2235 #ifdef _LP64
2236 void
2237 show_msgsys(private_t *pri, long msgsz)
2239 switch (pri->sys_args[0]) {
2240 case 0: /* msgget() */
2241 break;
2242 case 1: /* msgctl() */
2243 if (pri->sys_nargs > 3) {
2244 switch (pri->sys_args[2]) {
2245 case IPC_STAT:
2246 if (pri->Errno)
2247 break;
2248 /*FALLTHROUGH*/
2249 case IPC_SET:
2250 if (data_model == PR_MODEL_LP64)
2251 show_msgctl(pri,
2252 (long)pri->sys_args[3]);
2253 else
2254 show_msgctl32(pri,
2255 (long)pri->sys_args[3]);
2256 break;
2257 case IPC_STAT64:
2258 if (pri->Errno)
2259 break;
2260 /*FALLTHROUGH*/
2261 case IPC_SET64:
2262 show_msgctl64(pri, (long)pri->sys_args[3]);
2263 break;
2266 break;
2267 case 2: /* msgrcv() */
2268 if (!pri->Errno && pri->sys_nargs > 2) {
2269 if (data_model == PR_MODEL_LP64)
2270 show_msgbuf(pri, pri->sys_args[2], msgsz);
2271 else
2272 show_msgbuf32(pri, pri->sys_args[2], msgsz);
2274 break;
2275 case 3: /* msgsnd() */
2276 if (pri->sys_nargs > 3) {
2277 if (data_model == PR_MODEL_LP64)
2278 show_msgbuf(pri, pri->sys_args[2],
2279 pri->sys_args[3]);
2280 else
2281 show_msgbuf32(pri, pri->sys_args[2],
2282 pri->sys_args[3]);
2284 break;
2285 case 4: /* msgids() */
2286 case 5: /* msgsnap() */
2287 default: /* unexpected subcode */
2288 break;
2291 #else /* _LP64 */
2292 void
2293 show_msgsys(private_t *pri, long msgsz)
2295 switch (pri->sys_args[0]) {
2296 case 0: /* msgget() */
2297 break;
2298 case 1: /* msgctl() */
2299 if (pri->sys_nargs > 3) {
2300 switch (pri->sys_args[2]) {
2301 case IPC_STAT:
2302 if (pri->Errno)
2303 break;
2304 /*FALLTHROUGH*/
2305 case IPC_SET:
2306 show_msgctl(pri, (long)pri->sys_args[3]);
2307 break;
2308 case IPC_STAT64:
2309 if (pri->Errno)
2310 break;
2311 /*FALLTHROUGH*/
2312 case IPC_SET64:
2313 show_msgctl64(pri, (long)pri->sys_args[3]);
2314 break;
2317 break;
2318 case 2: /* msgrcv() */
2319 if (!pri->Errno && pri->sys_nargs > 2)
2320 show_msgbuf(pri, pri->sys_args[2], msgsz);
2321 break;
2322 case 3: /* msgsnd() */
2323 if (pri->sys_nargs > 3)
2324 show_msgbuf(pri, pri->sys_args[2],
2325 pri->sys_args[3]);
2326 break;
2327 case 4: /* msgids() */
2328 case 5: /* msgsnap() */
2329 default: /* unexpected subcode */
2330 break;
2333 #endif /* _LP64 */
2335 static void
2336 show_semctl64(private_t *pri, long offset)
2338 struct semid_ds64 semds;
2340 if (offset != 0 &&
2341 Pread(Proc, &semds, sizeof (semds), offset) == sizeof (semds)) {
2342 show_perm64(pri, &semds.semx_perm);
2344 (void) printf("%s\tnsems=%u\n", pri->pname, semds.semx_nsems);
2346 prtime(pri, " ot = ", (time_t)semds.semx_otime);
2347 prtime(pri, " ct = ", (time_t)semds.semx_ctime);
2351 void
2352 show_semctl(private_t *pri, long offset)
2354 struct semid_ds semds;
2356 if (offset != 0 &&
2357 Pread(Proc, &semds, sizeof (semds), offset) == sizeof (semds)) {
2358 show_perm(pri, &semds.sem_perm);
2360 (void) printf("%s\tnsems=%u\n",
2361 pri->pname,
2362 semds.sem_nsems);
2364 prtime(pri, " ot = ", semds.sem_otime);
2365 prtime(pri, " ct = ", semds.sem_ctime);
2369 #ifdef _LP64
2370 void
2371 show_semctl32(private_t *pri, long offset)
2373 struct semid_ds32 semds;
2375 if (offset != 0 &&
2376 Pread(Proc, &semds, sizeof (semds), offset) == sizeof (semds)) {
2377 show_perm32(pri, &semds.sem_perm);
2379 (void) printf("%s\tnsems=%u\n",
2380 pri->pname,
2381 semds.sem_nsems);
2383 prtime(pri, " ot = ", semds.sem_otime);
2384 prtime(pri, " ct = ", semds.sem_ctime);
2387 #endif /* _LP64 */
2389 void
2390 show_semop(private_t *pri, long offset, long nsops, long timeout)
2392 struct sembuf sembuf;
2393 const char *str;
2395 if (offset == 0)
2396 return;
2398 if (nsops > 40) /* let's not be ridiculous */
2399 nsops = 40;
2401 for (; nsops > 0 && !interrupt; --nsops, offset += sizeof (sembuf)) {
2402 if (Pread(Proc, &sembuf, sizeof (sembuf), offset) !=
2403 sizeof (sembuf))
2404 break;
2406 (void) printf("%s\tsemnum=%-5u semop=%-5d semflg=",
2407 pri->pname,
2408 sembuf.sem_num,
2409 sembuf.sem_op);
2411 if (sembuf.sem_flg == 0)
2412 (void) printf("0\n");
2413 else if ((str = semflags(pri, sembuf.sem_flg)) != NULL)
2414 (void) printf("%s\n", str);
2415 else
2416 (void) printf("0%.6o\n", sembuf.sem_flg);
2418 if (timeout)
2419 show_timestruc(pri, timeout, "timeout");
2422 void
2423 show_semsys(private_t *pri)
2425 switch (pri->sys_args[0]) {
2426 case 0: /* semctl() */
2427 if (pri->sys_nargs > 4) {
2428 switch (pri->sys_args[3]) {
2429 case IPC_STAT:
2430 if (pri->Errno)
2431 break;
2432 /*FALLTHROUGH*/
2433 case IPC_SET:
2434 #ifdef _LP64
2435 if (data_model == PR_MODEL_LP64)
2436 show_semctl(pri,
2437 (long)pri->sys_args[4]);
2438 else
2439 show_semctl32(pri,
2440 (long)pri->sys_args[4]);
2441 #else
2442 show_semctl(pri, (long)pri->sys_args[4]);
2443 #endif
2444 break;
2445 case IPC_STAT64:
2446 if (pri->Errno)
2447 break;
2448 /*FALLTHROUGH*/
2449 case IPC_SET64:
2450 show_semctl64(pri, (long)pri->sys_args[4]);
2451 break;
2454 break;
2455 case 1: /* semget() */
2456 break;
2457 case 2: /* semop() */
2458 if (pri->sys_nargs > 3)
2459 show_semop(pri, (long)pri->sys_args[2],
2460 pri->sys_args[3], 0);
2461 break;
2462 case 3: /* semids() */
2463 break;
2464 case 4: /* semtimedop() */
2465 if (pri->sys_nargs > 4)
2466 show_semop(pri, (long)pri->sys_args[2],
2467 pri->sys_args[3], pri->sys_args[4]);
2468 break;
2469 default: /* unexpected subcode */
2470 break;
2474 static void
2475 show_shmctl64(private_t *pri, long offset)
2477 struct shmid_ds64 shmds;
2479 if (offset != 0 &&
2480 Pread(Proc, &shmds, sizeof (shmds), offset) == sizeof (shmds)) {
2481 show_perm64(pri, &shmds.shmx_perm);
2483 (void) printf(
2484 "%s\tsize=%-6llu lpid=%-5d cpid=%-5d na=%-5llu cna=%llu\n",
2485 pri->pname,
2486 (unsigned long long)shmds.shmx_segsz,
2487 (int)shmds.shmx_lpid,
2488 (int)shmds.shmx_cpid,
2489 (unsigned long long)shmds.shmx_nattch,
2490 (unsigned long long)shmds.shmx_cnattch);
2492 prtime(pri, " at = ", (time_t)shmds.shmx_atime);
2493 prtime(pri, " dt = ", (time_t)shmds.shmx_dtime);
2494 prtime(pri, " ct = ", (time_t)shmds.shmx_ctime);
2498 void
2499 show_shmctl(private_t *pri, long offset)
2501 struct shmid_ds shmds;
2503 if (offset != 0 &&
2504 Pread(Proc, &shmds, sizeof (shmds), offset) == sizeof (shmds)) {
2505 show_perm(pri, &shmds.shm_perm);
2507 (void) printf(
2508 "%s\tsize=%-6lu lpid=%-5u cpid=%-5u na=%-5lu cna=%lu\n",
2509 pri->pname,
2510 (ulong_t)shmds.shm_segsz,
2511 (int)shmds.shm_lpid,
2512 (int)shmds.shm_cpid,
2513 shmds.shm_nattch,
2514 shmds.shm_cnattch);
2516 prtime(pri, " at = ", shmds.shm_atime);
2517 prtime(pri, " dt = ", shmds.shm_dtime);
2518 prtime(pri, " ct = ", shmds.shm_ctime);
2522 #ifdef _LP64
2523 void
2524 show_shmctl32(private_t *pri, long offset)
2526 struct shmid_ds32 shmds;
2528 if (offset != 0 &&
2529 Pread(Proc, &shmds, sizeof (shmds), offset) == sizeof (shmds)) {
2530 show_perm32(pri, &shmds.shm_perm);
2532 (void) printf(
2533 "%s\tsize=%-6u lpid=%-5u cpid=%-5u na=%-5u cna=%u\n",
2534 pri->pname,
2535 shmds.shm_segsz,
2536 shmds.shm_lpid,
2537 shmds.shm_cpid,
2538 shmds.shm_nattch,
2539 shmds.shm_cnattch);
2541 prtime(pri, " at = ", shmds.shm_atime);
2542 prtime(pri, " dt = ", shmds.shm_dtime);
2543 prtime(pri, " ct = ", shmds.shm_ctime);
2546 #endif /* _LP64 */
2548 void
2549 show_shmsys(private_t *pri)
2551 switch (pri->sys_args[0]) {
2552 case 0: /* shmat() */
2553 break;
2554 case 1: /* shmctl() */
2555 if (pri->sys_nargs > 3) {
2556 switch (pri->sys_args[2]) {
2557 case IPC_STAT:
2558 if (pri->Errno)
2559 break;
2560 /*FALLTHROUGH*/
2561 case IPC_SET:
2562 #ifdef _LP64
2563 if (data_model == PR_MODEL_LP64)
2564 show_shmctl(pri,
2565 (long)pri->sys_args[3]);
2566 else
2567 show_shmctl32(pri,
2568 (long)pri->sys_args[3]);
2569 #else
2570 show_shmctl(pri, (long)pri->sys_args[3]);
2571 #endif
2572 break;
2573 case IPC_STAT64:
2574 if (pri->Errno)
2575 break;
2576 /*FALLTHROUGH*/
2577 case IPC_SET64:
2578 show_shmctl64(pri, (long)pri->sys_args[3]);
2579 break;
2582 break;
2583 case 2: /* shmdt() */
2584 case 3: /* shmget() */
2585 case 4: /* shmids() */
2586 default: /* unexpected subcode */
2587 break;
2591 void
2592 show_groups(private_t *pri, long offset, long count)
2594 int groups[100];
2596 if (count > 100)
2597 count = 100;
2599 if (count > 0 && offset != 0 &&
2600 Pread(Proc, &groups[0], count*sizeof (int), offset) ==
2601 count*sizeof (int)) {
2602 int n;
2604 (void) printf("%s\t", pri->pname);
2605 for (n = 0; !interrupt && n < count; n++) {
2606 if (n != 0 && n%10 == 0)
2607 (void) printf("\n%s\t", pri->pname);
2608 (void) printf(" %5d", groups[n]);
2610 (void) fputc('\n', stdout);
2615 * This assumes that a sigset_t is simply an array of ints.
2617 char *
2618 sigset_string(private_t *pri, sigset_t *sp)
2620 char *s = pri->code_buf;
2621 int n = sizeof (*sp) / sizeof (int32_t);
2622 int32_t *lp = (int32_t *)sp;
2624 while (--n >= 0) {
2625 int32_t val = *lp++;
2627 if (val == 0)
2628 s += sprintf(s, " 0");
2629 else
2630 s += sprintf(s, " 0x%.8X", val);
2633 return (pri->code_buf);
2636 void
2637 show_sigset(private_t *pri, long offset, const char *name)
2639 sigset_t sigset;
2641 if (offset != 0 &&
2642 Pread(Proc, &sigset, sizeof (sigset), offset) == sizeof (sigset)) {
2643 (void) printf("%s\t%s =%s\n",
2644 pri->pname, name, sigset_string(pri, &sigset));
2648 #ifdef _LP64
2649 void
2650 show_sigaltstack32(private_t *pri, long offset, const char *name)
2652 struct sigaltstack32 altstack;
2654 if (offset != 0 &&
2655 Pread(Proc, &altstack, sizeof (altstack), offset) ==
2656 sizeof (altstack)) {
2657 (void) printf("%s\t%s: sp=0x%.8X size=%u flags=0x%.4X\n",
2658 pri->pname,
2659 name,
2660 altstack.ss_sp,
2661 altstack.ss_size,
2662 altstack.ss_flags);
2665 #endif /* _LP64 */
2667 void
2668 show_sigaltstack(private_t *pri, long offset, const char *name)
2670 struct sigaltstack altstack;
2672 #ifdef _LP64
2673 if (data_model != PR_MODEL_LP64) {
2674 show_sigaltstack32(pri, offset, name);
2675 return;
2677 #endif
2678 if (offset != 0 &&
2679 Pread(Proc, &altstack, sizeof (altstack), offset) ==
2680 sizeof (altstack)) {
2681 (void) printf("%s\t%s: sp=0x%.8lX size=%lu flags=0x%.4X\n",
2682 pri->pname,
2683 name,
2684 (ulong_t)altstack.ss_sp,
2685 (ulong_t)altstack.ss_size,
2686 altstack.ss_flags);
2690 #ifdef _LP64
2691 void
2692 show_sigaction32(private_t *pri, long offset, const char *name, long odisp)
2694 struct sigaction32 sigaction;
2696 if (offset != 0 &&
2697 Pread(Proc, &sigaction, sizeof (sigaction), offset) ==
2698 sizeof (sigaction)) {
2699 /* This is stupid, we shouldn't have to do this */
2700 if (odisp != 0)
2701 sigaction.sa_handler = (caddr32_t)odisp;
2702 (void) printf(
2703 "%s %s: hand = 0x%.8X mask =%s flags = 0x%.4X\n",
2704 pri->pname,
2705 name,
2706 sigaction.sa_handler,
2707 sigset_string(pri, (sigset_t *)&sigaction.sa_mask),
2708 sigaction.sa_flags);
2711 #endif /* _LP64 */
2713 void
2714 show_sigaction(private_t *pri, long offset, const char *name, long odisp)
2716 struct sigaction sigaction;
2718 #ifdef _LP64
2719 if (data_model != PR_MODEL_LP64) {
2720 show_sigaction32(pri, offset, name, odisp);
2721 return;
2723 #endif
2724 if (offset != 0 &&
2725 Pread(Proc, &sigaction, sizeof (sigaction), offset) ==
2726 sizeof (sigaction)) {
2727 /* This is stupid, we shouldn't have to do this */
2728 if (odisp != 0)
2729 sigaction.sa_handler = (void (*)())odisp;
2730 (void) printf(
2731 "%s %s: hand = 0x%.8lX mask =%s flags = 0x%.4X\n",
2732 pri->pname,
2733 name,
2734 (long)sigaction.sa_handler,
2735 sigset_string(pri, &sigaction.sa_mask),
2736 sigaction.sa_flags);
2740 #ifdef _LP64
2741 void
2742 print_siginfo32(private_t *pri, const siginfo32_t *sip)
2744 const char *code = NULL;
2746 (void) printf("%s siginfo: %s", pri->pname,
2747 signame(pri, sip->si_signo));
2749 if (sip->si_signo != 0 && SI_FROMUSER(sip) && sip->si_pid != 0) {
2750 (void) printf(" pid=%d uid=%d", sip->si_pid, sip->si_uid);
2751 if (sip->si_code != 0)
2752 (void) printf(" code=%d", sip->si_code);
2753 (void) fputc('\n', stdout);
2754 return;
2757 switch (sip->si_signo) {
2758 default:
2759 (void) fputc('\n', stdout);
2760 return;
2761 case SIGILL:
2762 case SIGTRAP:
2763 case SIGFPE:
2764 case SIGSEGV:
2765 case SIGBUS:
2766 case SIGEMT:
2767 case SIGCLD:
2768 case SIGPOLL:
2769 case SIGXFSZ:
2770 break;
2773 switch (sip->si_signo) {
2774 case SIGILL:
2775 switch (sip->si_code) {
2776 case ILL_ILLOPC: code = "ILL_ILLOPC"; break;
2777 case ILL_ILLOPN: code = "ILL_ILLOPN"; break;
2778 case ILL_ILLADR: code = "ILL_ILLADR"; break;
2779 case ILL_ILLTRP: code = "ILL_ILLTRP"; break;
2780 case ILL_PRVOPC: code = "ILL_PRVOPC"; break;
2781 case ILL_PRVREG: code = "ILL_PRVREG"; break;
2782 case ILL_COPROC: code = "ILL_COPROC"; break;
2783 case ILL_BADSTK: code = "ILL_BADSTK"; break;
2785 break;
2786 case SIGTRAP:
2787 switch (sip->si_code) {
2788 case TRAP_BRKPT: code = "TRAP_BRKPT"; break;
2789 case TRAP_TRACE: code = "TRAP_TRACE"; break;
2790 case TRAP_RWATCH: code = "TRAP_RWATCH"; break;
2791 case TRAP_WWATCH: code = "TRAP_WWATCH"; break;
2792 case TRAP_XWATCH: code = "TRAP_XWATCH"; break;
2793 case TRAP_DTRACE: code = "TRAP_DTRACE"; break;
2795 break;
2796 case SIGFPE:
2797 switch (sip->si_code) {
2798 case FPE_INTDIV: code = "FPE_INTDIV"; break;
2799 case FPE_INTOVF: code = "FPE_INTOVF"; break;
2800 case FPE_FLTDIV: code = "FPE_FLTDIV"; break;
2801 case FPE_FLTOVF: code = "FPE_FLTOVF"; break;
2802 case FPE_FLTUND: code = "FPE_FLTUND"; break;
2803 case FPE_FLTRES: code = "FPE_FLTRES"; break;
2804 case FPE_FLTINV: code = "FPE_FLTINV"; break;
2805 case FPE_FLTSUB: code = "FPE_FLTSUB"; break;
2806 #if defined(FPE_FLTDEN)
2807 case FPE_FLTDEN: code = "FPE_FLTDEN"; break;
2808 #endif
2810 break;
2811 case SIGSEGV:
2812 switch (sip->si_code) {
2813 case SEGV_MAPERR: code = "SEGV_MAPERR"; break;
2814 case SEGV_ACCERR: code = "SEGV_ACCERR"; break;
2816 break;
2817 case SIGEMT:
2818 switch (sip->si_code) {
2819 #ifdef EMT_TAGOVF
2820 case EMT_TAGOVF: code = "EMT_TAGOVF"; break;
2821 #endif
2822 case EMT_CPCOVF: code = "EMT_CPCOVF"; break;
2824 break;
2825 case SIGBUS:
2826 switch (sip->si_code) {
2827 case BUS_ADRALN: code = "BUS_ADRALN"; break;
2828 case BUS_ADRERR: code = "BUS_ADRERR"; break;
2829 case BUS_OBJERR: code = "BUS_OBJERR"; break;
2831 break;
2832 case SIGCLD:
2833 switch (sip->si_code) {
2834 case CLD_EXITED: code = "CLD_EXITED"; break;
2835 case CLD_KILLED: code = "CLD_KILLED"; break;
2836 case CLD_DUMPED: code = "CLD_DUMPED"; break;
2837 case CLD_TRAPPED: code = "CLD_TRAPPED"; break;
2838 case CLD_STOPPED: code = "CLD_STOPPED"; break;
2839 case CLD_CONTINUED: code = "CLD_CONTINUED"; break;
2841 break;
2842 case SIGPOLL:
2843 switch (sip->si_code) {
2844 case POLL_IN: code = "POLL_IN"; break;
2845 case POLL_OUT: code = "POLL_OUT"; break;
2846 case POLL_MSG: code = "POLL_MSG"; break;
2847 case POLL_ERR: code = "POLL_ERR"; break;
2848 case POLL_PRI: code = "POLL_PRI"; break;
2849 case POLL_HUP: code = "POLL_HUP"; break;
2851 break;
2854 if (code == NULL) {
2855 (void) sprintf(pri->code_buf, "code=%d", sip->si_code);
2856 code = (const char *)pri->code_buf;
2859 switch (sip->si_signo) {
2860 case SIGILL:
2861 case SIGTRAP:
2862 case SIGFPE:
2863 case SIGSEGV:
2864 case SIGBUS:
2865 case SIGEMT:
2866 (void) printf(" %s addr=0x%.8X",
2867 code,
2868 sip->si_addr);
2869 break;
2870 case SIGCLD:
2871 (void) printf(" %s pid=%d status=0x%.4X",
2872 code,
2873 sip->si_pid,
2874 sip->si_status);
2875 break;
2876 case SIGPOLL:
2877 case SIGXFSZ:
2878 (void) printf(" %s fd=%d band=%d",
2879 code,
2880 sip->si_fd,
2881 sip->si_band);
2882 break;
2885 if (sip->si_errno != 0) {
2886 const char *ename = errname(sip->si_errno);
2888 (void) printf(" errno=%d", sip->si_errno);
2889 if (ename != NULL)
2890 (void) printf("(%s)", ename);
2893 (void) fputc('\n', stdout);
2895 #endif /* _LP64 */
2897 void
2898 print_siginfo(private_t *pri, const siginfo_t *sip)
2900 const char *code = NULL;
2902 (void) printf("%s siginfo: %s", pri->pname,
2903 signame(pri, sip->si_signo));
2905 if (sip->si_signo != 0 && SI_FROMUSER(sip) && sip->si_pid != 0) {
2906 (void) printf(" pid=%d uid=%u",
2907 (int)sip->si_pid,
2908 sip->si_uid);
2909 if (sip->si_code != 0)
2910 (void) printf(" code=%d", sip->si_code);
2911 (void) fputc('\n', stdout);
2912 return;
2915 switch (sip->si_signo) {
2916 default:
2917 (void) fputc('\n', stdout);
2918 return;
2919 case SIGILL:
2920 case SIGTRAP:
2921 case SIGFPE:
2922 case SIGSEGV:
2923 case SIGBUS:
2924 case SIGEMT:
2925 case SIGCLD:
2926 case SIGPOLL:
2927 case SIGXFSZ:
2928 break;
2931 switch (sip->si_signo) {
2932 case SIGILL:
2933 switch (sip->si_code) {
2934 case ILL_ILLOPC: code = "ILL_ILLOPC"; break;
2935 case ILL_ILLOPN: code = "ILL_ILLOPN"; break;
2936 case ILL_ILLADR: code = "ILL_ILLADR"; break;
2937 case ILL_ILLTRP: code = "ILL_ILLTRP"; break;
2938 case ILL_PRVOPC: code = "ILL_PRVOPC"; break;
2939 case ILL_PRVREG: code = "ILL_PRVREG"; break;
2940 case ILL_COPROC: code = "ILL_COPROC"; break;
2941 case ILL_BADSTK: code = "ILL_BADSTK"; break;
2943 break;
2944 case SIGTRAP:
2945 switch (sip->si_code) {
2946 case TRAP_BRKPT: code = "TRAP_BRKPT"; break;
2947 case TRAP_TRACE: code = "TRAP_TRACE"; break;
2948 case TRAP_RWATCH: code = "TRAP_RWATCH"; break;
2949 case TRAP_WWATCH: code = "TRAP_WWATCH"; break;
2950 case TRAP_XWATCH: code = "TRAP_XWATCH"; break;
2951 case TRAP_DTRACE: code = "TRAP_DTRACE"; break;
2953 break;
2954 case SIGFPE:
2955 switch (sip->si_code) {
2956 case FPE_INTDIV: code = "FPE_INTDIV"; break;
2957 case FPE_INTOVF: code = "FPE_INTOVF"; break;
2958 case FPE_FLTDIV: code = "FPE_FLTDIV"; break;
2959 case FPE_FLTOVF: code = "FPE_FLTOVF"; break;
2960 case FPE_FLTUND: code = "FPE_FLTUND"; break;
2961 case FPE_FLTRES: code = "FPE_FLTRES"; break;
2962 case FPE_FLTINV: code = "FPE_FLTINV"; break;
2963 case FPE_FLTSUB: code = "FPE_FLTSUB"; break;
2964 #if defined(FPE_FLTDEN)
2965 case FPE_FLTDEN: code = "FPE_FLTDEN"; break;
2966 #endif
2968 break;
2969 case SIGSEGV:
2970 switch (sip->si_code) {
2971 case SEGV_MAPERR: code = "SEGV_MAPERR"; break;
2972 case SEGV_ACCERR: code = "SEGV_ACCERR"; break;
2974 break;
2975 case SIGEMT:
2976 switch (sip->si_code) {
2977 #ifdef EMT_TAGOVF
2978 case EMT_TAGOVF: code = "EMT_TAGOVF"; break;
2979 #endif
2980 case EMT_CPCOVF: code = "EMT_CPCOVF"; break;
2982 break;
2983 case SIGBUS:
2984 switch (sip->si_code) {
2985 case BUS_ADRALN: code = "BUS_ADRALN"; break;
2986 case BUS_ADRERR: code = "BUS_ADRERR"; break;
2987 case BUS_OBJERR: code = "BUS_OBJERR"; break;
2989 break;
2990 case SIGCLD:
2991 switch (sip->si_code) {
2992 case CLD_EXITED: code = "CLD_EXITED"; break;
2993 case CLD_KILLED: code = "CLD_KILLED"; break;
2994 case CLD_DUMPED: code = "CLD_DUMPED"; break;
2995 case CLD_TRAPPED: code = "CLD_TRAPPED"; break;
2996 case CLD_STOPPED: code = "CLD_STOPPED"; break;
2997 case CLD_CONTINUED: code = "CLD_CONTINUED"; break;
2999 break;
3000 case SIGPOLL:
3001 switch (sip->si_code) {
3002 case POLL_IN: code = "POLL_IN"; break;
3003 case POLL_OUT: code = "POLL_OUT"; break;
3004 case POLL_MSG: code = "POLL_MSG"; break;
3005 case POLL_ERR: code = "POLL_ERR"; break;
3006 case POLL_PRI: code = "POLL_PRI"; break;
3007 case POLL_HUP: code = "POLL_HUP"; break;
3009 break;
3012 if (code == NULL) {
3013 (void) sprintf(pri->code_buf, "code=%d", sip->si_code);
3014 code = (const char *)pri->code_buf;
3017 switch (sip->si_signo) {
3018 case SIGILL:
3019 case SIGTRAP:
3020 case SIGFPE:
3021 case SIGSEGV:
3022 case SIGBUS:
3023 case SIGEMT:
3024 (void) printf(" %s addr=0x%.8lX",
3025 code,
3026 (long)sip->si_addr);
3027 break;
3028 case SIGCLD:
3029 (void) printf(" %s pid=%d status=0x%.4X",
3030 code,
3031 (int)sip->si_pid,
3032 sip->si_status);
3033 break;
3034 case SIGPOLL:
3035 case SIGXFSZ:
3036 (void) printf(" %s fd=%d band=%ld",
3037 code,
3038 sip->si_fd,
3039 sip->si_band);
3040 break;
3043 if (sip->si_errno != 0) {
3044 const char *ename = errname(sip->si_errno);
3046 (void) printf(" errno=%d", sip->si_errno);
3047 if (ename != NULL)
3048 (void) printf("(%s)", ename);
3051 (void) fputc('\n', stdout);
3054 #ifdef _LP64
3055 void
3056 show_siginfo32(private_t *pri, long offset)
3058 struct siginfo32 siginfo;
3060 if (offset != 0 &&
3061 Pread(Proc, &siginfo, sizeof (siginfo), offset) == sizeof (siginfo))
3062 print_siginfo32(pri, &siginfo);
3064 #endif /* _LP64 */
3066 void
3067 show_siginfo(private_t *pri, long offset)
3069 struct siginfo siginfo;
3071 #ifdef _LP64
3072 if (data_model != PR_MODEL_LP64) {
3073 show_siginfo32(pri, offset);
3074 return;
3076 #endif
3077 if (offset != 0 &&
3078 Pread(Proc, &siginfo, sizeof (siginfo), offset) == sizeof (siginfo))
3079 print_siginfo(pri, &siginfo);
3082 void
3083 show_bool(private_t *pri, long offset, int count)
3085 int serial = (count > MYBUFSIZ / 4);
3087 /* enter region of lengthy output */
3088 if (serial)
3089 Eserialize();
3091 while (count > 0) {
3092 char buf[32];
3093 int nb = (count < 32)? count : 32;
3094 int i;
3096 if (Pread(Proc, buf, (size_t)nb, offset) != nb)
3097 break;
3099 (void) printf("%s ", pri->pname);
3100 for (i = 0; i < nb; i++)
3101 (void) printf(" %d", buf[i]);
3102 (void) fputc('\n', stdout);
3104 count -= nb;
3105 offset += nb;
3108 /* exit region of lengthy output */
3109 if (serial)
3110 Xserialize();
3113 #ifdef _LP64
3114 void
3115 show_iovec32(private_t *pri, long offset, int niov, int showbuf, long count)
3117 iovec32_t iovec[16];
3118 iovec32_t *ip;
3119 long nb;
3120 int serial = (count > MYBUFSIZ / 4 && showbuf);
3122 if (niov > 16) /* is this the real limit? */
3123 niov = 16;
3125 if (offset != 0 && niov > 0 &&
3126 Pread(Proc, &iovec[0], niov*sizeof (iovec32_t), offset)
3127 == niov*sizeof (iovec32_t)) {
3128 /* enter region of lengthy output */
3129 if (serial)
3130 Eserialize();
3132 for (ip = &iovec[0]; niov-- && !interrupt; ip++) {
3133 (void) printf("%s\tiov_base = 0x%.8X iov_len = %d\n",
3134 pri->pname,
3135 ip->iov_base,
3136 ip->iov_len);
3137 if ((nb = count) > 0) {
3138 if (nb > ip->iov_len)
3139 nb = ip->iov_len;
3140 if (nb > 0)
3141 count -= nb;
3143 if (showbuf && nb > 0)
3144 showbuffer(pri, (long)ip->iov_base, nb);
3147 /* exit region of lengthy output */
3148 if (serial)
3149 Xserialize();
3152 #endif /* _LP64 */
3154 void
3155 show_iovec(private_t *pri, long offset, long niov, int showbuf, long count)
3157 iovec_t iovec[16];
3158 iovec_t *ip;
3159 long nb;
3160 int serial = (count > MYBUFSIZ / 4 && showbuf);
3162 #ifdef _LP64
3163 if (data_model != PR_MODEL_LP64) {
3164 show_iovec32(pri, offset, niov, showbuf, count);
3165 return;
3167 #endif
3168 if (niov > 16) /* is this the real limit? */
3169 niov = 16;
3171 if (offset != 0 && niov > 0 &&
3172 Pread(Proc, &iovec[0], niov*sizeof (iovec_t), offset)
3173 == niov*sizeof (iovec_t)) {
3174 /* enter region of lengthy output */
3175 if (serial)
3176 Eserialize();
3178 for (ip = &iovec[0]; niov-- && !interrupt; ip++) {
3179 (void) printf("%s\tiov_base = 0x%.8lX iov_len = %lu\n",
3180 pri->pname,
3181 (long)ip->iov_base,
3182 ip->iov_len);
3183 if ((nb = count) > 0) {
3184 if (nb > ip->iov_len)
3185 nb = ip->iov_len;
3186 if (nb > 0)
3187 count -= nb;
3189 if (showbuf && nb > 0)
3190 showbuffer(pri, (long)ip->iov_base, nb);
3193 /* exit region of lengthy output */
3194 if (serial)
3195 Xserialize();
3199 void
3200 show_dents32(private_t *pri, long offset, long count)
3202 long buf[MYBUFSIZ / sizeof (long)];
3203 struct dirent32 *dp;
3204 int serial = (count > 100);
3206 if (offset == 0)
3207 return;
3209 /* enter region of lengthy output */
3210 if (serial)
3211 Eserialize();
3213 while (count > 0 && !interrupt) {
3214 int nb = count < MYBUFSIZ? (int)count : MYBUFSIZ;
3216 if ((nb = Pread(Proc, &buf[0], (size_t)nb, offset)) <= 0)
3217 break;
3219 dp = (struct dirent32 *)&buf[0];
3220 if (nb < (int)(dp->d_name - (char *)dp))
3221 break;
3222 if ((unsigned)nb < dp->d_reclen) {
3223 /* getdents() error? */
3224 (void) printf(
3225 "%s ino=%-5u off=%-4d rlen=%-3d\n",
3226 pri->pname,
3227 dp->d_ino,
3228 dp->d_off,
3229 dp->d_reclen);
3230 break;
3233 while (!interrupt &&
3234 nb >= (int)(dp->d_name - (char *)dp) &&
3235 (unsigned)nb >= dp->d_reclen) {
3236 (void) printf(
3237 "%s ino=%-5u off=%-4d rlen=%-3d \"%.*s\"\n",
3238 pri->pname,
3239 dp->d_ino,
3240 dp->d_off,
3241 dp->d_reclen,
3242 dp->d_reclen - (int)(dp->d_name - (char *)dp),
3243 dp->d_name);
3244 nb -= dp->d_reclen;
3245 count -= dp->d_reclen;
3246 offset += dp->d_reclen;
3247 /* LINTED improper alignment */
3248 dp = (struct dirent32 *)((char *)dp + dp->d_reclen);
3252 /* exit region of lengthy output */
3253 if (serial)
3254 Xserialize();
3257 void
3258 show_dents64(private_t *pri, long offset, long count)
3260 long long buf[MYBUFSIZ / sizeof (long long)];
3261 struct dirent64 *dp;
3262 int serial = (count > 100);
3264 if (offset == 0)
3265 return;
3267 /* enter region of lengthy output */
3268 if (serial)
3269 Eserialize();
3271 while (count > 0 && !interrupt) {
3272 int nb = count < MYBUFSIZ? (int)count : MYBUFSIZ;
3274 if ((nb = Pread(Proc, &buf[0], (size_t)nb, offset)) <= 0)
3275 break;
3277 dp = (struct dirent64 *)&buf[0];
3278 if (nb < (int)(dp->d_name - (char *)dp))
3279 break;
3280 if ((unsigned)nb < dp->d_reclen) {
3281 /* getdents() error? */
3282 (void) printf(
3283 "%s ino=%-5llu off=%-4lld rlen=%-3d\n",
3284 pri->pname,
3285 (long long)dp->d_ino,
3286 (long long)dp->d_off,
3287 dp->d_reclen);
3288 break;
3291 while (!interrupt &&
3292 nb >= (int)(dp->d_name - (char *)dp) &&
3293 (unsigned)nb >= dp->d_reclen) {
3294 (void) printf(
3295 "%s ino=%-5llu off=%-4lld rlen=%-3d \"%.*s\"\n",
3296 pri->pname,
3297 (long long)dp->d_ino,
3298 (long long)dp->d_off,
3299 dp->d_reclen,
3300 dp->d_reclen - (int)(dp->d_name - (char *)dp),
3301 dp->d_name);
3302 nb -= dp->d_reclen;
3303 count -= dp->d_reclen;
3304 offset += dp->d_reclen;
3305 /* LINTED improper alignment */
3306 dp = (struct dirent64 *)((char *)dp + dp->d_reclen);
3310 /* exit region of lengthy output */
3311 if (serial)
3312 Xserialize();
3315 void
3316 show_rlimit32(private_t *pri, long offset)
3318 struct rlimit32 rlimit;
3320 if (offset != 0 &&
3321 Pread(Proc, &rlimit, sizeof (rlimit), offset) == sizeof (rlimit)) {
3322 (void) printf("%s\t", pri->pname);
3323 switch (rlimit.rlim_cur) {
3324 case RLIM32_INFINITY:
3325 (void) fputs("cur = RLIM_INFINITY", stdout);
3326 break;
3327 case RLIM32_SAVED_MAX:
3328 (void) fputs("cur = RLIM_SAVED_MAX", stdout);
3329 break;
3330 case RLIM32_SAVED_CUR:
3331 (void) fputs("cur = RLIM_SAVED_CUR", stdout);
3332 break;
3333 default:
3334 (void) printf("cur = %lu", (long)rlimit.rlim_cur);
3335 break;
3337 switch (rlimit.rlim_max) {
3338 case RLIM32_INFINITY:
3339 (void) fputs(" max = RLIM_INFINITY\n", stdout);
3340 break;
3341 case RLIM32_SAVED_MAX:
3342 (void) fputs(" max = RLIM_SAVED_MAX\n", stdout);
3343 break;
3344 case RLIM32_SAVED_CUR:
3345 (void) fputs(" max = RLIM_SAVED_CUR\n", stdout);
3346 break;
3347 default:
3348 (void) printf(" max = %lu\n", (long)rlimit.rlim_max);
3349 break;
3354 void
3355 show_rlimit64(private_t *pri, long offset)
3357 struct rlimit64 rlimit;
3359 if (offset != 0 &&
3360 Pread(Proc, &rlimit, sizeof (rlimit), offset) == sizeof (rlimit)) {
3361 (void) printf("%s\t", pri->pname);
3362 switch (rlimit.rlim_cur) {
3363 case RLIM64_INFINITY:
3364 (void) fputs("cur = RLIM64_INFINITY", stdout);
3365 break;
3366 case RLIM64_SAVED_MAX:
3367 (void) fputs("cur = RLIM64_SAVED_MAX", stdout);
3368 break;
3369 case RLIM64_SAVED_CUR:
3370 (void) fputs("cur = RLIM64_SAVED_CUR", stdout);
3371 break;
3372 default:
3373 (void) printf("cur = %llu",
3374 (unsigned long long)rlimit.rlim_cur);
3375 break;
3377 switch (rlimit.rlim_max) {
3378 case RLIM64_INFINITY:
3379 (void) fputs(" max = RLIM64_INFINITY\n", stdout);
3380 break;
3381 case RLIM64_SAVED_MAX:
3382 (void) fputs(" max = RLIM64_SAVED_MAX\n", stdout);
3383 break;
3384 case RLIM64_SAVED_CUR:
3385 (void) fputs(" max = RLIM64_SAVED_CUR\n", stdout);
3386 break;
3387 default:
3388 (void) printf(" max = %llu\n",
3389 (unsigned long long)rlimit.rlim_max);
3390 break;
3395 void
3396 show_uname(private_t *pri, long offset)
3398 struct utsname ubuf;
3400 if (offset != 0 &&
3401 Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) {
3402 (void) printf(
3403 "%s\tsys=%s nod=%s rel=%s ver=%s mch=%s\n",
3404 pri->pname,
3405 ubuf.sysname,
3406 ubuf.nodename,
3407 ubuf.release,
3408 ubuf.version,
3409 ubuf.machine);
3413 void
3414 show_adjtime(private_t *pri, long off1, long off2)
3416 show_timeval(pri, off1, " delta");
3417 show_timeval(pri, off2, "olddelta");
3420 void
3421 show_sockaddr(private_t *pri,
3422 const char *str, long addroff, long lenoff, long len)
3425 * A buffer large enough for PATH_MAX size AF_UNIX address, which is
3426 * also large enough to store a sockaddr_in or a sockaddr_in6.
3428 long buf[(sizeof (short) + PATH_MAX + sizeof (long) - 1)
3429 / sizeof (long)];
3430 struct sockaddr *sa = (struct sockaddr *)buf;
3431 struct sockaddr_in *sin = (struct sockaddr_in *)buf;
3432 struct sockaddr_un *soun = (struct sockaddr_un *)buf;
3433 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)buf;
3434 char addrbuf[INET6_ADDRSTRLEN];
3436 if (lenoff != 0) {
3437 uint_t ilen;
3438 if (Pread(Proc, &ilen, sizeof (ilen), lenoff) != sizeof (ilen))
3439 return;
3440 len = ilen;
3443 if (len >= sizeof (buf)) /* protect against ridiculous length */
3444 len = sizeof (buf) - 1;
3445 if (Pread(Proc, buf, len, addroff) != len)
3446 return;
3448 switch (sa->sa_family) {
3449 case AF_INET6:
3450 (void) printf("%s\tAF_INET6 %s = %s port = %u\n",
3451 pri->pname, str,
3452 inet_ntop(AF_INET6, &sin6->sin6_addr, addrbuf,
3453 sizeof (addrbuf)),
3454 ntohs(sin6->sin6_port));
3455 (void) printf("%s\tscope id = %u source id = 0x%x\n"
3456 "%s\tflow class = 0x%02x flow label = 0x%05x\n",
3457 pri->pname, ntohl(sin6->sin6_scope_id),
3458 ntohl(sin6->__sin6_src_id),
3459 pri->pname,
3460 ntohl((sin6->sin6_flowinfo & IPV6_FLOWINFO_TCLASS) >> 20),
3461 ntohl(sin6->sin6_flowinfo & IPV6_FLOWINFO_FLOWLABEL));
3462 break;
3463 case AF_INET:
3464 (void) printf("%s\tAF_%s %s = %s port = %u\n",
3465 pri->pname, "INET",
3466 str, inet_ntop(AF_INET, &sin->sin_addr, addrbuf,
3467 sizeof (addrbuf)), ntohs(sin->sin_port));
3468 break;
3469 case AF_UNIX:
3470 len -= sizeof (soun->sun_family);
3471 if (len >= 0) {
3472 /* Null terminate */
3473 soun->sun_path[len] = '\0';
3474 (void) printf("%s\tAF_UNIX %s = %s\n", pri->pname,
3475 str, soun->sun_path);
3477 break;
3481 void
3482 show_msghdr(private_t *pri, long offset)
3484 const lwpstatus_t *Lsp = pri->lwpstat;
3485 int what = Lsp->pr_what;
3486 int err = pri->Errno;
3487 struct msghdr msg;
3488 int showbuf = FALSE;
3489 int i = pri->sys_args[0]+1;
3490 long nb = (what == SYS_recvmsg)? pri->Rval1 : 32*1024;
3492 if (Pread(Proc, &msg, sizeof (msg), offset) != sizeof (msg))
3493 return;
3495 if (msg.msg_name != NULL && msg.msg_namelen != 0)
3496 show_sockaddr(pri, "msg_name",
3497 (long)msg.msg_name, 0, (long)msg.msg_namelen);
3500 * Print the iovec if the syscall was successful and the fd is
3501 * part of the set being traced.
3503 if ((what == SYS_recvmsg && !err &&
3504 prismember(&readfd, i)) ||
3505 (what == SYS_sendmsg &&
3506 prismember(&writefd, i)))
3507 showbuf = TRUE;
3509 show_iovec(pri, (long)msg.msg_iov, msg.msg_iovlen, showbuf, nb);
3513 #ifdef _LP64
3514 void
3515 show_msghdr32(private_t *pri, long offset)
3517 struct msghdr32 {
3518 caddr32_t msg_name;
3519 uint32_t msg_namelen;
3520 caddr32_t msg_iov;
3521 int32_t msg_iovlen;
3522 } msg;
3523 const lwpstatus_t *Lsp = pri->lwpstat;
3524 int what = Lsp->pr_what;
3525 int err = pri->Errno;
3526 int showbuf = FALSE;
3527 int i = pri->sys_args[0]+1;
3528 long nb = (what == SYS_recvmsg)? pri->Rval1 : 32*1024;
3530 if (Pread(Proc, &msg, sizeof (msg), offset) != sizeof (msg))
3531 return;
3533 if (msg.msg_name != 0 && msg.msg_namelen != 0)
3534 show_sockaddr(pri, "msg_name",
3535 (long)msg.msg_name, 0, (long)msg.msg_namelen);
3537 * Print the iovec if the syscall was successful and the fd is
3538 * part of the set being traced.
3540 if ((what == SYS_recvmsg && !err &&
3541 prismember(&readfd, i)) ||
3542 (what == SYS_sendmsg &&
3543 prismember(&writefd, i)))
3544 showbuf = TRUE;
3546 show_iovec32(pri, (long)msg.msg_iov, msg.msg_iovlen, showbuf, nb);
3549 #endif /* _LP64 */
3551 static void
3552 show_doorargs(private_t *pri, long offset)
3554 door_arg_t args;
3556 if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
3557 (void) printf("%s\tdata_ptr=0x%lX data_size=%lu\n",
3558 pri->pname,
3559 (ulong_t)args.data_ptr,
3560 (ulong_t)args.data_size);
3561 (void) printf("%s\tdesc_ptr=0x%lX desc_num=%u\n",
3562 pri->pname,
3563 (ulong_t)args.desc_ptr,
3564 args.desc_num);
3565 (void) printf("%s\trbuf=0x%lX rsize=%lu\n",
3566 pri->pname,
3567 (ulong_t)args.rbuf,
3568 (ulong_t)args.rsize);
3572 static void
3573 show_ucred_privsets(private_t *pri, ucred_t *uc)
3575 int i = 0;
3576 const priv_set_t *s;
3577 priv_ptype_t sn;
3578 char *str;
3580 while ((sn = priv_getsetbynum(i++)) != NULL) {
3581 s = ucred_getprivset(uc, sn);
3583 if (s == NULL)
3584 continue;
3586 (void) printf("%s\t%c: %s\n",
3587 pri->pname,
3588 *sn,
3589 str = priv_set_to_str(s, ',', PRIV_STR_SHORT));
3591 free(str);
3595 static void
3596 show_ucred(private_t *pri, long offset)
3598 ucred_t *uc = _ucred_alloc();
3599 size_t sz;
3601 if (uc == NULL)
3602 return;
3604 sz = Pread(Proc, uc, uc->uc_size, offset);
3607 * A new uc_size is read, it could be smaller than the previously
3608 * value. We accept short reads that fill the whole header.
3610 if (sz >= sizeof (ucred_t) && sz >= uc->uc_size) {
3611 (void) printf("%s\teuid=%u egid=%u\n",
3612 pri->pname,
3613 ucred_geteuid(uc),
3614 ucred_getegid(uc));
3615 (void) printf("%s\truid=%u rgid=%u\n",
3616 pri->pname,
3617 ucred_getruid(uc),
3618 ucred_getrgid(uc));
3619 (void) printf("%s\tpid=%d zoneid=%d\n",
3620 pri->pname,
3621 (int)ucred_getpid(uc),
3622 (int)ucred_getzoneid(uc));
3623 show_ucred_privsets(pri, uc);
3625 ucred_free(uc);
3628 static void
3629 show_privset(private_t *pri, long offset, size_t size, char *label)
3631 priv_set_t *tmp = priv_allocset();
3632 size_t sz;
3634 if (tmp == NULL)
3635 return;
3637 sz = Pread(Proc, tmp, size, offset);
3639 if (sz == size) {
3640 char *str = priv_set_to_str(tmp, ',', PRIV_STR_SHORT);
3641 if (str != NULL) {
3642 (void) printf("%s\t%s%s\n", pri->pname, label, str);
3643 free(str);
3646 priv_freeset(tmp);
3649 static void
3650 show_doorinfo(private_t *pri, long offset)
3652 door_info_t info;
3653 door_attr_t attr;
3655 if (Pread(Proc, &info, sizeof (info), offset) != sizeof (info))
3656 return;
3657 (void) printf("%s\ttarget=%d proc=0x%llX data=0x%llX\n",
3658 pri->pname,
3659 (int)info.di_target,
3660 info.di_proc,
3661 info.di_data);
3662 attr = info.di_attributes;
3663 (void) printf("%s\tattributes=%s\n", pri->pname, door_flags(pri, attr));
3664 (void) printf("%s\tuniquifier=%llu\n", pri->pname, info.di_uniquifier);
3667 static void
3668 show_doorparam(private_t *pri, long offset)
3670 ulong_t val;
3672 if (Pread(Proc, &val, sizeof (val), offset) == sizeof (val)) {
3673 (void) printf("%s\tvalue=%lu\n",
3674 pri->pname,
3675 val);
3679 #ifdef _LP64
3681 static void
3682 show_doorargs32(private_t *pri, long offset)
3684 struct door_arg32 args;
3686 if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
3687 (void) printf("%s\tdata_ptr=%X data_size=%u\n",
3688 pri->pname,
3689 args.data_ptr,
3690 args.data_size);
3691 (void) printf("%s\tdesc_ptr=0x%X desc_num=%u\n",
3692 pri->pname,
3693 args.desc_ptr,
3694 args.desc_num);
3695 (void) printf("%s\trbuf=0x%X rsize=%u\n",
3696 pri->pname,
3697 args.rbuf,
3698 args.rsize);
3702 static void
3703 show_doorparam32(private_t *pri, long offset)
3705 uint_t val;
3707 if (Pread(Proc, &val, sizeof (val), offset) == sizeof (val)) {
3708 (void) printf("%s\tvalue=%u\n",
3709 pri->pname,
3710 val);
3714 #endif /* _LP64 */
3716 static void
3717 show_doors(private_t *pri)
3719 switch (pri->sys_args[5]) {
3720 case DOOR_CALL:
3721 #ifdef _LP64
3722 if (data_model == PR_MODEL_LP64)
3723 show_doorargs(pri, (long)pri->sys_args[1]);
3724 else
3725 show_doorargs32(pri, (long)pri->sys_args[1]);
3726 #else
3727 show_doorargs(pri, (long)pri->sys_args[1]);
3728 #endif
3729 break;
3730 case DOOR_UCRED:
3731 if (!pri->Errno)
3732 show_ucred(pri, (long)pri->sys_args[0]);
3733 break;
3734 case DOOR_INFO:
3735 if (!pri->Errno)
3736 show_doorinfo(pri, (long)pri->sys_args[1]);
3737 break;
3738 case DOOR_GETPARAM:
3739 if (!pri->Errno) {
3740 #ifdef _LP64
3741 if (data_model == PR_MODEL_LP64)
3742 show_doorparam(pri, (long)pri->sys_args[2]);
3743 else
3744 show_doorparam32(pri, (long)pri->sys_args[2]);
3745 #else
3746 show_doorparam(pri, (long)pri->sys_args[2]);
3747 #endif
3749 break;
3753 static void
3754 show_portargs(private_t *pri, long offset)
3756 port_event_t args;
3758 if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
3759 (void) printf("%s\tevents=0x%x source=%u\n",
3760 pri->pname,
3761 args.portev_events,
3762 args.portev_source);
3763 (void) printf("%s\tobject=0x%p user=0x%p\n",
3764 pri->pname,
3765 (void *)args.portev_object,
3766 (void *)args.portev_user);
3771 #ifdef _LP64
3773 static void
3774 show_portargs32(private_t *pri, long offset)
3776 port_event32_t args;
3778 if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
3779 (void) printf("%s\tevents=0x%x source=%u\n",
3780 pri->pname,
3781 args.portev_events,
3782 args.portev_source);
3783 (void) printf("%s\tobject=0x%x user=0x%x\n",
3784 pri->pname,
3785 args.portev_object,
3786 args.portev_user);
3790 #endif /* _LP64 */
3792 static void
3793 show_ports(private_t *pri)
3795 switch (pri->sys_args[0]) {
3796 case PORT_GET:
3797 #ifdef _LP64
3798 if (data_model == PR_MODEL_LP64)
3799 show_portargs(pri, (long)pri->sys_args[2]);
3800 else
3801 show_portargs32(pri, (long)pri->sys_args[2]);
3802 #else
3803 show_portargs(pri, (long)pri->sys_args[2]);
3804 #endif
3805 break;
3809 #define MAX_SNDFL_PRD 16
3811 #ifdef _LP64
3813 static void
3814 show_ksendfilevec32(private_t *pri, int fd,
3815 ksendfilevec32_t *sndvec, int sfvcnt)
3817 ksendfilevec32_t *snd_ptr, snd[MAX_SNDFL_PRD];
3818 size_t cpy_rqst;
3820 Eserialize();
3821 while (sfvcnt > 0) {
3822 cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
3823 sfvcnt -= cpy_rqst;
3824 cpy_rqst *= sizeof (snd[0]);
3826 if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
3827 break;
3829 snd_ptr = &snd[0];
3831 while (cpy_rqst) {
3832 (void) printf(
3833 "sfv_fd=%d\tsfv_flag=0x%x\t"
3834 "sfv_off=%d\tsfv_len=%u\n",
3835 snd_ptr->sfv_fd,
3836 snd_ptr->sfv_flag,
3837 snd_ptr->sfv_off,
3838 snd_ptr->sfv_len);
3840 if (snd_ptr->sfv_fd == SFV_FD_SELF &&
3841 prismember(&writefd, fd)) {
3842 showbuffer(pri,
3843 (long)snd_ptr->sfv_off & 0xffffffff,
3844 (long)snd_ptr->sfv_len);
3847 cpy_rqst -= sizeof (snd[0]);
3848 snd_ptr++;
3851 sndvec += MAX_SNDFL_PRD;
3853 Xserialize();
3856 static void
3857 show_ksendfilevec64(private_t *pri, int fd,
3858 ksendfilevec64_t *sndvec, int sfvcnt)
3860 ksendfilevec64_t *snd_ptr, snd[MAX_SNDFL_PRD];
3861 size_t cpy_rqst;
3863 Eserialize();
3864 while (sfvcnt > 0) {
3865 cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
3866 sfvcnt -= cpy_rqst;
3867 cpy_rqst *= sizeof (snd[0]);
3869 if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
3870 break;
3872 snd_ptr = &snd[0];
3874 while (cpy_rqst) {
3875 (void) printf(
3876 "sfv_fd=%d\tsfv_flag=0x%x\t"
3877 "sfv_off=%ld\tsfv_len=%u\n",
3878 snd_ptr->sfv_fd,
3879 snd_ptr->sfv_flag,
3880 snd_ptr->sfv_off,
3881 snd_ptr->sfv_len);
3883 if (snd_ptr->sfv_fd == SFV_FD_SELF &&
3884 prismember(&writefd, fd)) {
3885 showbuffer(pri,
3886 (long)snd_ptr->sfv_off & 0xffffffff,
3887 (long)snd_ptr->sfv_len);
3890 cpy_rqst -= sizeof (snd[0]);
3891 snd_ptr++;
3894 sndvec += MAX_SNDFL_PRD;
3896 Xserialize();
3899 #endif /* _LP64 */
3901 /*ARGSUSED*/
3902 static void
3903 show_sendfilevec(private_t *pri, int fd, sendfilevec_t *sndvec, int sfvcnt)
3905 sendfilevec_t *snd_ptr, snd[MAX_SNDFL_PRD];
3906 size_t cpy_rqst;
3908 #ifdef _LP64
3909 if (data_model != PR_MODEL_LP64) {
3910 show_ksendfilevec32(pri, fd,
3911 (ksendfilevec32_t *)sndvec, sfvcnt);
3912 return;
3914 #endif
3915 Eserialize();
3916 while (sfvcnt > 0) {
3917 cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
3918 sfvcnt -= cpy_rqst;
3919 cpy_rqst *= sizeof (snd[0]);
3921 if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
3922 break;
3924 snd_ptr = &snd[0];
3926 while (cpy_rqst) {
3927 (void) printf(
3928 "sfv_fd=%d\tsfv_flag=0x%x\t"
3929 "sfv_off=%ld\tsfv_len=%lu\n",
3930 snd_ptr->sfv_fd,
3931 snd_ptr->sfv_flag,
3932 snd_ptr->sfv_off,
3933 (ulong_t)snd_ptr->sfv_len);
3935 if (snd_ptr->sfv_fd == SFV_FD_SELF &&
3936 prismember(&writefd, fd)) {
3937 showbuffer(pri, (long)snd_ptr->sfv_off,
3938 (long)snd_ptr->sfv_len);
3941 cpy_rqst -= sizeof (snd[0]);
3942 snd_ptr++;
3945 sndvec += MAX_SNDFL_PRD;
3947 Xserialize();
3950 /*ARGSUSED*/
3951 static void
3952 show_sendfilevec64(private_t *pri, int fd, sendfilevec64_t *sndvec, int sfvcnt)
3954 sendfilevec64_t *snd_ptr, snd[MAX_SNDFL_PRD];
3955 size_t cpy_rqst;
3957 #ifdef _LP64
3958 if (data_model != PR_MODEL_LP64) {
3959 show_ksendfilevec64(pri, fd,
3960 (ksendfilevec64_t *)sndvec, sfvcnt);
3961 return;
3963 #endif
3965 Eserialize();
3966 while (sfvcnt > 0) {
3967 cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
3968 sfvcnt -= cpy_rqst;
3969 cpy_rqst *= sizeof (snd[0]);
3971 if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
3972 break;
3974 snd_ptr = &snd[0];
3976 while (cpy_rqst) {
3977 (void) printf(
3978 #ifdef _LP64
3979 "sfv_fd=%d\tsfv_flag=0x%x\t"
3980 "sfv_off=%ld\tsfv_len=%lu\n",
3981 #else
3982 "sfv_fd=%d\tsfv_flag=0x%x\t"
3983 "sfv_off=%lld\tsfv_len=%lu\n",
3984 #endif
3985 snd_ptr->sfv_fd,
3986 snd_ptr->sfv_flag,
3987 snd_ptr->sfv_off,
3988 (ulong_t)snd_ptr->sfv_len);
3990 if (snd_ptr->sfv_fd == SFV_FD_SELF &&
3991 prismember(&writefd, fd)) {
3992 showbuffer(pri, (long)snd_ptr->sfv_off,
3993 (long)snd_ptr->sfv_len);
3996 cpy_rqst -= sizeof (snd[0]);
3997 snd_ptr++;
4000 sndvec += MAX_SNDFL_PRD;
4002 Xserialize();
4005 static void
4006 show_memcntl_mha(private_t *pri, long offset)
4008 struct memcntl_mha mha;
4009 const char *s = NULL;
4011 if (Pread(Proc, &mha, sizeof (mha), offset) == sizeof (mha)) {
4012 switch (mha.mha_cmd) {
4013 case MHA_MAPSIZE_VA: s = "MHA_MAPSIZE_VA"; break;
4014 case MHA_MAPSIZE_BSSBRK: s = "MHA_MAPSIZE_BSSBRK"; break;
4015 case MHA_MAPSIZE_STACK: s = "MHA_MAPSIZE_STACK"; break;
4017 if (s)
4018 (void) printf("%s\tmha_cmd=%s mha_flags=0x%x"
4019 " mha_pagesize=%lu\n",
4020 pri->pname, s, mha.mha_flags,
4021 (ulong_t)mha.mha_pagesize);
4022 else
4023 (void) printf("%s\tmha_cmd=0x%.8x mha_flags=0x%x"
4024 " mha_pagesize=%lu\n",
4025 pri->pname, mha.mha_cmd, mha.mha_flags,
4026 (ulong_t)mha.mha_pagesize);
4030 #ifdef _LP64
4032 static void
4033 show_memcntl_mha32(private_t *pri, long offset)
4035 struct memcntl_mha32 mha32;
4036 const char *s = NULL;
4038 if (Pread(Proc, &mha32, sizeof (mha32), offset) ==
4039 sizeof (mha32)) {
4040 switch (mha32.mha_cmd) {
4041 case MHA_MAPSIZE_VA: s = "MHA_MAPSIZE_VA"; break;
4042 case MHA_MAPSIZE_BSSBRK: s = "MHA_MAPSIZE_BSSBRK"; break;
4043 case MHA_MAPSIZE_STACK: s = "MHA_MAPSIZE_STACK"; break;
4045 if (s)
4046 (void) printf("%s\tmha_cmd=%s mha_flags=0x%x"
4047 " mha_pagesize=%u\n",
4048 pri->pname, s, mha32.mha_flags, mha32.mha_pagesize);
4049 else
4050 (void) printf("%s\tmha_cmd=0x%.8x mha_flags=0x%x"
4051 " mha_pagesize=%u\n",
4052 pri->pname, mha32.mha_cmd, mha32.mha_flags,
4053 mha32.mha_pagesize);
4057 #endif /* _LP64 */
4059 static void
4060 show_memcntl(private_t *pri)
4063 if ((int)pri->sys_args[2] != MC_HAT_ADVISE)
4064 return;
4065 #ifdef _LP64
4066 if (data_model == PR_MODEL_LP64)
4067 show_memcntl_mha(pri, (long)pri->sys_args[3]);
4068 else
4069 show_memcntl_mha32(pri, (long)pri->sys_args[3]);
4070 #else
4071 show_memcntl_mha(pri, (long)pri->sys_args[3]);
4072 #endif
4075 void
4076 show_ids(private_t *pri, long offset, int count)
4078 id_t buf[MYBUFSIZ / sizeof (id_t)];
4079 id_t *idp;
4080 int serial = (count > MYBUFSIZ / 48);
4082 if (offset == 0)
4083 return;
4085 /* enter region of lengthy output */
4086 if (serial)
4087 Eserialize();
4089 while (count > 0 && !interrupt) {
4090 ssize_t nb = (count * sizeof (id_t) < MYBUFSIZ)?
4091 count * sizeof (id_t) : MYBUFSIZ;
4093 if ((nb = Pread(Proc, &buf[0], (size_t)nb, offset)) < 0 ||
4094 nb < sizeof (id_t))
4095 break;
4097 idp = buf;
4098 while (!interrupt && nb >= sizeof (id_t)) {
4099 (void) printf("%s\t%8d\n", pri->pname, (int)*idp);
4100 offset += sizeof (id_t);
4101 nb -= sizeof (id_t);
4102 idp++;
4103 count--;
4107 /* exit region of lengthy output */
4108 if (serial)
4109 Xserialize();
4112 void
4113 show_ntp_gettime(private_t *pri)
4115 struct ntptimeval ntv;
4116 long offset;
4118 if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == 0)
4119 return;
4121 if (data_model == PR_MODEL_NATIVE) {
4122 if (Pread(Proc, &ntv, sizeof (ntv), offset)
4123 != sizeof (ntv))
4124 return;
4125 } else {
4126 struct ntptimeval32 ntv32;
4128 if (Pread(Proc, &ntv32, sizeof (ntv32), offset)
4129 != sizeof (ntv32))
4130 return;
4132 TIMEVAL32_TO_TIMEVAL(&ntv.time, &ntv32.time);
4133 ntv.maxerror = ntv32.maxerror;
4134 ntv.esterror = ntv32.esterror;
4137 (void) printf("\ttime: %ld.%6.6ld sec\n",
4138 ntv.time.tv_sec, ntv.time.tv_usec);
4139 (void) printf("\tmaxerror: %11d usec\n", ntv.maxerror);
4140 (void) printf("\testerror: %11d usec\n", ntv.esterror);
4143 static char *
4144 get_timex_modes(private_t *pri, uint32_t val)
4146 char *str = pri->code_buf;
4147 size_t used = 0;
4149 *str = '\0';
4150 if (val & MOD_OFFSET)
4151 used = strlcat(str, "|MOD_OFFSET", sizeof (pri->code_buf));
4152 if (val & MOD_FREQUENCY)
4153 used = strlcat(str, "|MOD_FREQUENCY", sizeof (pri->code_buf));
4154 if (val & MOD_MAXERROR)
4155 used = strlcat(str, "|MOD_MAXERROR", sizeof (pri->code_buf));
4156 if (val & MOD_ESTERROR)
4157 used = strlcat(str, "|MOD_ESTERROR", sizeof (pri->code_buf));
4158 if (val & MOD_STATUS)
4159 used = strlcat(str, "|MOD_STATUS", sizeof (pri->code_buf));
4160 if (val & MOD_TIMECONST)
4161 used = strlcat(str, "|MOD_TIMECONST", sizeof (pri->code_buf));
4162 if (val & MOD_CLKB)
4163 used = strlcat(str, "|MOD_CLKB", sizeof (pri->code_buf));
4164 if (val & MOD_CLKA)
4165 used = strlcat(str, "|MOD_CLKA", sizeof (pri->code_buf));
4167 if (used == 0 || used >= sizeof (pri->code_buf))
4168 (void) snprintf(str, sizeof (pri->code_buf), " 0x%.4x", val);
4170 return (str + 1);
4173 static char *
4174 get_timex_status(private_t *pri, int32_t val)
4176 char *str = pri->code_buf;
4177 size_t used = 0;
4179 *str = '\0';
4180 if (val & STA_PLL)
4181 used = strlcat(str, "|STA_PLL", sizeof (pri->code_buf));
4182 if (val & STA_PPSFREQ)
4183 used = strlcat(str, "|STA_PPSFREQ", sizeof (pri->code_buf));
4184 if (val & STA_PPSTIME)
4185 used = strlcat(str, "|STA_PPSTIME", sizeof (pri->code_buf));
4186 if (val & STA_FLL)
4187 used = strlcat(str, "|STA_FLL", sizeof (pri->code_buf));
4189 if (val & STA_INS)
4190 used = strlcat(str, "|STA_INS", sizeof (pri->code_buf));
4191 if (val & STA_DEL)
4192 used = strlcat(str, "|STA_DEL", sizeof (pri->code_buf));
4193 if (val & STA_UNSYNC)
4194 used = strlcat(str, "|STA_UNSYNC", sizeof (pri->code_buf));
4195 if (val & STA_FREQHOLD)
4196 used = strlcat(str, "|STA_FREQHOLD", sizeof (pri->code_buf));
4198 if (val & STA_PPSSIGNAL)
4199 used = strlcat(str, "|STA_PPSSIGNAL", sizeof (pri->code_buf));
4200 if (val & STA_PPSJITTER)
4201 used = strlcat(str, "|STA_PPSJITTER", sizeof (pri->code_buf));
4202 if (val & STA_PPSWANDER)
4203 used = strlcat(str, "|STA_PPSWANDER", sizeof (pri->code_buf));
4204 if (val & STA_PPSERROR)
4205 used = strlcat(str, "|STA_PPSERROR", sizeof (pri->code_buf));
4207 if (val & STA_CLOCKERR)
4208 used = strlcat(str, "|STA_CLOCKERR", sizeof (pri->code_buf));
4210 if (used == 0 || used >= sizeof (pri->code_buf))
4211 (void) snprintf(str, sizeof (pri->code_buf), " 0x%.4x", val);
4213 return (str + 1);
4216 void
4217 show_ntp_adjtime(private_t *pri)
4219 struct timex timex;
4220 long offset;
4222 if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == 0)
4223 return;
4225 if (Pread(Proc, &timex, sizeof (timex), offset) != sizeof (timex))
4226 return;
4228 (void) printf("\tmodes: %s\n", get_timex_modes(pri, timex.modes));
4229 (void) printf("\toffset: %11d usec\n", timex.offset);
4230 (void) printf("\tfreq: %11d scaled ppm\n", timex.freq);
4231 (void) printf("\tmaxerror: %11d usec\n", timex.maxerror);
4232 (void) printf("\testerror: %11d usec\n", timex.esterror);
4233 (void) printf("\tstatus: %s\n", get_timex_status(pri, timex.status));
4234 (void) printf("\tconstant: %11d\n", timex.constant);
4235 (void) printf("\tprecision: %11d usec\n", timex.precision);
4236 (void) printf("\ttolerance: %11d scaled ppm\n", timex.tolerance);
4237 (void) printf("\tppsfreq: %11d scaled ppm\n", timex.ppsfreq);
4238 (void) printf("\tjitter: %11d usec\n", timex.jitter);
4239 (void) printf("\tshift: %11d sec\n", timex.shift);
4240 (void) printf("\tstabil: %11d scaled ppm\n", timex.stabil);
4241 (void) printf("\tjitcnt: %11d\n", timex.jitcnt);
4242 (void) printf("\tcalcnt: %11d\n", timex.calcnt);
4243 (void) printf("\terrcnt: %11d\n", timex.errcnt);
4244 (void) printf("\tstbcnt: %11d\n", timex.stbcnt);
4247 void
4248 show_getrusage(long offset)
4250 struct rusage r;
4251 if (Pread(Proc, &r, sizeof (r), offset) != sizeof (r))
4252 return;
4253 (void) printf("\t user time: %ld.%6.6ld sec\n",
4254 r.ru_utime.tv_sec,
4255 r.ru_utime.tv_usec);
4256 (void) printf("\t system time: %ld.%6.6ld sec\n",
4257 r.ru_stime.tv_sec,
4258 r.ru_stime.tv_usec);
4259 (void) printf("\t max rss: <unimpl> %ld\n",
4260 r.ru_maxrss);
4261 (void) printf("\t shared data: <unimpl> %ld\n",
4262 r.ru_ixrss);
4263 (void) printf("\t unshared data: <unimpl> %ld\n",
4264 r.ru_idrss);
4265 (void) printf("\t unshared stack: <unimpl> %ld\n",
4266 r.ru_isrss);
4267 (void) printf("\t minor faults: %ld\n",
4268 r.ru_minflt);
4269 (void) printf("\t major faults: %ld\n",
4270 r.ru_majflt);
4271 (void) printf("\t # of swaps: %ld\n",
4272 r.ru_nswap);
4273 (void) printf("\t blocked inputs: %ld\n",
4274 r.ru_inblock);
4275 (void) printf("\t blocked outputs: %ld\n",
4276 r.ru_oublock);
4277 (void) printf("\t msgs sent: %ld\n",
4278 r.ru_msgsnd);
4279 (void) printf("\t msgs rcv'd: %ld\n",
4280 r.ru_msgrcv);
4281 (void) printf("\t signals rcv'd: %ld\n",
4282 r.ru_nsignals);
4283 (void) printf("\tvol cntxt swtchs: %ld\n",
4284 r.ru_nvcsw);
4285 (void) printf("\tinv cntxt swtchs: %ld\n",
4286 r.ru_nivcsw);
4289 #ifdef _LP64
4290 void
4291 show_getrusage32(long offset)
4293 struct rusage32 r;
4294 if (Pread(Proc, &r, sizeof (r), offset) != sizeof (r))
4295 return;
4296 (void) printf("\t user time: %d.%6.6d sec\n",
4297 r.ru_utime.tv_sec,
4298 r.ru_utime.tv_usec);
4299 (void) printf("\t system time: %d.%6.6d sec\n",
4300 r.ru_stime.tv_sec,
4301 r.ru_stime.tv_usec);
4302 (void) printf("\t max rss: <unimpl> %d\n",
4303 r.ru_maxrss);
4304 (void) printf("\t shared data: <unimpl> %d\n",
4305 r.ru_ixrss);
4306 (void) printf("\t unshared data: <unimpl> %d\n",
4307 r.ru_idrss);
4308 (void) printf("\t unshared stack: <unimpl> %d\n",
4309 r.ru_isrss);
4310 (void) printf("\t minor faults: %d\n",
4311 r.ru_minflt);
4312 (void) printf("\t major faults: %d\n",
4313 r.ru_majflt);
4314 (void) printf("\t # of swaps: %d\n",
4315 r.ru_nswap);
4316 (void) printf("\t blocked inputs: %d\n",
4317 r.ru_inblock);
4318 (void) printf("\t blocked outputs: %d\n",
4319 r.ru_oublock);
4320 (void) printf("\t msgs sent: %d\n",
4321 r.ru_msgsnd);
4322 (void) printf("\t msgs rcv'd: %d\n",
4323 r.ru_msgrcv);
4324 (void) printf("\t signals rcv'd: %d\n",
4325 r.ru_nsignals);
4326 (void) printf("\tvol cntxt swtchs: %d\n",
4327 r.ru_nvcsw);
4328 (void) printf("\tinv cntxt swtchs: %d\n",
4329 r.ru_nivcsw);
4331 #endif
4334 * Utility function to print a packed nvlist by unpacking
4335 * and calling the libnvpair pretty printer. Frees all
4336 * allocated memory internally.
4338 static void
4339 show_packed_nvlist(private_t *pri, uintptr_t offset, size_t size)
4341 nvlist_t *nvl = NULL;
4342 size_t readsize;
4343 char *buf;
4345 if ((offset == 0) || (size == 0)) {
4346 return;
4349 buf = my_malloc(size, "nvlist decode buffer");
4350 readsize = Pread(Proc, buf, size, offset);
4351 if (readsize != size) {
4352 (void) printf("%s\t<?>", pri->pname);
4353 } else {
4354 int result;
4356 result = nvlist_unpack(buf, size, &nvl, 0);
4357 if (result == 0) {
4358 dump_nvlist(nvl, 8);
4359 nvlist_free(nvl);
4360 } else {
4361 (void) printf("%s\tunpack of nvlist"
4362 " failed: %d\n", pri->pname, result);
4365 free(buf);
4368 static void
4369 show_zone_create_args(private_t *pri, long offset)
4371 zone_def args;
4372 char zone_name[ZONENAME_MAX];
4373 char zone_root[MAXPATHLEN];
4374 char *zone_zfs = NULL;
4376 if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
4378 if (Pread_string(Proc, zone_name, sizeof (zone_name),
4379 (uintptr_t)args.zone_name) == -1)
4380 (void) strcpy(zone_name, "<?>");
4382 if (Pread_string(Proc, zone_root, sizeof (zone_root),
4383 (uintptr_t)args.zone_root) == -1)
4384 (void) strcpy(zone_root, "<?>");
4386 if (args.zfsbufsz > 0) {
4387 zone_zfs = malloc(MIN(4, args.zfsbufsz));
4388 if (zone_zfs != NULL) {
4389 if (Pread(Proc, zone_zfs, args.zfsbufsz,
4390 (uintptr_t)args.zfsbuf) == -1)
4391 (void) strcpy(zone_zfs, "<?>");
4393 } else {
4394 zone_zfs = "";
4397 (void) printf("%s\t zone_name: %s\n", pri->pname,
4398 zone_name);
4399 (void) printf("%s\t zone_root: %s\n", pri->pname,
4400 zone_root);
4402 show_privset(pri, (uintptr_t)args.zone_privs,
4403 args.zone_privssz, " zone_privs: ");
4405 (void) printf("%s\t rctlbuf: 0x%p\n", pri->pname,
4406 (void *)args.rctlbuf);
4407 (void) printf("%s\t rctlbufsz: %lu\n", pri->pname,
4408 (ulong_t)args.rctlbufsz);
4410 show_packed_nvlist(pri, (uintptr_t)args.rctlbuf,
4411 args.rctlbufsz);
4413 (void) printf("%s\t zfs: %s\n", pri->pname, zone_zfs);
4415 (void) printf("%s\textended_error: 0x%p\n", pri->pname,
4416 (void *)args.extended_error);
4418 if (args.zfsbufsz > 0)
4419 free(zone_zfs);
4424 #ifdef _LP64
4426 static void
4427 show_zone_create_args32(private_t *pri, long offset)
4429 zone_def32 args;
4430 char zone_name[ZONENAME_MAX];
4431 char zone_root[MAXPATHLEN];
4432 char *zone_zfs = NULL;
4434 if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
4436 if (Pread_string(Proc, zone_name, sizeof (zone_name),
4437 (uintptr_t)args.zone_name) == -1)
4438 (void) strcpy(zone_name, "<?>");
4440 if (Pread_string(Proc, zone_root, sizeof (zone_root),
4441 (uintptr_t)args.zone_root) == -1)
4442 (void) strcpy(zone_root, "<?>");
4444 if (args.zfsbufsz > 0) {
4445 zone_zfs = malloc(MIN(4, args.zfsbufsz));
4446 if (zone_zfs != NULL) {
4447 if (Pread(Proc, zone_zfs, args.zfsbufsz,
4448 (uintptr_t)args.zfsbuf) == -1)
4449 (void) strcpy(zone_zfs, "<?>");
4451 } else {
4452 zone_zfs = "";
4455 (void) printf("%s\t zone_name: %s\n", pri->pname,
4456 zone_name);
4457 (void) printf("%s\t zone_root: %s\n", pri->pname,
4458 zone_root);
4460 show_privset(pri, (uintptr_t)args.zone_privs,
4461 args.zone_privssz, " zone_privs: ");
4463 (void) printf("%s\t rctlbuf: 0x%x\n", pri->pname,
4464 (caddr32_t)args.rctlbuf);
4465 (void) printf("%s\t rctlbufsz: %lu\n", pri->pname,
4466 (ulong_t)args.rctlbufsz);
4468 show_packed_nvlist(pri, (uintptr_t)args.rctlbuf,
4469 args.rctlbufsz);
4471 (void) printf("%s\t zfs: %s\n", pri->pname, zone_zfs);
4473 (void) printf("%s\textended_error: 0x%x\n", pri->pname,
4474 (caddr32_t)args.extended_error);
4476 if (args.zfsbufsz > 0)
4477 free(zone_zfs);
4481 #endif
4483 static void
4484 show_zones(private_t *pri)
4486 switch (pri->sys_args[0]) {
4487 case ZONE_CREATE:
4488 #ifdef _LP64
4489 if (data_model == PR_MODEL_LP64)
4490 show_zone_create_args(pri, (long)pri->sys_args[1]);
4491 else
4492 show_zone_create_args32(pri, (long)pri->sys_args[1]);
4493 #else
4494 show_zone_create_args(pri, (long)pri->sys_args[1]);
4495 #endif
4496 break;
4500 static void
4501 show_rctlblk(private_t *pri, long _rctlblk)
4503 rctlblk_t *blk;
4504 int size = rctlblk_size();
4505 size_t readsize;
4506 const char *s;
4508 blk = my_malloc(size, "rctlblk decode buffer");
4509 readsize = Pread(Proc, blk, size, _rctlblk);
4510 if (readsize != size) {
4511 (void) printf("%s\t\t<?>", pri->pname);
4512 } else {
4513 (void) printf("%s\t\t Privilege: 0x%x\n",
4514 pri->pname,
4515 rctlblk_get_privilege(blk));
4516 (void) printf("%s\t\t Value: %lld\n",
4517 pri->pname,
4518 rctlblk_get_value(blk));
4519 (void) printf("%s\t\tEnforced Value: %lld\n",
4520 pri->pname,
4521 rctlblk_get_enforced_value(blk));
4524 int sig, act;
4525 act = rctlblk_get_local_action(blk, &sig);
4527 s = rctl_local_action(pri, act);
4528 if (s == NULL) {
4529 (void) printf("%s\t\t Local action: 0x%x\n",
4530 pri->pname, act);
4531 } else {
4532 (void) printf("%s\t\t Local action: %s\n",
4533 pri->pname, s);
4536 if (act & RCTL_LOCAL_SIGNAL) {
4537 (void) printf("%s\t\t "
4538 "For signal %s\n",
4539 pri->pname, signame(pri, sig));
4543 s = rctl_local_flags(pri, rctlblk_get_local_flags(blk));
4544 if (s == NULL) {
4545 (void) printf("%s\t\t Local flags: 0x%x\n",
4546 pri->pname, rctlblk_get_local_flags(blk));
4547 } else {
4548 (void) printf("%s\t\t Local flags: %s\n",
4549 pri->pname, s);
4552 #ifdef _LP64
4553 (void) printf("%s\t\t Recipient PID: %d\n",
4554 pri->pname,
4555 rctlblk_get_recipient_pid(blk));
4556 #else
4557 (void) printf("%s\t\t Recipient PID: %ld\n",
4558 pri->pname,
4559 rctlblk_get_recipient_pid(blk));
4560 #endif
4561 (void) printf("%s\t\t Firing Time: %lld\n",
4562 pri->pname,
4563 rctlblk_get_firing_time(blk));
4565 free(blk);
4568 static void
4569 show_rctls(private_t *pri)
4571 int entry;
4573 switch (pri->sys_args[0]) {
4574 case 0: /* getrctl */
4575 case 1: /* setrctl */
4577 * If these offsets look a little odd, remember that they're
4578 * into the _raw_ system call
4580 (void) printf("%s\tOld rctlblk: 0x%lx\n", pri->pname,
4581 pri->sys_args[2]);
4582 if (pri->sys_args[2] != 0) {
4583 show_rctlblk(pri, pri->sys_args[2]);
4585 (void) printf("%s\tNew rctlblk: 0x%lx\n", pri->pname,
4586 pri->sys_args[3]);
4587 if (pri->sys_args[3] != 0) {
4588 show_rctlblk(pri, pri->sys_args[3]);
4590 break;
4591 case 4: /* setprojrctl */
4592 for (entry = 0; entry < pri->sys_args[4]; entry++) {
4593 (void) printf("%s\tNew rctlblk[%d]: 0x%lx\n",
4594 pri->pname, entry,
4595 (long)RCTLBLK_INC(pri->sys_args[3], entry));
4596 if (RCTLBLK_INC(pri->sys_args[3], entry) != NULL) {
4597 show_rctlblk(pri,
4598 (long)RCTLBLK_INC(pri->sys_args[3], entry));
4604 void
4605 show_utimesys(private_t *pri)
4607 switch (pri->sys_args[0]) {
4608 case 0: /* futimens() */
4609 if (pri->sys_nargs > 2)
4610 show_utimens(pri, (long)pri->sys_args[2]);
4611 break;
4612 case 1: /* utimensat */
4613 if (pri->sys_nargs > 3)
4614 show_utimens(pri, (long)pri->sys_args[3]);
4615 break;
4616 default: /* unexpected subcode */
4617 break;
4621 #ifdef _LP64
4622 static void
4623 show_sockconfig_filter_prop32(private_t *pri, long addr)
4625 struct sockconfig_filter_props32 props;
4626 const char *s = NULL;
4627 char buf[MAX(FILNAME_MAX, MODMAXNAMELEN)];
4628 sof_socktuple32_t *tup;
4629 size_t sz;
4630 int i;
4632 if (Pread(Proc, &props, sizeof (props), addr) == sizeof (props)) {
4633 if (Pread_string(Proc, buf, sizeof (buf),
4634 (uintptr_t)props.sfp_modname) == -1)
4635 (void) strcpy(buf, "<?>");
4636 (void) printf("%s\tmodule name: %s\n", pri->pname, buf);
4637 (void) printf("%s\tattach semantics: %s", pri->pname,
4638 props.sfp_autoattach ? "automatic" : "progammatic");
4639 if (props.sfp_autoattach) {
4640 buf[0] = '\0';
4641 switch (props.sfp_hint) {
4642 case SOF_HINT_TOP: s = "top"; break;
4643 case SOF_HINT_BOTTOM: s = "bottom"; break;
4644 case SOF_HINT_BEFORE:
4645 case SOF_HINT_AFTER:
4646 s = (props.sfp_hint == SOF_HINT_BEFORE) ?
4647 "before" : "after";
4648 if (Pread_string(Proc, buf, sizeof (buf),
4649 (uintptr_t)props.sfp_hintarg) == -1)
4650 (void) strcpy(buf, "<?>");
4652 if (s != NULL) {
4653 (void) printf(", placement: %s %s", s, buf);
4656 (void) printf("\n");
4657 (void) printf("%s\tsocket tuples:\n", pri->pname);
4658 if (props.sfp_socktuple_cnt == 0) {
4659 (void) printf("\t\t<empty>\n");
4660 return;
4662 sz = props.sfp_socktuple_cnt * sizeof (*tup);
4663 tup = my_malloc(sz, "socket tuple buffer");
4664 if (Pread(Proc, tup, sz, (uintptr_t)props.sfp_socktuple) == sz)
4665 for (i = 0; i < props.sfp_socktuple_cnt; i++) {
4666 (void) printf(
4667 "\t\tfamily: %d, type: %d, proto: %d\n",
4668 tup[i].sofst_family, tup[i].sofst_type,
4669 tup[i].sofst_protocol);
4673 #endif /* _LP64 */
4674 static void
4675 show_sockconfig_filter_prop(private_t *pri, long addr)
4677 struct sockconfig_filter_props props;
4678 const char *s = NULL;
4679 char buf[MAX(FILNAME_MAX, MODMAXNAMELEN)];
4680 sof_socktuple_t *tup;
4681 size_t sz;
4682 int i;
4684 if (Pread(Proc, &props, sizeof (props), addr) == sizeof (props)) {
4685 if (Pread_string(Proc, buf, sizeof (buf),
4686 (uintptr_t)props.sfp_modname) == -1)
4687 (void) strcpy(buf, "<?>");
4688 (void) printf("%s\tmodule name: %s\n", pri->pname, buf);
4689 (void) printf("%s\tattach semantics: %s", pri->pname,
4690 props.sfp_autoattach ? "automatic" : "progammatic");
4691 if (props.sfp_autoattach) {
4692 buf[0] = '\0';
4693 switch (props.sfp_hint) {
4694 case SOF_HINT_TOP: s = "top"; break;
4695 case SOF_HINT_BOTTOM: s = "bottom"; break;
4696 case SOF_HINT_BEFORE:
4697 case SOF_HINT_AFTER:
4698 s = (props.sfp_hint == SOF_HINT_BEFORE) ?
4699 "before" : "after";
4700 if (Pread_string(Proc, buf, sizeof (buf),
4701 (uintptr_t)props.sfp_hintarg) == -1)
4702 (void) strcpy(buf, "<?>");
4704 if (s != NULL) {
4705 (void) printf(", placement: %s", s);
4708 (void) printf("\n");
4709 (void) printf("%s\tsocket tuples:\n", pri->pname);
4710 if (props.sfp_socktuple_cnt == 0) {
4711 (void) printf("\t\t<empty>\n");
4712 return;
4714 sz = props.sfp_socktuple_cnt * sizeof (*tup);
4715 tup = my_malloc(sz, "socket tuple buffer");
4716 if (Pread(Proc, tup, sz, (uintptr_t)props.sfp_socktuple) == sz)
4717 for (i = 0; i < props.sfp_socktuple_cnt; i++) {
4718 (void) printf(
4719 "\t\tfamily: %d, type: %d, proto: %d\n",
4720 tup[i].sofst_family, tup[i].sofst_type,
4721 tup[i].sofst_protocol);
4726 void
4727 show_sockconfig(private_t *pri)
4729 switch (pri->sys_args[0]) {
4730 case SOCKCONFIG_ADD_FILTER:
4731 #ifdef _LP64
4732 if (data_model == PR_MODEL_LP64)
4733 show_sockconfig_filter_prop(pri,
4734 (long)pri->sys_args[2]);
4735 else
4736 show_sockconfig_filter_prop32(pri,
4737 (long)pri->sys_args[2]);
4738 #else
4739 show_sockconfig_filter_prop(pri, (long)pri->sys_args[2]);
4740 #endif
4741 break;
4742 default:
4743 break;
4747 void
4748 show_zfs_ioc(private_t *pri, long addr)
4750 static const zfs_share_t zero_share = {0};
4751 static const dmu_objset_stats_t zero_objstats = {0};
4752 static const struct drr_begin zero_drrbegin = {0};
4753 static const zinject_record_t zero_injectrec = {0};
4754 static const zfs_stat_t zero_zstat = {0};
4755 zfs_cmd_t zc;
4757 if (Pread(Proc, &zc, sizeof (zc), addr) != sizeof (zc)) {
4758 (void) printf(" zfs_ioctl read failed\n");
4759 return;
4762 if (zc.zc_name[0])
4763 (void) printf(" zc_name=%s\n", zc.zc_name);
4764 if (zc.zc_value[0])
4765 (void) printf(" zc_value=%s\n", zc.zc_value);
4766 if (zc.zc_string[0])
4767 (void) printf(" zc_string=%s\n", zc.zc_string);
4768 if (zc.zc_guid != 0) {
4769 (void) printf(" zc_guid=%llu\n",
4770 (u_longlong_t)zc.zc_guid);
4772 if (zc.zc_nvlist_conf_size) {
4773 (void) printf(" nvlist_conf:\n");
4774 show_packed_nvlist(pri, zc.zc_nvlist_conf,
4775 zc.zc_nvlist_conf_size);
4777 if (zc.zc_nvlist_src_size) {
4778 (void) printf(" nvlist_src:\n");
4779 show_packed_nvlist(pri, zc.zc_nvlist_src,
4780 zc.zc_nvlist_src_size);
4782 if (zc.zc_nvlist_dst_size) {
4783 (void) printf(" nvlist_dst:\n");
4784 show_packed_nvlist(pri, zc.zc_nvlist_dst,
4785 zc.zc_nvlist_dst_size);
4787 if (zc.zc_cookie != 0) {
4788 (void) printf(" zc_cookie=%llu\n",
4789 (u_longlong_t)zc.zc_cookie);
4791 if (zc.zc_objset_type != 0) {
4792 (void) printf(" zc_objset_type=%llu\n",
4793 (u_longlong_t)zc.zc_objset_type);
4795 if (zc.zc_perm_action != 0) {
4796 (void) printf(" zc_perm_action=%llu\n",
4797 (u_longlong_t)zc.zc_perm_action);
4799 if (zc.zc_history != 0) {
4800 (void) printf(" zc_history=%llu\n",
4801 (u_longlong_t)zc.zc_history);
4803 if (zc.zc_obj != 0) {
4804 (void) printf(" zc_obj=%llu\n",
4805 (u_longlong_t)zc.zc_obj);
4807 if (zc.zc_iflags != 0) {
4808 (void) printf(" zc_obj=0x%llx\n",
4809 (u_longlong_t)zc.zc_iflags);
4812 if (memcmp(&zc.zc_share, &zero_share, sizeof (zc.zc_share))) {
4813 zfs_share_t *z = &zc.zc_share;
4814 (void) printf(" zc_share:\n");
4815 if (z->z_exportdata) {
4816 (void) printf("\tz_exportdata=0x%llx\n",
4817 (u_longlong_t)z->z_exportdata);
4819 if (z->z_sharedata) {
4820 (void) printf("\tz_sharedata=0x%llx\n",
4821 (u_longlong_t)z->z_sharedata);
4823 if (z->z_sharetype) {
4824 (void) printf("\tz_sharetype=%llu\n",
4825 (u_longlong_t)z->z_sharetype);
4827 if (z->z_sharemax) {
4828 (void) printf("\tz_sharemax=%llu\n",
4829 (u_longlong_t)z->z_sharemax);
4833 if (memcmp(&zc.zc_objset_stats, &zero_objstats,
4834 sizeof (zc.zc_objset_stats))) {
4835 dmu_objset_stats_t *dds = &zc.zc_objset_stats;
4836 (void) printf(" zc_objset_stats:\n");
4837 if (dds->dds_num_clones) {
4838 (void) printf("\tdds_num_clones=%llu\n",
4839 (u_longlong_t)dds->dds_num_clones);
4841 if (dds->dds_creation_txg) {
4842 (void) printf("\tdds_creation_txg=%llu\n",
4843 (u_longlong_t)dds->dds_creation_txg);
4845 if (dds->dds_guid) {
4846 (void) printf("\tdds_guid=%llu\n",
4847 (u_longlong_t)dds->dds_guid);
4849 if (dds->dds_type)
4850 (void) printf("\tdds_type=%u\n", dds->dds_type);
4851 if (dds->dds_is_snapshot) {
4852 (void) printf("\tdds_is_snapshot=%u\n",
4853 dds->dds_is_snapshot);
4855 if (dds->dds_inconsistent) {
4856 (void) printf("\tdds_inconsitent=%u\n",
4857 dds->dds_inconsistent);
4859 if (dds->dds_origin[0]) {
4860 (void) printf("\tdds_origin=%s\n", dds->dds_origin);
4864 if (memcmp(&zc.zc_begin_record, &zero_drrbegin,
4865 sizeof (zc.zc_begin_record))) {
4866 struct drr_begin *drr = &zc.zc_begin_record.drr_u.drr_begin;
4867 (void) printf(" zc_begin_record:\n");
4868 if (drr->drr_magic) {
4869 (void) printf("\tdrr_magic=%llu\n",
4870 (u_longlong_t)drr->drr_magic);
4872 if (drr->drr_versioninfo) {
4873 (void) printf("\tdrr_versioninfo=%llu\n",
4874 (u_longlong_t)drr->drr_versioninfo);
4876 if (drr->drr_creation_time) {
4877 (void) printf("\tdrr_creation_time=%llu\n",
4878 (u_longlong_t)drr->drr_creation_time);
4880 if (drr->drr_type)
4881 (void) printf("\tdrr_type=%u\n", drr->drr_type);
4882 if (drr->drr_flags)
4883 (void) printf("\tdrr_flags=0x%x\n", drr->drr_flags);
4884 if (drr->drr_toguid) {
4885 (void) printf("\tdrr_toguid=%llu\n",
4886 (u_longlong_t)drr->drr_toguid);
4888 if (drr->drr_fromguid) {
4889 (void) printf("\tdrr_fromguid=%llu\n",
4890 (u_longlong_t)drr->drr_fromguid);
4892 if (drr->drr_toname[0]) {
4893 (void) printf("\tdrr_toname=%s\n", drr->drr_toname);
4897 if (memcmp(&zc.zc_inject_record, &zero_injectrec,
4898 sizeof (zc.zc_inject_record))) {
4899 zinject_record_t *zi = &zc.zc_inject_record;
4900 (void) printf(" zc_inject_record:\n");
4901 if (zi->zi_objset) {
4902 (void) printf("\tzi_objset=%llu\n",
4903 (u_longlong_t)zi->zi_objset);
4905 if (zi->zi_object) {
4906 (void) printf("\tzi_object=%llu\n",
4907 (u_longlong_t)zi->zi_object);
4909 if (zi->zi_start) {
4910 (void) printf("\tzi_start=%llu\n",
4911 (u_longlong_t)zi->zi_start);
4913 if (zi->zi_end) {
4914 (void) printf("\tzi_end=%llu\n",
4915 (u_longlong_t)zi->zi_end);
4917 if (zi->zi_guid) {
4918 (void) printf("\tzi_guid=%llu\n",
4919 (u_longlong_t)zi->zi_guid);
4921 if (zi->zi_level) {
4922 (void) printf("\tzi_level=%lu\n",
4923 (ulong_t)zi->zi_level);
4925 if (zi->zi_error) {
4926 (void) printf("\tzi_error=%lu\n",
4927 (ulong_t)zi->zi_error);
4929 if (zi->zi_type) {
4930 (void) printf("\tzi_type=%llu\n",
4931 (u_longlong_t)zi->zi_type);
4933 if (zi->zi_freq) {
4934 (void) printf("\tzi_freq=%lu\n",
4935 (ulong_t)zi->zi_freq);
4937 if (zi->zi_failfast) {
4938 (void) printf("\tzi_failfast=%lu\n",
4939 (ulong_t)zi->zi_failfast);
4941 if (zi->zi_func[0])
4942 (void) printf("\tzi_func=%s\n", zi->zi_func);
4943 if (zi->zi_iotype) {
4944 (void) printf("\tzi_iotype=%lu\n",
4945 (ulong_t)zi->zi_iotype);
4947 if (zi->zi_duration) {
4948 (void) printf("\tzi_duration=%ld\n",
4949 (long)zi->zi_duration);
4951 if (zi->zi_timer) {
4952 (void) printf("\tzi_timer=%llu\n",
4953 (u_longlong_t)zi->zi_timer);
4957 if (zc.zc_defer_destroy) {
4958 (void) printf(" zc_defer_destroy=%d\n",
4959 (int)zc.zc_defer_destroy);
4961 if (zc.zc_flags) {
4962 (void) printf(" zc_flags=0x%x\n",
4963 zc.zc_flags);
4965 if (zc.zc_action_handle) {
4966 (void) printf(" zc_action_handle=%llu\n",
4967 (u_longlong_t)zc.zc_action_handle);
4969 if (zc.zc_cleanup_fd >= 0)
4970 (void) printf(" zc_cleanup_fd=%d\n", zc.zc_cleanup_fd);
4971 if (zc.zc_sendobj) {
4972 (void) printf(" zc_sendobj=%llu\n",
4973 (u_longlong_t)zc.zc_sendobj);
4975 if (zc.zc_fromobj) {
4976 (void) printf(" zc_fromobj=%llu\n",
4977 (u_longlong_t)zc.zc_fromobj);
4979 if (zc.zc_createtxg) {
4980 (void) printf(" zc_createtxg=%llu\n",
4981 (u_longlong_t)zc.zc_createtxg);
4984 if (memcmp(&zc.zc_stat, &zero_zstat, sizeof (zc.zc_stat))) {
4985 zfs_stat_t *zs = &zc.zc_stat;
4986 (void) printf(" zc_stat:\n");
4987 if (zs->zs_gen) {
4988 (void) printf("\tzs_gen=%llu\n",
4989 (u_longlong_t)zs->zs_gen);
4991 if (zs->zs_mode) {
4992 (void) printf("\tzs_mode=%llu\n",
4993 (u_longlong_t)zs->zs_mode);
4995 if (zs->zs_links) {
4996 (void) printf("\tzs_links=%llu\n",
4997 (u_longlong_t)zs->zs_links);
4999 if (zs->zs_ctime[0]) {
5000 (void) printf("\tzs_ctime[0]=%llu\n",
5001 (u_longlong_t)zs->zs_ctime[0]);
5003 if (zs->zs_ctime[1]) {
5004 (void) printf("\tzs_ctime[1]=%llu\n",
5005 (u_longlong_t)zs->zs_ctime[1]);
5010 /* expound verbosely upon syscall arguments */
5011 /*ARGSUSED*/
5012 void
5013 expound(private_t *pri, long r0, int raw)
5015 const lwpstatus_t *Lsp = pri->lwpstat;
5016 int lp64 = (data_model == PR_MODEL_LP64);
5017 int what = Lsp->pr_what;
5018 int err = pri->Errno; /* don't display output parameters */
5019 /* for a failed system call */
5020 #ifndef _LP64
5021 /* We are a 32-bit truss; we can't grok a 64-bit process */
5022 if (lp64)
5023 return;
5024 #endif
5025 /* for reporting sleeping system calls */
5026 if (what == 0 && (Lsp->pr_flags & (PR_ASLEEP|PR_VFORKP)))
5027 what = Lsp->pr_syscall;
5029 switch (what) {
5030 case SYS_gettimeofday:
5031 if (!err)
5032 show_timeofday(pri);
5033 break;
5034 case SYS_getitimer:
5035 if (!err && pri->sys_nargs > 1)
5036 show_itimerval(pri, (long)pri->sys_args[1],
5037 " value");
5038 break;
5039 case SYS_setitimer:
5040 if (pri->sys_nargs > 1)
5041 show_itimerval(pri, (long)pri->sys_args[1],
5042 " value");
5043 if (!err && pri->sys_nargs > 2)
5044 show_itimerval(pri, (long)pri->sys_args[2],
5045 "ovalue");
5046 break;
5047 case SYS_stime:
5048 show_stime(pri);
5049 break;
5050 case SYS_times:
5051 if (!err)
5052 show_times(pri);
5053 break;
5054 case SYS_utssys:
5055 if (err)
5056 break;
5057 #ifdef _LP64
5058 if (lp64)
5059 show_utssys(pri, r0);
5060 else
5061 show_utssys32(pri, r0);
5062 #else
5063 show_utssys(pri, r0);
5064 #endif
5065 break;
5066 case SYS_ioctl:
5067 if (pri->sys_nargs >= 3) /* each case must decide for itself */
5068 show_ioctl(pri, pri->sys_args[1],
5069 (long)pri->sys_args[2]);
5070 break;
5071 case SYS_fstatat:
5072 if (!err && pri->sys_nargs >= 3)
5073 show_stat(pri, (long)pri->sys_args[2]);
5074 break;
5075 case SYS_fstatat64:
5076 if (!err && pri->sys_nargs >= 3)
5077 show_stat64_32(pri, (long)pri->sys_args[2]);
5078 break;
5079 case SYS_stat:
5080 case SYS_fstat:
5081 case SYS_lstat:
5082 if (!err && pri->sys_nargs >= 2)
5083 show_stat(pri, (long)pri->sys_args[1]);
5084 break;
5085 case SYS_stat64:
5086 case SYS_fstat64:
5087 case SYS_lstat64:
5088 if (!err && pri->sys_nargs >= 2)
5089 show_stat64_32(pri, (long)pri->sys_args[1]);
5090 break;
5091 case SYS_statvfs:
5092 case SYS_fstatvfs:
5093 if (err)
5094 break;
5095 #ifdef _LP64
5096 if (!lp64) {
5097 show_statvfs32(pri);
5098 break;
5100 #endif
5101 show_statvfs(pri);
5102 break;
5103 case SYS_statvfs64:
5104 case SYS_fstatvfs64:
5105 if (err)
5106 break;
5107 show_statvfs64(pri);
5108 break;
5109 case SYS_statfs:
5110 case SYS_fstatfs:
5111 if (err)
5112 break;
5113 #ifdef _LP64
5114 if (lp64)
5115 show_statfs(pri);
5116 else
5117 show_statfs32(pri);
5118 #else
5119 show_statfs(pri);
5120 #endif
5121 break;
5122 case SYS_fcntl:
5123 show_fcntl(pri);
5124 break;
5125 case SYS_msgsys:
5126 show_msgsys(pri, r0); /* each case must decide for itself */
5127 break;
5128 case SYS_semsys:
5129 show_semsys(pri); /* each case must decide for itself */
5130 break;
5131 case SYS_shmsys:
5132 show_shmsys(pri); /* each case must decide for itself */
5133 break;
5134 case SYS_getdents:
5135 if (err || pri->sys_nargs <= 1 || r0 <= 0)
5136 break;
5137 #ifdef _LP64
5138 if (!lp64) {
5139 show_dents32(pri, (long)pri->sys_args[1], r0);
5140 break;
5142 #else
5143 show_dents32(pri, (long)pri->sys_args[1], r0);
5144 break;
5145 #endif
5146 /* FALLTHROUGH */
5147 case SYS_getdents64:
5148 if (err || pri->sys_nargs <= 1 || r0 <= 0)
5149 break;
5150 show_dents64(pri, (long)pri->sys_args[1], r0);
5151 break;
5152 case SYS_getmsg:
5153 show_gp_msg(pri, what);
5154 if (pri->sys_nargs > 3)
5155 show_hhex_int(pri, (long)pri->sys_args[3], "flags");
5156 break;
5157 case SYS_getpmsg:
5158 show_gp_msg(pri, what);
5159 if (pri->sys_nargs > 3)
5160 show_hhex_int(pri, (long)pri->sys_args[3], "band");
5161 if (pri->sys_nargs > 4)
5162 show_hhex_int(pri, (long)pri->sys_args[4], "flags");
5163 break;
5164 case SYS_putmsg:
5165 case SYS_putpmsg:
5166 show_gp_msg(pri, what);
5167 break;
5168 case SYS_pollsys:
5169 show_pollsys(pri);
5170 break;
5171 case SYS_setgroups:
5172 if (pri->sys_nargs > 1 && (r0 = pri->sys_args[0]) > 0)
5173 show_groups(pri, (long)pri->sys_args[1], r0);
5174 break;
5175 case SYS_getgroups:
5176 if (!err && pri->sys_nargs > 1 && pri->sys_args[0] > 0)
5177 show_groups(pri, (long)pri->sys_args[1], r0);
5178 break;
5179 case SYS_sigprocmask:
5180 if (pri->sys_nargs > 1)
5181 show_sigset(pri, (long)pri->sys_args[1], " set");
5182 if (!err && pri->sys_nargs > 2)
5183 show_sigset(pri, (long)pri->sys_args[2], "oset");
5184 break;
5185 case SYS_sigsuspend:
5186 case SYS_sigtimedwait:
5187 if (pri->sys_nargs > 0)
5188 show_sigset(pri, (long)pri->sys_args[0], "sigmask");
5189 if (!err && pri->sys_nargs > 1)
5190 show_siginfo(pri, (long)pri->sys_args[1]);
5191 if (pri->sys_nargs > 2)
5192 show_timestruc(pri, (long)pri->sys_args[2], "timeout");
5193 break;
5194 case SYS_sigaltstack:
5195 if (pri->sys_nargs > 0)
5196 show_sigaltstack(pri, (long)pri->sys_args[0],
5197 "new");
5198 if (!err && pri->sys_nargs > 1)
5199 show_sigaltstack(pri, (long)pri->sys_args[1],
5200 "old");
5201 break;
5202 case SYS_sigaction:
5203 if (pri->sys_nargs > 1)
5204 show_sigaction(pri, (long)pri->sys_args[1],
5205 "new", 0);
5206 if (!err && pri->sys_nargs > 2)
5207 show_sigaction(pri, (long)pri->sys_args[2],
5208 "old", r0);
5209 break;
5210 case SYS_signotify:
5211 if (pri->sys_nargs > 1)
5212 show_siginfo(pri, (long)pri->sys_args[1]);
5213 break;
5214 case SYS_sigresend:
5215 if (pri->sys_nargs > 1)
5216 show_siginfo(pri, (long)pri->sys_args[1]);
5217 if (pri->sys_nargs > 2)
5218 show_sigset(pri, (long)pri->sys_args[2], "sigmask");
5219 break;
5220 case SYS_sigpending:
5221 if (!err && pri->sys_nargs > 1)
5222 show_sigset(pri, (long)pri->sys_args[1], "sigmask");
5223 break;
5224 case SYS_waitid:
5225 if (!err && pri->sys_nargs > 2)
5226 show_siginfo(pri, (long)pri->sys_args[2]);
5227 break;
5228 case SYS_sigsendsys:
5229 if (pri->sys_nargs > 0)
5230 show_procset(pri, (long)pri->sys_args[0]);
5231 break;
5232 case SYS_priocntlsys:
5233 if (pri->sys_nargs > 1)
5234 show_procset(pri, (long)pri->sys_args[1]);
5235 break;
5236 case SYS_mincore:
5237 if (!err && pri->sys_nargs > 2)
5238 show_bool(pri, (long)pri->sys_args[2],
5239 (pri->sys_args[1] + pagesize - 1) / pagesize);
5240 break;
5241 case SYS_readv:
5242 case SYS_writev:
5243 if (pri->sys_nargs > 2) {
5244 int i = pri->sys_args[0]+1;
5245 int showbuf = FALSE;
5246 long nb = (what == SYS_readv)? r0 : 32*1024;
5248 if ((what == SYS_readv && !err &&
5249 prismember(&readfd, i)) ||
5250 (what == SYS_writev &&
5251 prismember(&writefd, i)))
5252 showbuf = TRUE;
5253 show_iovec(pri, (long)pri->sys_args[1],
5254 pri->sys_args[2], showbuf, nb);
5256 break;
5257 case SYS_getrlimit:
5258 if (err)
5259 break;
5260 /*FALLTHROUGH*/
5261 case SYS_setrlimit:
5262 if (pri->sys_nargs <= 1)
5263 break;
5264 #ifdef _LP64
5265 if (lp64)
5266 show_rlimit64(pri, (long)pri->sys_args[1]);
5267 else
5268 show_rlimit32(pri, (long)pri->sys_args[1]);
5269 #else
5270 show_rlimit32(pri, (long)pri->sys_args[1]);
5271 #endif
5272 break;
5273 case SYS_getrlimit64:
5274 if (err)
5275 break;
5276 /*FALLTHROUGH*/
5277 case SYS_setrlimit64:
5278 if (pri->sys_nargs <= 1)
5279 break;
5280 show_rlimit64(pri, (long)pri->sys_args[1]);
5281 break;
5282 case SYS_uname:
5283 if (!err && pri->sys_nargs > 0)
5284 show_uname(pri, (long)pri->sys_args[0]);
5285 break;
5286 case SYS_adjtime:
5287 if (!err && pri->sys_nargs > 1)
5288 show_adjtime(pri, (long)pri->sys_args[0],
5289 (long)pri->sys_args[1]);
5290 break;
5291 case SYS_lwp_info:
5292 if (!err && pri->sys_nargs > 0)
5293 show_timestruc(pri, (long)pri->sys_args[0], "cpu time");
5294 break;
5295 case SYS_lwp_wait:
5296 if (!err && pri->sys_nargs > 1)
5297 show_int(pri, (long)pri->sys_args[1], "lwpid");
5298 break;
5299 case SYS_lwp_mutex_wakeup:
5300 case SYS_lwp_mutex_unlock:
5301 case SYS_lwp_mutex_trylock:
5302 case SYS_lwp_mutex_register:
5303 if (pri->sys_nargs > 0)
5304 show_mutex(pri, (long)pri->sys_args[0]);
5305 break;
5306 case SYS_lwp_mutex_timedlock:
5307 if (pri->sys_nargs > 0)
5308 show_mutex(pri, (long)pri->sys_args[0]);
5309 if (pri->sys_nargs > 1)
5310 show_timestruc(pri, (long)pri->sys_args[1], "timeout");
5311 break;
5312 case SYS_lwp_cond_wait:
5313 if (pri->sys_nargs > 0)
5314 show_condvar(pri, (long)pri->sys_args[0]);
5315 if (pri->sys_nargs > 1)
5316 show_mutex(pri, (long)pri->sys_args[1]);
5317 if (pri->sys_nargs > 2)
5318 show_timestruc(pri, (long)pri->sys_args[2], "timeout");
5319 break;
5320 case SYS_lwp_cond_signal:
5321 case SYS_lwp_cond_broadcast:
5322 if (pri->sys_nargs > 0)
5323 show_condvar(pri, (long)pri->sys_args[0]);
5324 break;
5325 case SYS_lwp_sema_trywait:
5326 case SYS_lwp_sema_post:
5327 if (pri->sys_nargs > 0)
5328 show_sema(pri, (long)pri->sys_args[0]);
5329 break;
5330 case SYS_lwp_sema_timedwait:
5331 if (pri->sys_nargs > 0)
5332 show_sema(pri, (long)pri->sys_args[0]);
5333 if (pri->sys_nargs > 1)
5334 show_timestruc(pri, (long)pri->sys_args[1], "timeout");
5335 break;
5336 case SYS_lwp_rwlock_sys:
5337 if (pri->sys_nargs > 1)
5338 show_rwlock(pri, (long)pri->sys_args[1]);
5339 if (pri->sys_nargs > 2 &&
5340 (pri->sys_args[0] == 0 || pri->sys_args[0] == 1))
5341 show_timestruc(pri, (long)pri->sys_args[2], "timeout");
5342 break;
5343 case SYS_lwp_create:
5344 /* XXX print some values in ucontext ??? */
5345 if (!err && pri->sys_nargs > 2)
5346 show_int(pri, (long)pri->sys_args[2], "lwpid");
5347 break;
5348 case SYS_kaio:
5349 if (pri->sys_args[0] == AIOWAIT && !err && pri->sys_nargs > 1)
5350 show_timeval(pri, (long)pri->sys_args[1], "timeout");
5351 break;
5352 case SYS_nanosleep:
5353 if (pri->sys_nargs > 0)
5354 show_timestruc(pri, (long)pri->sys_args[0], "tmout");
5355 if (pri->sys_nargs > 1 && (err == 0 || err == EINTR))
5356 show_timestruc(pri, (long)pri->sys_args[1], "resid");
5357 break;
5358 case SYS_privsys:
5359 switch (pri->sys_args[0]) {
5360 case PRIVSYS_SETPPRIV:
5361 case PRIVSYS_GETPPRIV:
5362 if (!err)
5363 show_privset(pri, (long)pri->sys_args[3],
5364 (size_t)pri->sys_args[4], "");
5366 break;
5367 case SYS_ucredsys:
5368 switch (pri->sys_args[0]) {
5369 case UCREDSYS_UCREDGET:
5370 case UCREDSYS_GETPEERUCRED:
5371 if (err == 0)
5372 show_ucred(pri, (long)pri->sys_args[2]);
5373 break;
5375 break;
5376 case SYS_bind:
5377 case SYS_connect:
5378 if (pri->sys_nargs > 2)
5379 show_sockaddr(pri, "name", (long)pri->sys_args[1],
5380 0, (long)pri->sys_args[2]);
5381 break;
5382 case SYS_sendto:
5383 if (pri->sys_nargs > 5)
5384 show_sockaddr(pri, "to", (long)pri->sys_args[4], 0,
5385 pri->sys_args[5]);
5386 break;
5387 case SYS_accept:
5388 if (!err && pri->sys_nargs > 2)
5389 show_sockaddr(pri, "name", (long)pri->sys_args[1],
5390 (long)pri->sys_args[2], 0);
5391 break;
5392 case SYS_getsockname:
5393 case SYS_getpeername:
5394 if (!err && pri->sys_nargs > 2)
5395 show_sockaddr(pri, "name", (long)pri->sys_args[1],
5396 (long)pri->sys_args[2], 0);
5397 break;
5398 case SYS_recvfrom:
5399 if (!err && pri->sys_nargs > 5)
5400 show_sockaddr(pri, "from", (long)pri->sys_args[4],
5401 (long)pri->sys_args[5], 0);
5402 break;
5403 case SYS_recvmsg:
5404 if (err)
5405 break;
5406 /* FALLTHROUGH */
5407 case SYS_sendmsg:
5408 if (pri->sys_nargs <= 2)
5409 break;
5410 #ifdef _LP64
5411 if (lp64)
5412 show_msghdr(pri, pri->sys_args[1]);
5413 else
5414 show_msghdr32(pri, pri->sys_args[1]);
5415 #else
5416 show_msghdr(pri, pri->sys_args[1]);
5417 #endif
5418 break;
5419 case SYS_door:
5420 show_doors(pri);
5421 break;
5422 case SYS_sendfilev:
5423 if (pri->sys_nargs != 5)
5424 break;
5426 if (pri->sys_args[0] == SENDFILEV) {
5427 show_sendfilevec(pri, (int)pri->sys_args[1],
5428 (sendfilevec_t *)pri->sys_args[2],
5429 (int)pri->sys_args[3]);
5430 } else if (pri->sys_args[0] == SENDFILEV64) {
5431 show_sendfilevec64(pri, (int)pri->sys_args[1],
5432 (sendfilevec64_t *)pri->sys_args[2],
5433 (int)pri->sys_args[3]);
5435 break;
5436 case SYS_memcntl:
5437 show_memcntl(pri);
5438 break;
5439 case SYS_lwp_park:
5441 * subcode 0: lwp_park(timespec_t *, id_t)
5442 * subcode 4: lwp_set_park(timespec_t *, id_t)
5444 if (pri->sys_nargs > 1 &&
5445 (pri->sys_args[0] == 0 || pri->sys_args[0] == 4))
5446 show_timestruc(pri, (long)pri->sys_args[1], "timeout");
5447 /* subcode 2: lwp_unpark_all(id_t *, int) */
5448 if (pri->sys_nargs > 2 && pri->sys_args[0] == 2)
5449 show_ids(pri, (long)pri->sys_args[1],
5450 (int)pri->sys_args[2]);
5451 break;
5452 case SYS_ntp_gettime:
5453 if (!err)
5454 show_ntp_gettime(pri);
5455 break;
5456 case SYS_ntp_adjtime:
5457 if (!err)
5458 show_ntp_adjtime(pri);
5459 break;
5460 case SYS_rusagesys:
5461 if (!err)
5462 if (pri->sys_args[0] == _RUSAGESYS_GETRUSAGE) {
5463 #ifdef _LP64
5464 if (!lp64)
5465 show_getrusage32(pri->sys_args[1]);
5466 else
5467 #endif
5468 show_getrusage(pri->sys_args[1]);
5470 break;
5471 case SYS_port:
5472 show_ports(pri);
5473 break;
5474 case SYS_zone:
5475 show_zones(pri);
5476 break;
5477 case SYS_rctlsys:
5478 show_rctls(pri);
5479 break;
5480 case SYS_utimesys:
5481 show_utimesys(pri);
5482 break;
5483 case SYS_sockconfig:
5484 show_sockconfig(pri);
5485 break;