1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28 /* All Rights Reserved */ 29 30 31 #pragma ident "%Z%%M% %I% %E% SMI" 32 33 #define _SYSCALL32 34 35 #include <stdio.h> 36 #include <stdlib.h> 37 #include <unistd.h> 38 #include <ctype.h> 39 #include <sys/types.h> 40 #include <sys/mman.h> 41 #include <libproc.h> 42 #include <string.h> 43 #include <limits.h> 44 #include <sys/statfs.h> 45 #include <sys/times.h> 46 #include <sys/timex.h> 47 #include <sys/utssys.h> 48 #include <sys/utsname.h> 49 #include <sys/ipc.h> 50 #include <sys/ipc_impl.h> 51 #include <sys/msg.h> 52 #include <sys/msg_impl.h> 53 #include <sys/sem.h> 54 #include <sys/sem_impl.h> 55 #include <sys/shm.h> 56 #include <sys/shm_impl.h> 57 #include <sys/dirent.h> 58 #include <sys/utime.h> 59 #include <ustat.h> 60 #include <fcntl.h> 61 #include <time.h> 62 #include <sys/termios.h> 63 #include <sys/termiox.h> 64 #include <sys/termio.h> 65 #include <sys/ttold.h> 66 #include <sys/jioctl.h> 67 #include <sys/filio.h> 68 #include <stropts.h> 69 #include <poll.h> 70 #include <sys/uio.h> 71 #include <sys/resource.h> 72 #include <sys/statvfs.h> 73 #include <sys/time.h> 74 #include <sys/aio.h> 75 #include <sys/socket.h> 76 #include <netinet/in.h> 77 #include <sys/un.h> 78 #include <sys/byteorder.h> 79 #include <arpa/inet.h> 80 #include <sys/audioio.h> 81 #include <sys/cladm.h> 82 #include <sys/synch.h> 83 #include <sys/synch32.h> 84 #include <sys/sysmacros.h> 85 #include <sys/sendfile.h> 86 #include <priv.h> 87 #include <ucred.h> 88 #include <sys/ucred.h> 89 #include <sys/port_impl.h> 90 91 #include "ramdata.h" 92 #include "systable.h" 93 #include "proto.h" 94 95 void show_sigset(private_t *, long, const char *); 96 void show_ioctl(private_t *, int, long); 97 98 void 99 prtime(private_t *pri, const char *name, time_t value) 100 { 101 char str[80]; 102 103 (void) strftime(str, sizeof (str), "%b %e %H:%M:%S %Z %Y", 104 localtime(&value)); 105 (void) printf("%s\t%s%s [ %llu ]\n", 106 pri->pname, 107 name, 108 str, 109 (longlong_t)value); 110 } 111 112 void 113 prtimestruc(private_t *pri, const char *name, timestruc_t *value) 114 { 115 prtime(pri, name, value->tv_sec); 116 } 117 118 void 119 show_utime(private_t *pri) 120 { 121 long offset; 122 struct utimbuf utimbuf; 123 124 if (pri->sys_nargs < 2 || (offset = pri->sys_args[1]) == NULL) 125 return; 126 127 if (data_model == PR_MODEL_NATIVE) { 128 if (Pread(Proc, &utimbuf, sizeof (utimbuf), offset) 129 != sizeof (utimbuf)) 130 return; 131 } else { 132 struct utimbuf32 utimbuf32; 133 134 if (Pread(Proc, &utimbuf32, sizeof (utimbuf32), offset) 135 != sizeof (utimbuf32)) 136 return; 137 138 utimbuf.actime = (time_t)utimbuf32.actime; 139 utimbuf.modtime = (time_t)utimbuf32.modtime; 140 } 141 142 /* print access and modification times */ 143 prtime(pri, "atime: ", utimbuf.actime); 144 prtime(pri, "mtime: ", utimbuf.modtime); 145 } 146 147 void 148 show_utimes(private_t *pri) 149 { 150 long offset; 151 struct { 152 struct timeval atime; 153 struct timeval mtime; 154 } utimbuf; 155 156 if (pri->sys_nargs < 2 || (offset = pri->sys_args[1]) == NULL) 157 return; 158 159 if (data_model == PR_MODEL_NATIVE) { 160 if (Pread(Proc, &utimbuf, sizeof (utimbuf), offset) 161 != sizeof (utimbuf)) 162 return; 163 } else { 164 struct { 165 struct timeval32 atime; 166 struct timeval32 mtime; 167 } utimbuf32; 168 169 if (Pread(Proc, &utimbuf32, sizeof (utimbuf32), offset) 170 != sizeof (utimbuf32)) 171 return; 172 173 TIMEVAL32_TO_TIMEVAL(&utimbuf.atime, &utimbuf32.atime); 174 TIMEVAL32_TO_TIMEVAL(&utimbuf.mtime, &utimbuf32.mtime); 175 } 176 177 /* print access and modification times */ 178 prtime(pri, "atime: ", utimbuf.atime.tv_sec); 179 prtime(pri, "mtime: ", utimbuf.mtime.tv_sec); 180 } 181 182 void 183 show_timeofday(private_t *pri) 184 { 185 struct timeval tod; 186 long offset; 187 188 if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == NULL) 189 return; 190 191 if (data_model == PR_MODEL_NATIVE) { 192 if (Pread(Proc, &tod, sizeof (tod), offset) 193 != sizeof (tod)) 194 return; 195 } else { 196 struct timeval32 tod32; 197 198 if (Pread(Proc, &tod32, sizeof (tod32), offset) 199 != sizeof (tod32)) 200 return; 201 202 TIMEVAL32_TO_TIMEVAL(&tod, &tod32); 203 } 204 205 prtime(pri, "time: ", tod.tv_sec); 206 } 207 208 void 209 show_itimerval(private_t *pri, long offset, const char *name) 210 { 211 struct itimerval itimerval; 212 213 if (offset == NULL) 214 return; 215 216 if (data_model == PR_MODEL_NATIVE) { 217 if (Pread(Proc, &itimerval, sizeof (itimerval), offset) 218 != sizeof (itimerval)) 219 return; 220 } else { 221 struct itimerval32 itimerval32; 222 223 if (Pread(Proc, &itimerval32, sizeof (itimerval32), offset) 224 != sizeof (itimerval32)) 225 return; 226 227 ITIMERVAL32_TO_ITIMERVAL(&itimerval, &itimerval32); 228 } 229 230 (void) printf( 231 "%s\t%s: interval: %4ld.%6.6ld sec value: %4ld.%6.6ld sec\n", 232 pri->pname, 233 name, 234 itimerval.it_interval.tv_sec, 235 itimerval.it_interval.tv_usec, 236 itimerval.it_value.tv_sec, 237 itimerval.it_value.tv_usec); 238 } 239 240 void 241 show_timeval(private_t *pri, long offset, const char *name) 242 { 243 struct timeval timeval; 244 245 if (offset == NULL) 246 return; 247 248 if (data_model == PR_MODEL_NATIVE) { 249 if (Pread(Proc, &timeval, sizeof (timeval), offset) 250 != sizeof (timeval)) 251 return; 252 } else { 253 struct timeval32 timeval32; 254 255 if (Pread(Proc, &timeval32, sizeof (timeval32), offset) 256 != sizeof (timeval32)) 257 return; 258 259 TIMEVAL32_TO_TIMEVAL(&timeval, &timeval32); 260 } 261 262 (void) printf( 263 "%s\t%s: %ld.%6.6ld sec\n", 264 pri->pname, 265 name, 266 timeval.tv_sec, 267 timeval.tv_usec); 268 } 269 270 void 271 show_timestruc(private_t *pri, long offset, const char *name) 272 { 273 timestruc_t timestruc; 274 275 if (offset == NULL) 276 return; 277 278 if (data_model == PR_MODEL_NATIVE) { 279 if (Pread(Proc, ×truc, sizeof (timestruc), offset) 280 != sizeof (timestruc)) 281 return; 282 } else { 283 timestruc32_t timestruc32; 284 285 if (Pread(Proc, ×truc32, sizeof (timestruc32), offset) 286 != sizeof (timestruc32)) 287 return; 288 289 TIMESPEC32_TO_TIMESPEC(×truc, ×truc32); 290 } 291 292 (void) printf( 293 "%s\t%s: %ld.%9.9ld sec\n", 294 pri->pname, 295 name, 296 timestruc.tv_sec, 297 timestruc.tv_nsec); 298 } 299 300 void 301 show_stime(private_t *pri) 302 { 303 if (pri->sys_nargs >= 1) { 304 /* print new system time */ 305 prtime(pri, "systime = ", (time_t)pri->sys_args[0]); 306 } 307 } 308 309 void 310 show_times(private_t *pri) 311 { 312 long hz = sysconf(_SC_CLK_TCK); 313 long offset; 314 struct tms tms; 315 316 if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == NULL) 317 return; 318 319 if (data_model == PR_MODEL_NATIVE) { 320 if (Pread(Proc, &tms, sizeof (tms), offset) 321 != sizeof (tms)) 322 return; 323 } else { 324 struct tms32 tms32; 325 326 if (Pread(Proc, &tms32, sizeof (tms32), offset) 327 != sizeof (tms32)) 328 return; 329 330 /* 331 * This looks a bit odd (since the values are actually 332 * signed), but we need to suppress sign extension to 333 * preserve compatibility (we've always printed these 334 * numbers as unsigned quantities). 335 */ 336 tms.tms_utime = (unsigned)tms32.tms_utime; 337 tms.tms_stime = (unsigned)tms32.tms_stime; 338 tms.tms_cutime = (unsigned)tms32.tms_cutime; 339 tms.tms_cstime = (unsigned)tms32.tms_cstime; 340 } 341 342 (void) printf( 343 "%s\tutim=%-6lu stim=%-6lu cutim=%-6lu cstim=%-6lu (HZ=%ld)\n", 344 pri->pname, 345 tms.tms_utime, 346 tms.tms_stime, 347 tms.tms_cutime, 348 tms.tms_cstime, 349 hz); 350 } 351 352 void 353 show_uname(private_t *pri, long offset) 354 { 355 /* 356 * Old utsname buffer (no longer accessible in <sys/utsname.h>). 357 */ 358 struct { 359 char sysname[9]; 360 char nodename[9]; 361 char release[9]; 362 char version[9]; 363 char machine[9]; 364 } ubuf; 365 366 if (offset != NULL && 367 Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) { 368 (void) printf( 369 "%s\tsys=%-9.9snod=%-9.9srel=%-9.9sver=%-9.9smch=%.9s\n", 370 pri->pname, 371 ubuf.sysname, 372 ubuf.nodename, 373 ubuf.release, 374 ubuf.version, 375 ubuf.machine); 376 } 377 } 378 379 /* XX64 -- definition of 'struct ustat' is strange -- check out the defn */ 380 void 381 show_ustat(private_t *pri, long offset) 382 { 383 struct ustat ubuf; 384 385 if (offset != NULL && 386 Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) { 387 (void) printf( 388 "%s\ttfree=%-6ld tinode=%-5lu fname=%-6.6s fpack=%-.6s\n", 389 pri->pname, 390 ubuf.f_tfree, 391 ubuf.f_tinode, 392 ubuf.f_fname, 393 ubuf.f_fpack); 394 } 395 } 396 397 #ifdef _LP64 398 void 399 show_ustat32(private_t *pri, long offset) 400 { 401 struct ustat32 ubuf; 402 403 if (offset != NULL && 404 Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) { 405 (void) printf( 406 "%s\ttfree=%-6d tinode=%-5u fname=%-6.6s fpack=%-.6s\n", 407 pri->pname, 408 ubuf.f_tfree, 409 ubuf.f_tinode, 410 ubuf.f_fname, 411 ubuf.f_fpack); 412 } 413 } 414 #endif /* _LP64 */ 415 416 void 417 show_fusers(private_t *pri, long offset, long nproc) 418 { 419 f_user_t fubuf; 420 int serial = (nproc > 4); 421 422 if (offset == NULL) 423 return; 424 425 /* enter region of lengthy output */ 426 if (serial) 427 Eserialize(); 428 429 while (nproc > 0 && 430 Pread(Proc, &fubuf, sizeof (fubuf), offset) == sizeof (fubuf)) { 431 (void) printf("%s\tpid=%-5d uid=%-5d flags=%s\n", 432 pri->pname, 433 (int)fubuf.fu_pid, 434 (int)fubuf.fu_uid, 435 fuflags(pri, fubuf.fu_flags)); 436 nproc--; 437 offset += sizeof (fubuf); 438 } 439 440 /* exit region of lengthy output */ 441 if (serial) 442 Xserialize(); 443 } 444 445 void 446 show_utssys(private_t *pri, long r0) 447 { 448 if (pri->sys_nargs >= 3) { 449 switch (pri->sys_args[2]) { 450 case UTS_UNAME: 451 show_uname(pri, (long)pri->sys_args[0]); 452 break; 453 case UTS_USTAT: 454 show_ustat(pri, (long)pri->sys_args[0]); 455 break; 456 case UTS_FUSERS: 457 show_fusers(pri, (long)pri->sys_args[3], r0); 458 break; 459 } 460 } 461 } 462 463 #ifdef _LP64 464 void 465 show_utssys32(private_t *pri, long r0) 466 { 467 if (pri->sys_nargs >= 3) { 468 switch (pri->sys_args[2]) { 469 case UTS_UNAME: 470 show_uname(pri, (long)pri->sys_args[0]); 471 break; 472 case UTS_USTAT: 473 show_ustat32(pri, (long)pri->sys_args[0]); 474 break; 475 case UTS_FUSERS: 476 show_fusers(pri, (long)pri->sys_args[3], r0); 477 break; 478 } 479 } 480 } 481 #endif /* _LP64 */ 482 483 void 484 show_cladm(private_t *pri, int code, int function, long offset) 485 { 486 int arg; 487 488 switch (code) { 489 case CL_INITIALIZE: 490 switch (function) { 491 case CL_GET_BOOTFLAG: 492 if (Pread(Proc, &arg, sizeof (arg), offset) 493 == sizeof (arg)) { 494 if (arg & CLUSTER_CONFIGURED) 495 (void) printf("%s\tbootflags=" 496 "CLUSTER_CONFIGURED", pri->pname); 497 if (arg & CLUSTER_BOOTED) 498 (void) printf("|CLUSTER_BOOTED\n"); 499 } 500 break; 501 } 502 break; 503 case CL_CONFIG: 504 switch (function) { 505 case CL_NODEID: 506 case CL_HIGHEST_NODEID: 507 if (Pread(Proc, &arg, sizeof (arg), offset) 508 == sizeof (arg)) 509 (void) printf("%s\tnodeid=%d\n", 510 pri->pname, arg); 511 } 512 break; 513 } 514 } 515 516 #define ALL_LOCK_TYPES \ 517 (USYNC_PROCESS|LOCK_ERRORCHECK|LOCK_RECURSIVE|USYNC_PROCESS_ROBUST|\ 518 LOCK_PRIO_INHERIT|LOCK_PRIO_PROTECT|LOCK_ROBUST_NP) 519 520 /* return cv and mutex types */ 521 const char * 522 synch_type(private_t *pri, uint_t type) 523 { 524 char *str = pri->code_buf; 525 526 if (type & USYNC_PROCESS) 527 (void) strcpy(str, "USYNC_PROCESS"); 528 else 529 (void) strcpy(str, "USYNC_THREAD"); 530 531 if (type & LOCK_ERRORCHECK) 532 (void) strcat(str, "|LOCK_ERRORCHECK"); 533 if (type & LOCK_RECURSIVE) 534 (void) strcat(str, "|LOCK_RECURSIVE"); 535 if (type & USYNC_PROCESS_ROBUST) 536 (void) strcat(str, "|USYNC_PROCESS_ROBUST"); 537 if (type & LOCK_PRIO_INHERIT) 538 (void) strcat(str, "|LOCK_PRIO_INHERIT"); 539 if (type & LOCK_PRIO_PROTECT) 540 (void) strcat(str, "|LOCK_PRIO_PROTECT"); 541 if (type & LOCK_ROBUST_NP) 542 (void) strcat(str, "|LOCK_ROBUST_NP"); 543 544 if ((type &= ~ALL_LOCK_TYPES) != 0) 545 (void) sprintf(str + strlen(str), "|0x%.4X", type); 546 547 return ((const char *)str); 548 } 549 550 void 551 show_mutex(private_t *pri, long offset) 552 { 553 lwp_mutex_t mutex; 554 555 if (Pread(Proc, &mutex, sizeof (mutex), offset) == sizeof (mutex)) { 556 (void) printf("%s\tmutex type: %s\n", 557 pri->pname, 558 synch_type(pri, mutex.mutex_type)); 559 } 560 } 561 562 void 563 show_condvar(private_t *pri, long offset) 564 { 565 lwp_cond_t condvar; 566 567 if (Pread(Proc, &condvar, sizeof (condvar), offset) 568 == sizeof (condvar)) { 569 (void) printf("%s\tcondvar type: %s\n", 570 pri->pname, 571 synch_type(pri, condvar.cond_type)); 572 } 573 } 574 575 void 576 show_sema(private_t *pri, long offset) 577 { 578 lwp_sema_t sema; 579 580 if (Pread(Proc, &sema, sizeof (sema), offset) == sizeof (sema)) { 581 (void) printf("%s\tsema type: %s count = %u\n", 582 pri->pname, 583 synch_type(pri, sema.sema_type), 584 sema.sema_count); 585 } 586 } 587 588 void 589 show_rwlock(private_t *pri, long offset) 590 { 591 lwp_rwlock_t rwlock; 592 593 if (Pread(Proc, &rwlock, sizeof (rwlock), offset) == sizeof (rwlock)) { 594 (void) printf("%s\trwlock type: %s readers = %d\n", 595 pri->pname, 596 synch_type(pri, rwlock.rwlock_type), 597 rwlock.rwlock_readers); 598 } 599 } 600 601 /* represent character as itself ('c') or octal (012) */ 602 char * 603 show_char(char *buf, int c) 604 { 605 const char *fmt; 606 607 if (c >= ' ' && c < 0177) 608 fmt = "'%c'"; 609 else 610 fmt = "%.3o"; 611 612 (void) sprintf(buf, fmt, c&0xff); 613 return (buf); 614 } 615 616 void 617 show_termio(private_t *pri, long offset) 618 { 619 struct termio termio; 620 char cbuf[8]; 621 int i; 622 623 if (Pread(Proc, &termio, sizeof (termio), offset) == sizeof (termio)) { 624 (void) printf( 625 "%s\tiflag=0%.6o oflag=0%.6o cflag=0%.6o lflag=0%.6o line=%d\n", 626 pri->pname, 627 termio.c_iflag, 628 termio.c_oflag, 629 termio.c_cflag, 630 termio.c_lflag, 631 termio.c_line); 632 (void) printf("%s\t cc: ", pri->pname); 633 for (i = 0; i < NCC; i++) 634 (void) printf(" %s", 635 show_char(cbuf, (int)termio.c_cc[i])); 636 (void) fputc('\n', stdout); 637 } 638 } 639 640 void 641 show_termios(private_t *pri, long offset) 642 { 643 struct termios termios; 644 char cbuf[8]; 645 int i; 646 647 if (Pread(Proc, &termios, sizeof (termios), offset) 648 == sizeof (termios)) { 649 (void) printf( 650 "%s\tiflag=0%.6o oflag=0%.6o cflag=0%.6o lflag=0%.6o\n", 651 pri->pname, 652 termios.c_iflag, 653 termios.c_oflag, 654 termios.c_cflag, 655 termios.c_lflag); 656 (void) printf("%s\t cc: ", pri->pname); 657 for (i = 0; i < NCCS; i++) { 658 if (i == NCC) /* show new chars on new line */ 659 (void) printf("\n%s\t\t", pri->pname); 660 (void) printf(" %s", 661 show_char(cbuf, (int)termios.c_cc[i])); 662 } 663 (void) fputc('\n', stdout); 664 } 665 } 666 667 void 668 show_termiox(private_t *pri, long offset) 669 { 670 struct termiox termiox; 671 int i; 672 673 if (Pread(Proc, &termiox, sizeof (termiox), offset) 674 == sizeof (termiox)) { 675 (void) printf("%s\thflag=0%.3o cflag=0%.3o rflag=0%.3o", 676 pri->pname, 677 termiox.x_hflag, 678 termiox.x_cflag, 679 termiox.x_rflag[0]); 680 for (i = 1; i < NFF; i++) 681 (void) printf(",0%.3o", termiox.x_rflag[i]); 682 (void) printf(" sflag=0%.3o\n", 683 termiox.x_sflag); 684 } 685 } 686 687 void 688 show_sgttyb(private_t *pri, long offset) 689 { 690 struct sgttyb sgttyb; 691 692 if (Pread(Proc, &sgttyb, sizeof (sgttyb), offset) == sizeof (sgttyb)) { 693 char erase[8]; 694 char kill[8]; 695 696 (void) printf( 697 "%s\tispeed=%-2d ospeed=%-2d erase=%s kill=%s flags=0x%.8x\n", 698 pri->pname, 699 sgttyb.sg_ispeed&0xff, 700 sgttyb.sg_ospeed&0xff, 701 show_char(erase, sgttyb.sg_erase), 702 show_char(kill, sgttyb.sg_kill), 703 sgttyb.sg_flags); 704 } 705 } 706 707 void 708 show_ltchars(private_t *pri, long offset) 709 { 710 struct ltchars ltchars; 711 char *p; 712 char cbuf[8]; 713 int i; 714 715 if (Pread(Proc, <chars, sizeof (ltchars), offset) 716 == sizeof (ltchars)) { 717 (void) printf("%s\t cc: ", pri->pname); 718 for (p = (char *)<chars, i = 0; i < sizeof (ltchars); i++) 719 (void) printf(" %s", show_char(cbuf, (int)*p++)); 720 (void) fputc('\n', stdout); 721 } 722 } 723 724 void 725 show_tchars(private_t *pri, long offset) 726 { 727 struct tchars tchars; 728 char *p; 729 char cbuf[8]; 730 int i; 731 732 if (Pread(Proc, &tchars, sizeof (tchars), offset) == sizeof (tchars)) { 733 (void) printf("%s\t cc: ", pri->pname); 734 for (p = (char *)&tchars, i = 0; i < sizeof (tchars); i++) 735 (void) printf(" %s", show_char(cbuf, (int)*p++)); 736 (void) fputc('\n', stdout); 737 } 738 } 739 740 void 741 show_termcb(private_t *pri, long offset) 742 { 743 struct termcb termcb; 744 745 if (Pread(Proc, &termcb, sizeof (termcb), offset) == sizeof (termcb)) { 746 (void) printf( 747 "%s\tflgs=0%.2o termt=%d crow=%d ccol=%d vrow=%d lrow=%d\n", 748 pri->pname, 749 termcb.st_flgs&0xff, 750 termcb.st_termt&0xff, 751 termcb.st_crow&0xff, 752 termcb.st_ccol&0xff, 753 termcb.st_vrow&0xff, 754 termcb.st_lrow&0xff); 755 } 756 } 757 758 /* integer value pointed to by ioctl() arg */ 759 void 760 show_strint(private_t *pri, int code, long offset) 761 { 762 int val; 763 764 if (Pread(Proc, &val, sizeof (val), offset) == sizeof (val)) { 765 const char *s = NULL; 766 767 switch (code) { /* interpret these symbolically */ 768 case I_GRDOPT: 769 s = strrdopt(val); 770 break; 771 case I_GETSIG: 772 s = strevents(pri, val); 773 break; 774 case TIOCFLUSH: 775 s = tiocflush(pri, val); 776 break; 777 } 778 779 if (s == NULL) 780 (void) printf("%s\t0x%.8lX: %d\n", 781 pri->pname, offset, val); 782 else 783 (void) printf("%s\t0x%.8lX: %s\n", 784 pri->pname, offset, s); 785 } 786 } 787 788 void 789 show_strioctl(private_t *pri, long offset) 790 { 791 struct strioctl strioctl; 792 793 if (Pread(Proc, &strioctl, sizeof (strioctl), offset) == 794 sizeof (strioctl)) { 795 (void) printf( 796 "%s\tcmd=%s timout=%d len=%d dp=0x%.8lX\n", 797 pri->pname, 798 ioctlname(pri, strioctl.ic_cmd), 799 strioctl.ic_timout, 800 strioctl.ic_len, 801 (long)strioctl.ic_dp); 802 803 if (pri->recur++ == 0) /* avoid indefinite recursion */ 804 show_ioctl(pri, strioctl.ic_cmd, 805 (long)strioctl.ic_dp); 806 --pri->recur; 807 } 808 } 809 810 #ifdef _LP64 811 void 812 show_strioctl32(private_t *pri, long offset) 813 { 814 struct strioctl32 strioctl; 815 816 if (Pread(Proc, &strioctl, sizeof (strioctl), offset) == 817 sizeof (strioctl)) { 818 (void) printf( 819 "%s\tcmd=%s timout=%d len=%d dp=0x%.8lX\n", 820 pri->pname, 821 ioctlname(pri, strioctl.ic_cmd), 822 strioctl.ic_timout, 823 strioctl.ic_len, 824 (long)strioctl.ic_dp); 825 826 if (pri->recur++ == 0) /* avoid indefinite recursion */ 827 show_ioctl(pri, strioctl.ic_cmd, 828 (long)strioctl.ic_dp); 829 --pri->recur; 830 } 831 } 832 #endif /* _LP64 */ 833 834 void 835 print_strbuf(private_t *pri, struct strbuf *sp, const char *name, int dump) 836 { 837 (void) printf( 838 "%s\t%s: maxlen=%-4d len=%-4d buf=0x%.8lX", 839 pri->pname, 840 name, 841 sp->maxlen, 842 sp->len, 843 (long)sp->buf); 844 /* 845 * Should we show the buffer contents? 846 * Keyed to the '-r fds' and '-w fds' options? 847 */ 848 if (sp->buf == NULL || sp->len <= 0) 849 (void) fputc('\n', stdout); 850 else { 851 int nb = (sp->len > 8)? 8 : sp->len; 852 char buffer[8]; 853 char obuf[40]; 854 855 if (Pread(Proc, buffer, (size_t)nb, (long)sp->buf) == nb) { 856 (void) strcpy(obuf, ": \""); 857 showbytes(buffer, nb, obuf+3); 858 (void) strcat(obuf, 859 (nb == sp->len)? 860 (const char *)"\"" : (const char *)"\".."); 861 (void) fputs(obuf, stdout); 862 } 863 (void) fputc('\n', stdout); 864 if (dump && sp->len > 8) 865 showbuffer(pri, (long)sp->buf, (long)sp->len); 866 } 867 } 868 869 #ifdef _LP64 870 void 871 print_strbuf32(private_t *pri, struct strbuf32 *sp, const char *name, int dump) 872 { 873 (void) printf( 874 "%s\t%s: maxlen=%-4d len=%-4d buf=0x%.8lX", 875 pri->pname, 876 name, 877 sp->maxlen, 878 sp->len, 879 (long)sp->buf); 880 /* 881 * Should we show the buffer contents? 882 * Keyed to the '-r fds' and '-w fds' options? 883 */ 884 if (sp->buf == NULL || sp->len <= 0) 885 (void) fputc('\n', stdout); 886 else { 887 int nb = (sp->len > 8)? 8 : sp->len; 888 char buffer[8]; 889 char obuf[40]; 890 891 if (Pread(Proc, buffer, (size_t)nb, (long)sp->buf) == nb) { 892 (void) strcpy(obuf, ": \""); 893 showbytes(buffer, nb, obuf+3); 894 (void) strcat(obuf, 895 (nb == sp->len)? 896 (const char *)"\"" : (const char *)"\".."); 897 (void) fputs(obuf, stdout); 898 } 899 (void) fputc('\n', stdout); 900 if (dump && sp->len > 8) 901 showbuffer(pri, (long)sp->buf, (long)sp->len); 902 } 903 } 904 #endif /* _LP64 */ 905 906 /* strpeek and strfdinsert flags word */ 907 const char * 908 strflags(private_t *pri, int flags) 909 { 910 const char *s; 911 912 switch (flags) { 913 case 0: 914 s = "0"; 915 break; 916 case RS_HIPRI: 917 s = "RS_HIPRI"; 918 break; 919 default: 920 (void) sprintf(pri->code_buf, "0x%.4X", flags); 921 s = pri->code_buf; 922 } 923 924 return (s); 925 } 926 927 void 928 show_strpeek(private_t *pri, long offset) 929 { 930 struct strpeek strpeek; 931 932 if (Pread(Proc, &strpeek, sizeof (strpeek), offset) 933 == sizeof (strpeek)) { 934 935 print_strbuf(pri, &strpeek.ctlbuf, "ctl", FALSE); 936 print_strbuf(pri, &strpeek.databuf, "dat", FALSE); 937 938 (void) printf("%s\tflags=%s\n", 939 pri->pname, 940 strflags(pri, strpeek.flags)); 941 } 942 } 943 944 #ifdef _LP64 945 void 946 show_strpeek32(private_t *pri, long offset) 947 { 948 struct strpeek32 strpeek; 949 950 if (Pread(Proc, &strpeek, sizeof (strpeek), offset) 951 == sizeof (strpeek)) { 952 953 print_strbuf32(pri, &strpeek.ctlbuf, "ctl", FALSE); 954 print_strbuf32(pri, &strpeek.databuf, "dat", FALSE); 955 956 (void) printf("%s\tflags=%s\n", 957 pri->pname, 958 strflags(pri, strpeek.flags)); 959 } 960 } 961 #endif /* _LP64 */ 962 963 void 964 show_strfdinsert(private_t *pri, long offset) 965 { 966 struct strfdinsert strfdinsert; 967 968 if (Pread(Proc, &strfdinsert, sizeof (strfdinsert), offset) == 969 sizeof (strfdinsert)) { 970 971 print_strbuf(pri, &strfdinsert.ctlbuf, "ctl", FALSE); 972 print_strbuf(pri, &strfdinsert.databuf, "dat", FALSE); 973 974 (void) printf("%s\tflags=%s fildes=%d offset=%d\n", 975 pri->pname, 976 strflags(pri, strfdinsert.flags), 977 strfdinsert.fildes, 978 strfdinsert.offset); 979 } 980 } 981 982 #ifdef _LP64 983 void 984 show_strfdinsert32(private_t *pri, long offset) 985 { 986 struct strfdinsert32 strfdinsert; 987 988 if (Pread(Proc, &strfdinsert, sizeof (strfdinsert), offset) == 989 sizeof (strfdinsert)) { 990 991 print_strbuf32(pri, &strfdinsert.ctlbuf, "ctl", FALSE); 992 print_strbuf32(pri, &strfdinsert.databuf, "dat", FALSE); 993 994 (void) printf("%s\tflags=%s fildes=%d offset=%d\n", 995 pri->pname, 996 strflags(pri, strfdinsert.flags), 997 strfdinsert.fildes, 998 strfdinsert.offset); 999 } 1000 } 1001 #endif /* _LP64 */ 1002 1003 void 1004 show_strrecvfd(private_t *pri, long offset) 1005 { 1006 struct strrecvfd strrecvfd; 1007 1008 if (Pread(Proc, &strrecvfd, sizeof (strrecvfd), offset) == 1009 sizeof (strrecvfd)) { 1010 (void) printf( 1011 "%s\tfd=%-5d uid=%-5d gid=%d\n", 1012 pri->pname, 1013 strrecvfd.fd, 1014 (int)strrecvfd.uid, 1015 (int)strrecvfd.gid); 1016 } 1017 } 1018 1019 void 1020 show_strlist(private_t *pri, long offset) 1021 { 1022 struct str_list strlist; 1023 struct str_mlist list; 1024 int count; 1025 1026 if (Pread(Proc, &strlist, sizeof (strlist), offset) == 1027 sizeof (strlist)) { 1028 (void) printf("%s\tnmods=%d modlist=0x%.8lX\n", 1029 pri->pname, 1030 strlist.sl_nmods, 1031 (long)strlist.sl_modlist); 1032 1033 count = strlist.sl_nmods; 1034 offset = (long)strlist.sl_modlist; 1035 while (!interrupt && --count >= 0) { 1036 if (Pread(Proc, &list, sizeof (list), offset) != 1037 sizeof (list)) 1038 break; 1039 (void) printf("%s\t\t\"%.*s\"\n", 1040 pri->pname, 1041 (int)sizeof (list.l_name), 1042 list.l_name); 1043 offset += sizeof (struct str_mlist); 1044 } 1045 } 1046 } 1047 1048 #ifdef _LP64 1049 void 1050 show_strlist32(private_t *pri, long offset) 1051 { 1052 struct str_list32 strlist; 1053 struct str_mlist list; 1054 int count; 1055 1056 if (Pread(Proc, &strlist, sizeof (strlist), offset) == 1057 sizeof (strlist)) { 1058 (void) printf("%s\tnmods=%d modlist=0x%.8lX\n", 1059 pri->pname, 1060 strlist.sl_nmods, 1061 (long)strlist.sl_modlist); 1062 1063 count = strlist.sl_nmods; 1064 offset = (long)strlist.sl_modlist; 1065 while (!interrupt && --count >= 0) { 1066 if (Pread(Proc, &list, sizeof (list), offset) != 1067 sizeof (list)) 1068 break; 1069 (void) printf("%s\t\t\"%.*s\"\n", 1070 pri->pname, 1071 (int)sizeof (list.l_name), 1072 list.l_name); 1073 offset += sizeof (struct str_mlist); 1074 } 1075 } 1076 } 1077 #endif /* _LP64 */ 1078 1079 void 1080 show_jwinsize(private_t *pri, long offset) 1081 { 1082 struct jwinsize jwinsize; 1083 1084 if (Pread(Proc, &jwinsize, sizeof (jwinsize), offset) == 1085 sizeof (jwinsize)) { 1086 (void) printf( 1087 "%s\tbytesx=%-3u bytesy=%-3u bitsx=%-3u bitsy=%-3u\n", 1088 pri->pname, 1089 (unsigned)jwinsize.bytesx, 1090 (unsigned)jwinsize.bytesy, 1091 (unsigned)jwinsize.bitsx, 1092 (unsigned)jwinsize.bitsy); 1093 } 1094 } 1095 1096 void 1097 show_winsize(private_t *pri, long offset) 1098 { 1099 struct winsize winsize; 1100 1101 if (Pread(Proc, &winsize, sizeof (winsize), offset) 1102 == sizeof (winsize)) { 1103 (void) printf( 1104 "%s\trow=%-3d col=%-3d xpixel=%-3d ypixel=%-3d\n", 1105 pri->pname, 1106 winsize.ws_row, 1107 winsize.ws_col, 1108 winsize.ws_xpixel, 1109 winsize.ws_ypixel); 1110 } 1111 } 1112 1113 struct audio_stuff { 1114 uint_t bit; 1115 const char *str; 1116 }; 1117 1118 const struct audio_stuff audio_output_ports[] = { 1119 { AUDIO_SPEAKER, "SPEAKER" }, 1120 { AUDIO_HEADPHONE, "HEADPHONE" }, 1121 { AUDIO_LINE_OUT, "LINE_OUT" }, 1122 { AUDIO_SPDIF_OUT, "SPDIF_OUT" }, 1123 { AUDIO_AUX1_OUT, "AUX1_OUT" }, 1124 { AUDIO_AUX2_OUT, "AUX2_OUT" }, 1125 { 0, NULL } 1126 }; 1127 1128 const struct audio_stuff audio_input_ports[] = { 1129 { AUDIO_MICROPHONE, "MICROPHONE" }, 1130 { AUDIO_LINE_IN, "LINE_IN" }, 1131 { AUDIO_CD, "CD" }, 1132 { AUDIO_SPDIF_IN, "SPDIF_IN" }, 1133 { AUDIO_AUX1_IN, "AUX1_IN" }, 1134 { AUDIO_AUX2_IN, "AUX2_IN" }, 1135 { AUDIO_CODEC_LOOPB_IN, "CODEC_LOOPB_IN" }, 1136 { AUDIO_SUNVTS, "SUNVTS" }, 1137 { 0, NULL } 1138 }; 1139 1140 static const struct audio_stuff audio_hw_features[] = { 1141 { AUDIO_HWFEATURE_DUPLEX, "DUPLEX" }, 1142 { AUDIO_HWFEATURE_MSCODEC, "MSCODEC" }, 1143 { AUDIO_HWFEATURE_IN2OUT, "IN2OUT" }, 1144 { AUDIO_HWFEATURE_PLAY, "PLAY" }, 1145 { AUDIO_HWFEATURE_RECORD, "RECORD" }, 1146 { 0, NULL } 1147 }; 1148 1149 static const struct audio_stuff audio_sw_features[] = { 1150 { AUDIO_SWFEATURE_MIXER, "MIXER" }, 1151 { 0, NULL } 1152 }; 1153 1154 void 1155 show_audio_features(const private_t *pri, 1156 const struct audio_stuff *audio_porttab, uint_t features, 1157 const char *name) 1158 { 1159 (void) printf("%s\t%s=", pri->pname, name); 1160 if (features == 0) { 1161 (void) printf("0\n"); 1162 return; 1163 } 1164 1165 for (; audio_porttab->bit != 0; ++audio_porttab) { 1166 if (features & audio_porttab->bit) { 1167 (void) printf(audio_porttab->str); 1168 features &= ~audio_porttab->bit; 1169 if (features) 1170 (void) putchar('|'); 1171 } 1172 } 1173 if (features) 1174 (void) printf("0x%x", features); 1175 (void) putchar('\n'); 1176 } 1177 1178 void 1179 show_audio_ports(private_t *pri, const char *mode, 1180 const char *field, uint_t ports) 1181 { 1182 const struct audio_stuff *audio_porttab; 1183 1184 (void) printf("%s\t%s\t%s=", pri->pname, mode, field); 1185 if (ports == 0) { 1186 (void) printf("0\n"); 1187 return; 1188 } 1189 if (*mode == 'p') 1190 audio_porttab = audio_output_ports; 1191 else 1192 audio_porttab = audio_input_ports; 1193 for (; audio_porttab->bit != 0; ++audio_porttab) { 1194 if (ports & audio_porttab->bit) { 1195 (void) printf(audio_porttab->str); 1196 ports &= ~audio_porttab->bit; 1197 if (ports) 1198 (void) putchar('|'); 1199 } 1200 } 1201 if (ports) 1202 (void) printf("0x%x", ports); 1203 (void) putchar('\n'); 1204 } 1205 1206 void 1207 show_audio_prinfo(private_t *pri, const char *mode, struct audio_prinfo *au_pr) 1208 { 1209 const char *s; 1210 1211 /* 1212 * The following values describe the audio data encoding. 1213 */ 1214 1215 (void) printf("%s\t%s\tsample_rate=%u channels=%u precision=%u\n", 1216 pri->pname, mode, 1217 au_pr->sample_rate, 1218 au_pr->channels, 1219 au_pr->precision); 1220 1221 s = NULL; 1222 switch (au_pr->encoding) { 1223 case AUDIO_ENCODING_NONE: s = "NONE"; break; 1224 case AUDIO_ENCODING_ULAW: s = "ULAW"; break; 1225 case AUDIO_ENCODING_ALAW: s = "ALAW"; break; 1226 case AUDIO_ENCODING_LINEAR: s = "LINEAR"; break; 1227 case AUDIO_ENCODING_DVI: s = "DVI"; break; 1228 case AUDIO_ENCODING_LINEAR8: s = "LINEAR8"; break; 1229 } 1230 if (s) 1231 (void) printf("%s\t%s\tencoding=%s\n", pri->pname, mode, s); 1232 else { 1233 (void) printf("%s\t%s\tencoding=%u\n", 1234 pri->pname, mode, au_pr->encoding); 1235 } 1236 1237 /* 1238 * The following values control audio device configuration 1239 */ 1240 1241 (void) printf( 1242 "%s\t%s\tgain=%u buffer_size=%u\n", 1243 pri->pname, mode, 1244 au_pr->gain, 1245 au_pr->buffer_size); 1246 show_audio_ports(pri, mode, "port", au_pr->port); 1247 show_audio_ports(pri, mode, "avail_ports", au_pr->avail_ports); 1248 show_audio_ports(pri, mode, "mod_ports", au_pr->mod_ports); 1249 1250 /* 1251 * The following values describe driver state 1252 */ 1253 1254 (void) printf("%s\t%s\tsamples=%u eof=%u pause=%u error=%u\n", 1255 pri->pname, mode, 1256 au_pr->samples, 1257 au_pr->eof, 1258 au_pr->pause, 1259 au_pr->error); 1260 (void) printf("%s\t%s\twaiting=%u balance=%u minordev=%u\n", 1261 pri->pname, mode, 1262 au_pr->waiting, 1263 au_pr->balance, 1264 au_pr->minordev); 1265 1266 /* 1267 * The following values are read-only state flags 1268 */ 1269 (void) printf("%s\t%s\topen=%u active=%u\n", 1270 pri->pname, mode, 1271 au_pr->open, 1272 au_pr->active); 1273 } 1274 1275 void 1276 show_audio_info(private_t *pri, long offset) 1277 { 1278 struct audio_info au; 1279 1280 if (Pread(Proc, &au, sizeof (au), offset) == sizeof (au)) { 1281 show_audio_prinfo(pri, "play", &au.play); 1282 show_audio_prinfo(pri, "record", &au.record); 1283 (void) printf("%s\tmonitor_gain=%u output_muted=%u\n", 1284 pri->pname, au.monitor_gain, au.output_muted); 1285 show_audio_features(pri, audio_hw_features, au.hw_features, 1286 "hw_features"); 1287 show_audio_features(pri, audio_sw_features, au.sw_features, 1288 "sw_features"); 1289 show_audio_features(pri, audio_sw_features, 1290 au.sw_features_enabled, "sw_features_enabled"); 1291 } 1292 } 1293 1294 void 1295 show_ioctl(private_t *pri, int code, long offset) 1296 { 1297 int lp64 = (data_model == PR_MODEL_LP64); 1298 int err = pri->Errno; /* don't display output parameters */ 1299 /* for a failed system call */ 1300 #ifndef _LP64 1301 if (lp64) 1302 return; 1303 #endif 1304 if (offset == NULL) 1305 return; 1306 1307 switch (code) { 1308 case TCGETA: 1309 if (err) 1310 break; 1311 /*FALLTHROUGH*/ 1312 case TCSETA: 1313 case TCSETAW: 1314 case TCSETAF: 1315 show_termio(pri, offset); 1316 break; 1317 case TCGETS: 1318 if (err) 1319 break; 1320 /*FALLTHROUGH*/ 1321 case TCSETS: 1322 case TCSETSW: 1323 case TCSETSF: 1324 show_termios(pri, offset); 1325 break; 1326 case TCGETX: 1327 if (err) 1328 break; 1329 /*FALLTHROUGH*/ 1330 case TCSETX: 1331 case TCSETXW: 1332 case TCSETXF: 1333 show_termiox(pri, offset); 1334 break; 1335 case TIOCGETP: 1336 if (err) 1337 break; 1338 /*FALLTHROUGH*/ 1339 case TIOCSETN: 1340 case TIOCSETP: 1341 show_sgttyb(pri, offset); 1342 break; 1343 case TIOCGLTC: 1344 if (err) 1345 break; 1346 /*FALLTHROUGH*/ 1347 case TIOCSLTC: 1348 show_ltchars(pri, offset); 1349 break; 1350 case TIOCGETC: 1351 if (err) 1352 break; 1353 /*FALLTHROUGH*/ 1354 case TIOCSETC: 1355 show_tchars(pri, offset); 1356 break; 1357 case LDGETT: 1358 if (err) 1359 break; 1360 /*FALLTHROUGH*/ 1361 case LDSETT: 1362 show_termcb(pri, offset); 1363 break; 1364 /* streams ioctl()s */ 1365 #if 0 1366 /* these are displayed as strings in the arg list */ 1367 /* by prt_ioa(). don't display them again here */ 1368 case I_PUSH: 1369 case I_LOOK: 1370 case I_FIND: 1371 /* these are displayed as decimal in the arg list */ 1372 /* by prt_ioa(). don't display them again here */ 1373 case I_LINK: 1374 case I_UNLINK: 1375 case I_SENDFD: 1376 /* these are displayed symbolically in the arg list */ 1377 /* by prt_ioa(). don't display them again here */ 1378 case I_SRDOPT: 1379 case I_SETSIG: 1380 case I_FLUSH: 1381 break; 1382 /* this one just ignores the argument */ 1383 case I_POP: 1384 break; 1385 #endif 1386 /* these return something in an int pointed to by arg */ 1387 case I_NREAD: 1388 case I_GRDOPT: 1389 case I_GETSIG: 1390 case TIOCGSID: 1391 case TIOCGPGRP: 1392 case TIOCLGET: 1393 case FIONREAD: 1394 case FIORDCHK: 1395 if (err) 1396 break; 1397 /*FALLTHROUGH*/ 1398 /* these pass something in an int pointed to by arg */ 1399 case TIOCSPGRP: 1400 case TIOCFLUSH: 1401 case TIOCLBIS: 1402 case TIOCLBIC: 1403 case TIOCLSET: 1404 show_strint(pri, code, offset); 1405 break; 1406 /* these all point to structures */ 1407 case I_STR: 1408 #ifdef _LP64 1409 if (lp64) 1410 show_strioctl(pri, offset); 1411 else 1412 show_strioctl32(pri, offset); 1413 #else 1414 show_strioctl(pri, offset); 1415 #endif 1416 break; 1417 case I_PEEK: 1418 #ifdef _LP64 1419 if (lp64) 1420 show_strpeek(pri, offset); 1421 else 1422 show_strpeek32(pri, offset); 1423 #else 1424 show_strpeek(pri, offset); 1425 #endif 1426 break; 1427 case I_FDINSERT: 1428 #ifdef _LP64 1429 if (lp64) 1430 show_strfdinsert(pri, offset); 1431 else 1432 show_strfdinsert32(pri, offset); 1433 #else 1434 show_strfdinsert(pri, offset); 1435 #endif 1436 break; 1437 case I_RECVFD: 1438 if (err) 1439 break; 1440 show_strrecvfd(pri, offset); 1441 break; 1442 case I_LIST: 1443 if (err) 1444 break; 1445 #ifdef _LP64 1446 if (lp64) 1447 show_strlist(pri, offset); 1448 else 1449 show_strlist32(pri, offset); 1450 #else 1451 show_strlist(pri, offset); 1452 #endif 1453 break; 1454 case JWINSIZE: 1455 if (err) 1456 break; 1457 show_jwinsize(pri, offset); 1458 break; 1459 case TIOCGWINSZ: 1460 if (err) 1461 break; 1462 /*FALLTHROUGH*/ 1463 case TIOCSWINSZ: 1464 show_winsize(pri, offset); 1465 break; 1466 case AUDIO_GETINFO: 1467 case (int)AUDIO_SETINFO: 1468 show_audio_info(pri, offset); 1469 break; 1470 1471 default: 1472 if (code & IOC_INOUT) { 1473 const char *str = ioctldatastruct(code); 1474 1475 (void) printf("\t\t%s", 1476 (code & IOC_INOUT) == IOC_INOUT ? "write/read" : 1477 code & IOC_IN ? "write" : "read"); 1478 if (str != NULL) { 1479 (void) printf(" (struct %s)\n", str); 1480 } else { 1481 (void) printf(" %d bytes\n", 1482 (code >> 16) & IOCPARM_MASK); 1483 } 1484 } 1485 } 1486 } 1487 1488 void 1489 show_statvfs(private_t *pri) 1490 { 1491 long offset; 1492 struct statvfs statvfs; 1493 char *cp; 1494 1495 if (pri->sys_nargs > 1 && (offset = pri->sys_args[1]) != NULL && 1496 Pread(Proc, &statvfs, sizeof (statvfs), offset) 1497 == sizeof (statvfs)) { 1498 (void) printf( 1499 "%s\tbsize=%-10lu frsize=%-9lu blocks=%-8llu bfree=%-9llu\n", 1500 pri->pname, 1501 statvfs.f_bsize, 1502 statvfs.f_frsize, 1503 (u_longlong_t)statvfs.f_blocks, 1504 (u_longlong_t)statvfs.f_bfree); 1505 (void) printf( 1506 "%s\tbavail=%-9llu files=%-10llu ffree=%-9llu favail=%-9llu\n", 1507 pri->pname, 1508 (u_longlong_t)statvfs.f_bavail, 1509 (u_longlong_t)statvfs.f_files, 1510 (u_longlong_t)statvfs.f_ffree, 1511 (u_longlong_t)statvfs.f_favail); 1512 (void) printf( 1513 "%s\tfsid=0x%-9.4lX basetype=%-7.16s namemax=%ld\n", 1514 pri->pname, 1515 statvfs.f_fsid, 1516 statvfs.f_basetype, 1517 (long)statvfs.f_namemax); 1518 (void) printf( 1519 "%s\tflag=%s\n", 1520 pri->pname, 1521 svfsflags(pri, (ulong_t)statvfs.f_flag)); 1522 cp = statvfs.f_fstr + strlen(statvfs.f_fstr); 1523 if (cp < statvfs.f_fstr + sizeof (statvfs.f_fstr) - 1 && 1524 *(cp+1) != '\0') 1525 *cp = ' '; 1526 (void) printf("%s\tfstr=\"%.*s\"\n", 1527 pri->pname, 1528 (int)sizeof (statvfs.f_fstr), 1529 statvfs.f_fstr); 1530 } 1531 } 1532 1533 #ifdef _LP64 1534 void 1535 show_statvfs32(private_t *pri) 1536 { 1537 long offset; 1538 struct statvfs32 statvfs; 1539 char *cp; 1540 1541 if (pri->sys_nargs > 1 && (offset = pri->sys_args[1]) != NULL && 1542 Pread(Proc, &statvfs, sizeof (statvfs), offset) 1543 == sizeof (statvfs)) { 1544 (void) printf( 1545 "%s\tbsize=%-10u frsize=%-9u blocks=%-8u bfree=%-9u\n", 1546 pri->pname, 1547 statvfs.f_bsize, 1548 statvfs.f_frsize, 1549 statvfs.f_blocks, 1550 statvfs.f_bfree); 1551 (void) printf( 1552 "%s\tbavail=%-9u files=%-10u ffree=%-9u favail=%-9u\n", 1553 pri->pname, 1554 statvfs.f_bavail, 1555 statvfs.f_files, 1556 statvfs.f_ffree, 1557 statvfs.f_favail); 1558 (void) printf( 1559 "%s\tfsid=0x%-9.4X basetype=%-7.16s namemax=%d\n", 1560 pri->pname, 1561 statvfs.f_fsid, 1562 statvfs.f_basetype, 1563 (int)statvfs.f_namemax); 1564 (void) printf( 1565 "%s\tflag=%s\n", 1566 pri->pname, 1567 svfsflags(pri, (ulong_t)statvfs.f_flag)); 1568 cp = statvfs.f_fstr + strlen(statvfs.f_fstr); 1569 if (cp < statvfs.f_fstr + sizeof (statvfs.f_fstr) - 1 && 1570 *(cp+1) != '\0') 1571 *cp = ' '; 1572 (void) printf("%s\tfstr=\"%.*s\"\n", 1573 pri->pname, 1574 (int)sizeof (statvfs.f_fstr), 1575 statvfs.f_fstr); 1576 } 1577 } 1578 #endif /* _LP64 */ 1579 1580 void 1581 show_statvfs64(private_t *pri) 1582 { 1583 long offset; 1584 struct statvfs64_32 statvfs; 1585 char *cp; 1586 1587 if (pri->sys_nargs > 1 && (offset = pri->sys_args[1]) != NULL && 1588 Pread(Proc, &statvfs, sizeof (statvfs), offset) 1589 == sizeof (statvfs)) { 1590 (void) printf( 1591 "%s\tbsize=%-10u frsize=%-9u blocks=%-8llu bfree=%-9llu\n", 1592 pri->pname, 1593 statvfs.f_bsize, 1594 statvfs.f_frsize, 1595 (u_longlong_t)statvfs.f_blocks, 1596 (u_longlong_t)statvfs.f_bfree); 1597 (void) printf( 1598 "%s\tbavail=%-9llu files=%-10llu ffree=%-9llu favail=%-9llu\n", 1599 pri->pname, 1600 (u_longlong_t)statvfs.f_bavail, 1601 (u_longlong_t)statvfs.f_files, 1602 (u_longlong_t)statvfs.f_ffree, 1603 (u_longlong_t)statvfs.f_favail); 1604 (void) printf( 1605 "%s\tfsid=0x%-9.4X basetype=%-7.16s namemax=%d\n", 1606 pri->pname, 1607 statvfs.f_fsid, 1608 statvfs.f_basetype, 1609 (int)statvfs.f_namemax); 1610 (void) printf( 1611 "%s\tflag=%s\n", 1612 pri->pname, 1613 svfsflags(pri, (ulong_t)statvfs.f_flag)); 1614 cp = statvfs.f_fstr + strlen(statvfs.f_fstr); 1615 if (cp < statvfs.f_fstr + sizeof (statvfs.f_fstr) - 1 && 1616 *(cp+1) != '\0') 1617 *cp = ' '; 1618 (void) printf("%s\tfstr=\"%.*s\"\n", 1619 pri->pname, 1620 (int)sizeof (statvfs.f_fstr), 1621 statvfs.f_fstr); 1622 } 1623 } 1624 1625 void 1626 show_statfs(private_t *pri) 1627 { 1628 long offset; 1629 struct statfs statfs; 1630 1631 if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != NULL && 1632 Pread(Proc, &statfs, sizeof (statfs), offset) == sizeof (statfs)) { 1633 (void) printf( 1634 "%s\tfty=%d bsz=%ld fsz=%ld blk=%ld bfr=%ld fil=%lu ffr=%lu\n", 1635 pri->pname, 1636 statfs.f_fstyp, 1637 statfs.f_bsize, 1638 statfs.f_frsize, 1639 statfs.f_blocks, 1640 statfs.f_bfree, 1641 statfs.f_files, 1642 statfs.f_ffree); 1643 (void) printf("%s\t fname=%.6s fpack=%.6s\n", 1644 pri->pname, 1645 statfs.f_fname, 1646 statfs.f_fpack); 1647 } 1648 } 1649 1650 #ifdef _LP64 1651 void 1652 show_statfs32(private_t *pri) 1653 { 1654 long offset; 1655 struct statfs32 statfs; 1656 1657 if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != NULL && 1658 Pread(Proc, &statfs, sizeof (statfs), offset) == sizeof (statfs)) { 1659 (void) printf( 1660 "%s\tfty=%d bsz=%d fsz=%d blk=%d bfr=%d fil=%u ffr=%u\n", 1661 pri->pname, 1662 statfs.f_fstyp, 1663 statfs.f_bsize, 1664 statfs.f_frsize, 1665 statfs.f_blocks, 1666 statfs.f_bfree, 1667 statfs.f_files, 1668 statfs.f_ffree); 1669 (void) printf("%s\t fname=%.6s fpack=%.6s\n", 1670 pri->pname, 1671 statfs.f_fname, 1672 statfs.f_fpack); 1673 } 1674 } 1675 #endif /* _LP64 */ 1676 1677 void 1678 show_flock32(private_t *pri, long offset) 1679 { 1680 struct flock32 flock; 1681 1682 if (Pread(Proc, &flock, sizeof (flock), offset) == sizeof (flock)) { 1683 const char *str = NULL; 1684 1685 (void) printf("%s\ttyp=", pri->pname); 1686 1687 switch (flock.l_type) { 1688 case F_RDLCK: 1689 str = "F_RDLCK"; 1690 break; 1691 case F_WRLCK: 1692 str = "F_WRLCK"; 1693 break; 1694 case F_UNLCK: 1695 str = "F_UNLCK"; 1696 break; 1697 } 1698 if (str != NULL) 1699 (void) printf("%s", str); 1700 else 1701 (void) printf("%-7d", flock.l_type); 1702 1703 str = whencearg(flock.l_whence); 1704 if (str != NULL) 1705 (void) printf(" whence=%s", str); 1706 else 1707 (void) printf(" whence=%-8u", flock.l_whence); 1708 1709 (void) printf( 1710 " start=%-5d len=%-5d sys=%-2u pid=%d\n", 1711 flock.l_start, 1712 flock.l_len, 1713 flock.l_sysid, 1714 flock.l_pid); 1715 } 1716 } 1717 1718 void 1719 show_flock64(private_t *pri, long offset) 1720 { 1721 struct flock64 flock; 1722 1723 if (Pread(Proc, &flock, sizeof (flock), offset) == sizeof (flock)) { 1724 const char *str = NULL; 1725 1726 (void) printf("%s\ttyp=", pri->pname); 1727 1728 switch (flock.l_type) { 1729 case F_RDLCK: 1730 str = "F_RDLCK"; 1731 break; 1732 case F_WRLCK: 1733 str = "F_WRLCK"; 1734 break; 1735 case F_UNLCK: 1736 str = "F_UNLCK"; 1737 break; 1738 } 1739 if (str != NULL) 1740 (void) printf("%s", str); 1741 else 1742 (void) printf("%-7d", flock.l_type); 1743 1744 str = whencearg(flock.l_whence); 1745 if (str != NULL) 1746 (void) printf(" whence=%s", str); 1747 else 1748 (void) printf(" whence=%-8u", flock.l_whence); 1749 1750 (void) printf( 1751 " start=%-5lld len=%-5lld sys=%-2u pid=%d\n", 1752 (long long)flock.l_start, 1753 (long long)flock.l_len, 1754 flock.l_sysid, 1755 (int)flock.l_pid); 1756 } 1757 } 1758 1759 void 1760 show_share(private_t *pri, long offset) 1761 { 1762 struct fshare fshare; 1763 1764 if (Pread(Proc, &fshare, sizeof (fshare), offset) == sizeof (fshare)) { 1765 const char *str = NULL; 1766 int manddny = 0; 1767 1768 (void) printf("%s\taccess=", pri->pname); 1769 1770 switch (fshare.f_access) { 1771 case F_RDACC: 1772 str = "F_RDACC"; 1773 break; 1774 case F_WRACC: 1775 str = "F_WRACC"; 1776 break; 1777 case F_RWACC: 1778 str = "F_RWACC"; 1779 break; 1780 } 1781 if (str != NULL) 1782 (void) printf("%s", str); 1783 else 1784 (void) printf("%-7d", fshare.f_access); 1785 1786 str = NULL; 1787 if (fshare.f_deny & F_MANDDNY) { 1788 fshare.f_deny &= ~F_MANDDNY; 1789 manddny = 1; 1790 } 1791 switch (fshare.f_deny) { 1792 case F_NODNY: 1793 str = "F_NODNY"; 1794 break; 1795 case F_RDDNY: 1796 str = "F_RDDNY"; 1797 break; 1798 case F_WRDNY: 1799 str = "F_WRDNY"; 1800 break; 1801 case F_RWDNY: 1802 str = "F_RWDNY"; 1803 break; 1804 case F_COMPAT: 1805 str = "F_COMPAT"; 1806 break; 1807 } 1808 if (str != NULL) { 1809 if (manddny) 1810 (void) printf(" deny=F_MANDDNY|%s", str); 1811 else 1812 (void) printf(" deny=%s", str); 1813 } else { 1814 (void) printf(" deny=0x%x", manddny? 1815 fshare.f_deny | F_MANDDNY : fshare.f_deny); 1816 } 1817 1818 (void) printf(" id=%x\n", fshare.f_id); 1819 } 1820 } 1821 1822 void 1823 show_ffg(private_t *pri) 1824 { 1825 (void) putchar('\t'); 1826 (void) putchar('\t'); 1827 prt_ffg(pri, 0, pri->Rval1); 1828 (void) puts(pri->sys_string); 1829 } 1830 1831 /* print values in fcntl() pointed-to structure */ 1832 void 1833 show_fcntl(private_t *pri) 1834 { 1835 long offset; 1836 1837 if (pri->sys_nargs >= 2 && pri->sys_args[1] == F_GETFL) { 1838 show_ffg(pri); 1839 return; 1840 } 1841 1842 if (pri->sys_nargs < 3 || (offset = pri->sys_args[2]) == NULL) 1843 return; 1844 1845 switch (pri->sys_args[1]) { 1846 #ifdef _LP64 1847 case F_GETLK: 1848 case F_SETLK: 1849 case F_SETLKW: 1850 case F_FREESP: 1851 case F_ALLOCSP: 1852 case F_SETLK_NBMAND: 1853 if (data_model == PR_MODEL_LP64) 1854 show_flock64(pri, offset); 1855 else 1856 show_flock32(pri, offset); 1857 break; 1858 case 33: /* F_GETLK64 */ 1859 case 34: /* F_SETLK64 */ 1860 case 35: /* F_SETLKW64 */ 1861 case 27: /* F_FREESP64 */ 1862 case 44: /* F_SETLK64_NBMAND */ 1863 show_flock64(pri, offset); 1864 break; 1865 #else /* _LP64 */ 1866 case F_GETLK: 1867 case F_SETLK: 1868 case F_SETLKW: 1869 case F_FREESP: 1870 case F_ALLOCSP: 1871 case F_SETLK_NBMAND: 1872 show_flock32(pri, offset); 1873 break; 1874 case F_GETLK64: 1875 case F_SETLK64: 1876 case F_SETLKW64: 1877 case F_FREESP64: 1878 case F_SETLK64_NBMAND: 1879 show_flock64(pri, offset); 1880 break; 1881 #endif /* _LP64 */ 1882 case F_SHARE: 1883 case F_UNSHARE: 1884 show_share(pri, offset); 1885 break; 1886 } 1887 } 1888 1889 void 1890 show_strbuf(private_t *pri, long offset, const char *name, int dump) 1891 { 1892 struct strbuf strbuf; 1893 1894 if (Pread(Proc, &strbuf, sizeof (strbuf), offset) == sizeof (strbuf)) 1895 print_strbuf(pri, &strbuf, name, dump); 1896 } 1897 1898 #ifdef _LP64 1899 void 1900 show_strbuf32(private_t *pri, long offset, const char *name, int dump) 1901 { 1902 struct strbuf32 strbuf; 1903 1904 if (Pread(Proc, &strbuf, sizeof (strbuf), offset) == sizeof (strbuf)) 1905 print_strbuf32(pri, &strbuf, name, dump); 1906 } 1907 #endif /* _LP64 */ 1908 1909 void 1910 show_gp_msg(private_t *pri, int what) 1911 { 1912 long offset; 1913 int dump = FALSE; 1914 int fdp1 = pri->sys_args[0] + 1; 1915 1916 switch (what) { 1917 case SYS_getmsg: 1918 case SYS_getpmsg: 1919 if (pri->Errno == 0 && prismember(&readfd, fdp1)) 1920 dump = TRUE; 1921 break; 1922 case SYS_putmsg: 1923 case SYS_putpmsg: 1924 if (prismember(&writefd, fdp1)) 1925 dump = TRUE; 1926 break; 1927 } 1928 1929 /* enter region of lengthy output */ 1930 if (dump) 1931 Eserialize(); 1932 1933 #ifdef _LP64 1934 if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != NULL) { 1935 if (data_model == PR_MODEL_LP64) 1936 show_strbuf(pri, offset, "ctl", dump); 1937 else 1938 show_strbuf32(pri, offset, "ctl", dump); 1939 } 1940 if (pri->sys_nargs >= 3 && (offset = pri->sys_args[2]) != NULL) { 1941 if (data_model == PR_MODEL_LP64) 1942 show_strbuf(pri, offset, "dat", dump); 1943 else 1944 show_strbuf32(pri, offset, "dat", dump); 1945 } 1946 #else /* _LP64 */ 1947 if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != NULL) 1948 show_strbuf(pri, offset, "ctl", dump); 1949 if (pri->sys_nargs >= 3 && (offset = pri->sys_args[2]) != NULL) 1950 show_strbuf(pri, offset, "dat", dump); 1951 #endif /* _LP64 */ 1952 1953 /* exit region of lengthy output */ 1954 if (dump) 1955 Xserialize(); 1956 } 1957 1958 void 1959 show_int(private_t *pri, long offset, const char *name) 1960 { 1961 int value; 1962 1963 if (offset != 0 && 1964 Pread(Proc, &value, sizeof (value), offset) == sizeof (value)) 1965 (void) printf("%s\t%s:\t%d\n", 1966 pri->pname, 1967 name, 1968 value); 1969 } 1970 1971 void 1972 show_hhex_int(private_t *pri, long offset, const char *name) 1973 { 1974 int value; 1975 1976 if (Pread(Proc, &value, sizeof (value), offset) == sizeof (value)) 1977 (void) printf("%s\t%s:\t0x%.4X\n", 1978 pri->pname, 1979 name, 1980 value); 1981 } 1982 1983 #define ALL_POLL_FLAGS (POLLIN|POLLPRI|POLLOUT| \ 1984 POLLRDNORM|POLLRDBAND|POLLWRBAND|POLLERR|POLLHUP|POLLNVAL) 1985 1986 const char * 1987 pollevent(private_t *pri, int arg) 1988 { 1989 char *str = pri->code_buf; 1990 1991 if (arg == 0) 1992 return ("0"); 1993 if (arg & ~ALL_POLL_FLAGS) { 1994 (void) sprintf(str, "0x%-5X", arg); 1995 return ((const char *)str); 1996 } 1997 1998 *str = '\0'; 1999 if (arg & POLLIN) 2000 (void) strcat(str, "|POLLIN"); 2001 if (arg & POLLPRI) 2002 (void) strcat(str, "|POLLPRI"); 2003 if (arg & POLLOUT) 2004 (void) strcat(str, "|POLLOUT"); 2005 if (arg & POLLRDNORM) 2006 (void) strcat(str, "|POLLRDNORM"); 2007 if (arg & POLLRDBAND) 2008 (void) strcat(str, "|POLLRDBAND"); 2009 if (arg & POLLWRBAND) 2010 (void) strcat(str, "|POLLWRBAND"); 2011 if (arg & POLLERR) 2012 (void) strcat(str, "|POLLERR"); 2013 if (arg & POLLHUP) 2014 (void) strcat(str, "|POLLHUP"); 2015 if (arg & POLLNVAL) 2016 (void) strcat(str, "|POLLNVAL"); 2017 2018 return ((const char *)(str+1)); 2019 } 2020 2021 static void 2022 show_one_pollfd(private_t *pri, struct pollfd *ppollfd) 2023 { 2024 /* 2025 * can't print both events and revents in same printf. 2026 * pollevent() returns a pointer to a TSD location. 2027 */ 2028 (void) printf("%s\tfd=%-2d ev=%s", 2029 pri->pname, ppollfd->fd, pollevent(pri, ppollfd->events)); 2030 (void) printf(" rev=%s\n", pollevent(pri, ppollfd->revents)); 2031 } 2032 2033 static void 2034 show_all_pollfds(private_t *pri, long offset, int nfds) 2035 { 2036 struct pollfd pollfd[2]; 2037 int skip = -1; 2038 2039 for (; nfds && !interrupt; nfds--, offset += sizeof (struct pollfd)) { 2040 if (Pread(Proc, &pollfd[0], sizeof (struct pollfd), offset) != 2041 sizeof (struct pollfd)) 2042 continue; 2043 2044 if (skip >= 0 && pollfd[0].fd == pollfd[1].fd && 2045 pollfd[0].events == pollfd[1].events && 2046 pollfd[0].revents == pollfd[1].revents) { 2047 skip++; 2048 continue; 2049 } 2050 2051 if (skip > 0) 2052 (void) printf("%s\t...last pollfd structure" 2053 " repeated %d time%s...\n", 2054 pri->pname, skip, (skip == 1 ? "" : "s")); 2055 2056 skip = 0; 2057 show_one_pollfd(pri, &pollfd[0]); 2058 pollfd[1] = pollfd[0]; 2059 } 2060 2061 if (skip > 0) 2062 (void) printf( 2063 "%s\t...last pollfd structure repeated %d time%s...\n", 2064 pri->pname, skip, (skip == 1 ? "" : "s")); 2065 } 2066 2067 void 2068 show_poll(private_t *pri) 2069 { 2070 long offset; 2071 int nfds; 2072 int serial = 0; 2073 2074 if (pri->sys_nargs < 2 || (offset = pri->sys_args[0]) == NULL || 2075 (nfds = pri->sys_args[1]) <= 0) 2076 return; 2077 2078 /* enter region of lengthy output */ 2079 if (nfds > 32) { 2080 Eserialize(); 2081 serial = 1; 2082 } 2083 2084 show_all_pollfds(pri, offset, nfds); 2085 2086 /* exit region of lengthy output */ 2087 if (serial) 2088 Xserialize(); 2089 } 2090 2091 void 2092 show_pollsys(private_t *pri) 2093 { 2094 long offset; 2095 int nfds; 2096 int serial = 0; 2097 2098 if (pri->sys_nargs < 2) 2099 return; 2100 2101 offset = pri->sys_args[0]; 2102 nfds = pri->sys_args[1]; 2103 2104 /* enter region of lengthy output */ 2105 if (offset != NULL && nfds > 32) { 2106 Eserialize(); 2107 serial = 1; 2108 } 2109 2110 if (offset != NULL && nfds > 0) 2111 show_all_pollfds(pri, offset, nfds); 2112 2113 if (pri->sys_nargs > 2) 2114 show_timestruc(pri, (long)pri->sys_args[2], "timeout"); 2115 2116 if (pri->sys_nargs > 3) 2117 show_sigset(pri, (long)pri->sys_args[3], "sigmask"); 2118 2119 /* exit region of lengthy output */ 2120 if (serial) 2121 Xserialize(); 2122 } 2123 2124 static void 2125 show_perm64(private_t *pri, struct ipc_perm64 *ip) 2126 { 2127 (void) printf("%s\tu=%-5d g=%-5d cu=%-5d cg=%-5d z=%-5d " 2128 "m=0%.6o key=%d projid=%-5d\n", 2129 pri->pname, 2130 (int)ip->ipcx_uid, 2131 (int)ip->ipcx_gid, 2132 (int)ip->ipcx_cuid, 2133 (int)ip->ipcx_cgid, 2134 (int)ip->ipcx_zoneid, 2135 (unsigned int)ip->ipcx_mode, 2136 ip->ipcx_key, 2137 (int)ip->ipcx_projid); 2138 } 2139 2140 void 2141 show_perm(private_t *pri, struct ipc_perm *ip) 2142 { 2143 (void) printf( 2144 "%s\tu=%-5u g=%-5u cu=%-5u cg=%-5u m=0%.6o seq=%u key=%d\n", 2145 pri->pname, 2146 (int)ip->uid, 2147 (int)ip->gid, 2148 (int)ip->cuid, 2149 (int)ip->cgid, 2150 (int)ip->mode, 2151 ip->seq, 2152 ip->key); 2153 } 2154 2155 #ifdef _LP64 2156 void 2157 show_perm32(private_t *pri, struct ipc_perm32 *ip) 2158 { 2159 (void) printf( 2160 "%s\tu=%-5u g=%-5u cu=%-5u cg=%-5u m=0%.6o seq=%u key=%d\n", 2161 pri->pname, 2162 ip->uid, 2163 ip->gid, 2164 ip->cuid, 2165 ip->cgid, 2166 ip->mode, 2167 ip->seq, 2168 ip->key); 2169 } 2170 #endif /* _LP64 */ 2171 2172 static void 2173 show_msgctl64(private_t *pri, long offset) 2174 { 2175 struct msqid_ds64 msgq; 2176 2177 if (offset != NULL && 2178 Pread(Proc, &msgq, sizeof (msgq), offset) == sizeof (msgq)) { 2179 show_perm64(pri, &msgq.msgx_perm); 2180 2181 (void) printf("%s\tbytes=%-5llu msgs=%-5llu maxby=%-5llu " 2182 "lspid=%-5d lrpid=%-5d\n", pri->pname, 2183 (unsigned long long)msgq.msgx_cbytes, 2184 (unsigned long long)msgq.msgx_qnum, 2185 (unsigned long long)msgq.msgx_qbytes, 2186 (int)msgq.msgx_lspid, 2187 (int)msgq.msgx_lrpid); 2188 2189 prtime(pri, " st = ", (time_t)msgq.msgx_stime); 2190 prtime(pri, " rt = ", (time_t)msgq.msgx_rtime); 2191 prtime(pri, " ct = ", (time_t)msgq.msgx_ctime); 2192 } 2193 } 2194 2195 void 2196 show_msgctl(private_t *pri, long offset) 2197 { 2198 struct msqid_ds msgq; 2199 2200 if (offset != NULL && 2201 Pread(Proc, &msgq, sizeof (msgq), offset) == sizeof (msgq)) { 2202 show_perm(pri, &msgq.msg_perm); 2203 2204 (void) printf( 2205 "%s\tbytes=%-5lu msgs=%-5lu maxby=%-5lu lspid=%-5u lrpid=%-5u\n", 2206 pri->pname, 2207 msgq.msg_cbytes, 2208 msgq.msg_qnum, 2209 msgq.msg_qbytes, 2210 (int)msgq.msg_lspid, 2211 (int)msgq.msg_lrpid); 2212 2213 prtime(pri, " st = ", msgq.msg_stime); 2214 prtime(pri, " rt = ", msgq.msg_rtime); 2215 prtime(pri, " ct = ", msgq.msg_ctime); 2216 } 2217 } 2218 2219 #ifdef _LP64 2220 void 2221 show_msgctl32(private_t *pri, long offset) 2222 { 2223 struct msqid_ds32 msgq; 2224 2225 if (offset != NULL && 2226 Pread(Proc, &msgq, sizeof (msgq), offset) == sizeof (msgq)) { 2227 show_perm32(pri, &msgq.msg_perm); 2228 2229 (void) printf( 2230 "%s\tbytes=%-5u msgs=%-5u maxby=%-5u lspid=%-5u lrpid=%-5u\n", 2231 pri->pname, 2232 msgq.msg_cbytes, 2233 msgq.msg_qnum, 2234 msgq.msg_qbytes, 2235 msgq.msg_lspid, 2236 msgq.msg_lrpid); 2237 2238 prtime(pri, " st = ", msgq.msg_stime); 2239 prtime(pri, " rt = ", msgq.msg_rtime); 2240 prtime(pri, " ct = ", msgq.msg_ctime); 2241 } 2242 } 2243 #endif /* _LP64 */ 2244 2245 void 2246 show_msgbuf(private_t *pri, long offset, long msgsz) 2247 { 2248 struct msgbuf msgb; 2249 2250 if (offset != NULL && 2251 Pread(Proc, &msgb, sizeof (msgb.mtype), offset) == 2252 sizeof (msgb.mtype)) { 2253 /* enter region of lengthy output */ 2254 if (msgsz > MYBUFSIZ / 4) 2255 Eserialize(); 2256 2257 (void) printf("%s\tmtype=%lu mtext[]=\n", 2258 pri->pname, 2259 msgb.mtype); 2260 showbuffer(pri, 2261 (long)(offset + sizeof (msgb.mtype)), msgsz); 2262 2263 /* exit region of lengthy output */ 2264 if (msgsz > MYBUFSIZ / 4) 2265 Xserialize(); 2266 } 2267 } 2268 2269 #ifdef _LP64 2270 void 2271 show_msgbuf32(private_t *pri, long offset, long msgsz) 2272 { 2273 struct ipcmsgbuf32 msgb; 2274 2275 if (offset != NULL && 2276 Pread(Proc, &msgb, sizeof (msgb.mtype), offset) == 2277 sizeof (msgb.mtype)) { 2278 /* enter region of lengthy output */ 2279 if (msgsz > MYBUFSIZ / 4) 2280 Eserialize(); 2281 2282 (void) printf("%s\tmtype=%u mtext[]=\n", 2283 pri->pname, 2284 msgb.mtype); 2285 showbuffer(pri, 2286 (long)(offset + sizeof (msgb.mtype)), msgsz); 2287 2288 /* exit region of lengthy output */ 2289 if (msgsz > MYBUFSIZ / 4) 2290 Xserialize(); 2291 } 2292 } 2293 #endif /* _LP64 */ 2294 2295 #ifdef _LP64 2296 void 2297 show_msgsys(private_t *pri, long msgsz) 2298 { 2299 switch (pri->sys_args[0]) { 2300 case 0: /* msgget() */ 2301 break; 2302 case 1: /* msgctl() */ 2303 if (pri->sys_nargs > 3) { 2304 switch (pri->sys_args[2]) { 2305 case IPC_STAT: 2306 if (pri->Errno) 2307 break; 2308 /*FALLTHROUGH*/ 2309 case IPC_SET: 2310 if (data_model == PR_MODEL_LP64) 2311 show_msgctl(pri, 2312 (long)pri->sys_args[3]); 2313 else 2314 show_msgctl32(pri, 2315 (long)pri->sys_args[3]); 2316 break; 2317 case IPC_STAT64: 2318 if (pri->Errno) 2319 break; 2320 /*FALLTHROUGH*/ 2321 case IPC_SET64: 2322 show_msgctl64(pri, (long)pri->sys_args[3]); 2323 break; 2324 } 2325 } 2326 break; 2327 case 2: /* msgrcv() */ 2328 if (!pri->Errno && pri->sys_nargs > 2) { 2329 if (data_model == PR_MODEL_LP64) 2330 show_msgbuf(pri, pri->sys_args[2], msgsz); 2331 else 2332 show_msgbuf32(pri, pri->sys_args[2], msgsz); 2333 } 2334 break; 2335 case 3: /* msgsnd() */ 2336 if (pri->sys_nargs > 3) { 2337 if (data_model == PR_MODEL_LP64) 2338 show_msgbuf(pri, pri->sys_args[2], 2339 pri->sys_args[3]); 2340 else 2341 show_msgbuf32(pri, pri->sys_args[2], 2342 pri->sys_args[3]); 2343 } 2344 break; 2345 case 4: /* msgids() */ 2346 case 5: /* msgsnap() */ 2347 default: /* unexpected subcode */ 2348 break; 2349 } 2350 } 2351 #else /* _LP64 */ 2352 void 2353 show_msgsys(private_t *pri, long msgsz) 2354 { 2355 switch (pri->sys_args[0]) { 2356 case 0: /* msgget() */ 2357 break; 2358 case 1: /* msgctl() */ 2359 if (pri->sys_nargs > 3) { 2360 switch (pri->sys_args[2]) { 2361 case IPC_STAT: 2362 if (pri->Errno) 2363 break; 2364 /*FALLTHROUGH*/ 2365 case IPC_SET: 2366 show_msgctl(pri, (long)pri->sys_args[3]); 2367 break; 2368 case IPC_STAT64: 2369 if (pri->Errno) 2370 break; 2371 /*FALLTHROUGH*/ 2372 case IPC_SET64: 2373 show_msgctl64(pri, (long)pri->sys_args[3]); 2374 break; 2375 } 2376 } 2377 break; 2378 case 2: /* msgrcv() */ 2379 if (!pri->Errno && pri->sys_nargs > 2) 2380 show_msgbuf(pri, pri->sys_args[2], msgsz); 2381 break; 2382 case 3: /* msgsnd() */ 2383 if (pri->sys_nargs > 3) 2384 show_msgbuf(pri, pri->sys_args[2], 2385 pri->sys_args[3]); 2386 break; 2387 case 4: /* msgids() */ 2388 case 5: /* msgsnap() */ 2389 default: /* unexpected subcode */ 2390 break; 2391 } 2392 } 2393 #endif /* _LP64 */ 2394 2395 static void 2396 show_semctl64(private_t *pri, long offset) 2397 { 2398 struct semid_ds64 semds; 2399 2400 if (offset != NULL && 2401 Pread(Proc, &semds, sizeof (semds), offset) == sizeof (semds)) { 2402 show_perm64(pri, &semds.semx_perm); 2403 2404 (void) printf("%s\tnsems=%u\n", pri->pname, semds.semx_nsems); 2405 2406 prtime(pri, " ot = ", (time_t)semds.semx_otime); 2407 prtime(pri, " ct = ", (time_t)semds.semx_ctime); 2408 } 2409 } 2410 2411 void 2412 show_semctl(private_t *pri, long offset) 2413 { 2414 struct semid_ds semds; 2415 2416 if (offset != NULL && 2417 Pread(Proc, &semds, sizeof (semds), offset) == sizeof (semds)) { 2418 show_perm(pri, &semds.sem_perm); 2419 2420 (void) printf("%s\tnsems=%u\n", 2421 pri->pname, 2422 semds.sem_nsems); 2423 2424 prtime(pri, " ot = ", semds.sem_otime); 2425 prtime(pri, " ct = ", semds.sem_ctime); 2426 } 2427 } 2428 2429 #ifdef _LP64 2430 void 2431 show_semctl32(private_t *pri, long offset) 2432 { 2433 struct semid_ds32 semds; 2434 2435 if (offset != NULL && 2436 Pread(Proc, &semds, sizeof (semds), offset) == sizeof (semds)) { 2437 show_perm32(pri, &semds.sem_perm); 2438 2439 (void) printf("%s\tnsems=%u\n", 2440 pri->pname, 2441 semds.sem_nsems); 2442 2443 prtime(pri, " ot = ", semds.sem_otime); 2444 prtime(pri, " ct = ", semds.sem_ctime); 2445 } 2446 } 2447 #endif /* _LP64 */ 2448 2449 void 2450 show_semop(private_t *pri, long offset, long nsops, long timeout) 2451 { 2452 struct sembuf sembuf; 2453 const char *str; 2454 2455 if (offset == NULL) 2456 return; 2457 2458 if (nsops > 40) /* let's not be ridiculous */ 2459 nsops = 40; 2460 2461 for (; nsops > 0 && !interrupt; --nsops, offset += sizeof (sembuf)) { 2462 if (Pread(Proc, &sembuf, sizeof (sembuf), offset) != 2463 sizeof (sembuf)) 2464 break; 2465 2466 (void) printf("%s\tsemnum=%-5u semop=%-5d semflg=", 2467 pri->pname, 2468 sembuf.sem_num, 2469 sembuf.sem_op); 2470 2471 if (sembuf.sem_flg == 0) 2472 (void) printf("0\n"); 2473 else if ((str = semflags(pri, sembuf.sem_flg)) != NULL) 2474 (void) printf("%s\n", str); 2475 else 2476 (void) printf("0%.6o\n", sembuf.sem_flg); 2477 } 2478 if (timeout) 2479 show_timestruc(pri, timeout, "timeout"); 2480 } 2481 2482 void 2483 show_semsys(private_t *pri) 2484 { 2485 switch (pri->sys_args[0]) { 2486 case 0: /* semctl() */ 2487 if (pri->sys_nargs > 4) { 2488 switch (pri->sys_args[3]) { 2489 case IPC_STAT: 2490 if (pri->Errno) 2491 break; 2492 /*FALLTHROUGH*/ 2493 case IPC_SET: 2494 #ifdef _LP64 2495 if (data_model == PR_MODEL_LP64) 2496 show_semctl(pri, 2497 (long)pri->sys_args[4]); 2498 else 2499 show_semctl32(pri, 2500 (long)pri->sys_args[4]); 2501 #else 2502 show_semctl(pri, (long)pri->sys_args[4]); 2503 #endif 2504 break; 2505 case IPC_STAT64: 2506 if (pri->Errno) 2507 break; 2508 /*FALLTHROUGH*/ 2509 case IPC_SET64: 2510 show_semctl64(pri, (long)pri->sys_args[4]); 2511 break; 2512 } 2513 } 2514 break; 2515 case 1: /* semget() */ 2516 break; 2517 case 2: /* semop() */ 2518 if (pri->sys_nargs > 3) 2519 show_semop(pri, (long)pri->sys_args[2], 2520 pri->sys_args[3], 0); 2521 break; 2522 case 3: /* semids() */ 2523 break; 2524 case 4: /* semtimedop() */ 2525 if (pri->sys_nargs > 4) 2526 show_semop(pri, (long)pri->sys_args[2], 2527 pri->sys_args[3], pri->sys_args[4]); 2528 break; 2529 default: /* unexpected subcode */ 2530 break; 2531 } 2532 } 2533 2534 static void 2535 show_shmctl64(private_t *pri, long offset) 2536 { 2537 struct shmid_ds64 shmds; 2538 2539 if (offset != NULL && 2540 Pread(Proc, &shmds, sizeof (shmds), offset) == sizeof (shmds)) { 2541 show_perm64(pri, &shmds.shmx_perm); 2542 2543 (void) printf( 2544 "%s\tsize=%-6llu lpid=%-5d cpid=%-5d na=%-5llu cna=%llu\n", 2545 pri->pname, 2546 (unsigned long long)shmds.shmx_segsz, 2547 (int)shmds.shmx_lpid, 2548 (int)shmds.shmx_cpid, 2549 (unsigned long long)shmds.shmx_nattch, 2550 (unsigned long long)shmds.shmx_cnattch); 2551 2552 prtime(pri, " at = ", (time_t)shmds.shmx_atime); 2553 prtime(pri, " dt = ", (time_t)shmds.shmx_dtime); 2554 prtime(pri, " ct = ", (time_t)shmds.shmx_ctime); 2555 } 2556 } 2557 2558 void 2559 show_shmctl(private_t *pri, long offset) 2560 { 2561 struct shmid_ds shmds; 2562 2563 if (offset != NULL && 2564 Pread(Proc, &shmds, sizeof (shmds), offset) == sizeof (shmds)) { 2565 show_perm(pri, &shmds.shm_perm); 2566 2567 (void) printf( 2568 "%s\tsize=%-6lu lpid=%-5u cpid=%-5u na=%-5lu cna=%lu\n", 2569 pri->pname, 2570 (ulong_t)shmds.shm_segsz, 2571 (int)shmds.shm_lpid, 2572 (int)shmds.shm_cpid, 2573 shmds.shm_nattch, 2574 shmds.shm_cnattch); 2575 2576 prtime(pri, " at = ", shmds.shm_atime); 2577 prtime(pri, " dt = ", shmds.shm_dtime); 2578 prtime(pri, " ct = ", shmds.shm_ctime); 2579 } 2580 } 2581 2582 #ifdef _LP64 2583 void 2584 show_shmctl32(private_t *pri, long offset) 2585 { 2586 struct shmid_ds32 shmds; 2587 2588 if (offset != NULL && 2589 Pread(Proc, &shmds, sizeof (shmds), offset) == sizeof (shmds)) { 2590 show_perm32(pri, &shmds.shm_perm); 2591 2592 (void) printf( 2593 "%s\tsize=%-6u lpid=%-5u cpid=%-5u na=%-5u cna=%u\n", 2594 pri->pname, 2595 shmds.shm_segsz, 2596 shmds.shm_lpid, 2597 shmds.shm_cpid, 2598 shmds.shm_nattch, 2599 shmds.shm_cnattch); 2600 2601 prtime(pri, " at = ", shmds.shm_atime); 2602 prtime(pri, " dt = ", shmds.shm_dtime); 2603 prtime(pri, " ct = ", shmds.shm_ctime); 2604 } 2605 } 2606 #endif /* _LP64 */ 2607 2608 void 2609 show_shmsys(private_t *pri) 2610 { 2611 switch (pri->sys_args[0]) { 2612 case 0: /* shmat() */ 2613 break; 2614 case 1: /* shmctl() */ 2615 if (pri->sys_nargs > 3) { 2616 switch (pri->sys_args[2]) { 2617 case IPC_STAT: 2618 if (pri->Errno) 2619 break; 2620 /*FALLTHROUGH*/ 2621 case IPC_SET: 2622 #ifdef _LP64 2623 if (data_model == PR_MODEL_LP64) 2624 show_shmctl(pri, 2625 (long)pri->sys_args[3]); 2626 else 2627 show_shmctl32(pri, 2628 (long)pri->sys_args[3]); 2629 #else 2630 show_shmctl(pri, (long)pri->sys_args[3]); 2631 #endif 2632 break; 2633 case IPC_STAT64: 2634 if (pri->Errno) 2635 break; 2636 /*FALLTHROUGH*/ 2637 case IPC_SET64: 2638 show_shmctl64(pri, (long)pri->sys_args[3]); 2639 break; 2640 } 2641 } 2642 break; 2643 case 2: /* shmdt() */ 2644 case 3: /* shmget() */ 2645 case 4: /* shmids() */ 2646 default: /* unexpected subcode */ 2647 break; 2648 } 2649 } 2650 2651 void 2652 show_groups(private_t *pri, long offset, long count) 2653 { 2654 int groups[100]; 2655 2656 if (count > 100) 2657 count = 100; 2658 2659 if (count > 0 && offset != NULL && 2660 Pread(Proc, &groups[0], count*sizeof (int), offset) == 2661 count*sizeof (int)) { 2662 int n; 2663 2664 (void) printf("%s\t", pri->pname); 2665 for (n = 0; !interrupt && n < count; n++) { 2666 if (n != 0 && n%10 == 0) 2667 (void) printf("\n%s\t", pri->pname); 2668 (void) printf(" %5d", groups[n]); 2669 } 2670 (void) fputc('\n', stdout); 2671 } 2672 } 2673 2674 /* 2675 * This assumes that a sigset_t is simply an array of ints. 2676 */ 2677 char * 2678 sigset_string(private_t *pri, sigset_t *sp) 2679 { 2680 char *s = pri->code_buf; 2681 int n = sizeof (*sp) / sizeof (int32_t); 2682 int32_t *lp = (int32_t *)sp; 2683 2684 while (--n >= 0) { 2685 int32_t val = *lp++; 2686 2687 if (val == 0) 2688 s += sprintf(s, " 0"); 2689 else 2690 s += sprintf(s, " 0x%.8X", val); 2691 } 2692 2693 return (pri->code_buf); 2694 } 2695 2696 void 2697 show_sigset(private_t *pri, long offset, const char *name) 2698 { 2699 sigset_t sigset; 2700 2701 if (offset != NULL && 2702 Pread(Proc, &sigset, sizeof (sigset), offset) == sizeof (sigset)) { 2703 (void) printf("%s\t%s =%s\n", 2704 pri->pname, name, sigset_string(pri, &sigset)); 2705 } 2706 } 2707 2708 #ifdef _LP64 2709 void 2710 show_sigaltstack32(private_t *pri, long offset, const char *name) 2711 { 2712 struct sigaltstack32 altstack; 2713 2714 if (offset != NULL && 2715 Pread(Proc, &altstack, sizeof (altstack), offset) == 2716 sizeof (altstack)) { 2717 (void) printf("%s\t%s: sp=0x%.8X size=%u flags=0x%.4X\n", 2718 pri->pname, 2719 name, 2720 altstack.ss_sp, 2721 altstack.ss_size, 2722 altstack.ss_flags); 2723 } 2724 } 2725 #endif /* _LP64 */ 2726 2727 void 2728 show_sigaltstack(private_t *pri, long offset, const char *name) 2729 { 2730 struct sigaltstack altstack; 2731 2732 #ifdef _LP64 2733 if (data_model != PR_MODEL_LP64) { 2734 show_sigaltstack32(pri, offset, name); 2735 return; 2736 } 2737 #endif 2738 if (offset != NULL && 2739 Pread(Proc, &altstack, sizeof (altstack), offset) == 2740 sizeof (altstack)) { 2741 (void) printf("%s\t%s: sp=0x%.8lX size=%lu flags=0x%.4X\n", 2742 pri->pname, 2743 name, 2744 (ulong_t)altstack.ss_sp, 2745 (ulong_t)altstack.ss_size, 2746 altstack.ss_flags); 2747 } 2748 } 2749 2750 #ifdef _LP64 2751 void 2752 show_sigaction32(private_t *pri, long offset, const char *name, long odisp) 2753 { 2754 struct sigaction32 sigaction; 2755 2756 if (offset != NULL && 2757 Pread(Proc, &sigaction, sizeof (sigaction), offset) == 2758 sizeof (sigaction)) { 2759 /* This is stupid, we shouldn't have to do this */ 2760 if (odisp != NULL) 2761 sigaction.sa_handler = (caddr32_t)odisp; 2762 (void) printf( 2763 "%s %s: hand = 0x%.8X mask =%s flags = 0x%.4X\n", 2764 pri->pname, 2765 name, 2766 sigaction.sa_handler, 2767 sigset_string(pri, (sigset_t *)&sigaction.sa_mask), 2768 sigaction.sa_flags); 2769 } 2770 } 2771 #endif /* _LP64 */ 2772 2773 void 2774 show_sigaction(private_t *pri, long offset, const char *name, long odisp) 2775 { 2776 struct sigaction sigaction; 2777 2778 #ifdef _LP64 2779 if (data_model != PR_MODEL_LP64) { 2780 show_sigaction32(pri, offset, name, odisp); 2781 return; 2782 } 2783 #endif 2784 if (offset != NULL && 2785 Pread(Proc, &sigaction, sizeof (sigaction), offset) == 2786 sizeof (sigaction)) { 2787 /* This is stupid, we shouldn't have to do this */ 2788 if (odisp != NULL) 2789 sigaction.sa_handler = (void (*)())odisp; 2790 (void) printf( 2791 "%s %s: hand = 0x%.8lX mask =%s flags = 0x%.4X\n", 2792 pri->pname, 2793 name, 2794 (long)sigaction.sa_handler, 2795 sigset_string(pri, &sigaction.sa_mask), 2796 sigaction.sa_flags); 2797 } 2798 } 2799 2800 #ifdef _LP64 2801 void 2802 print_siginfo32(private_t *pri, const siginfo32_t *sip) 2803 { 2804 const char *code = NULL; 2805 2806 (void) printf("%s siginfo: %s", pri->pname, 2807 signame(pri, sip->si_signo)); 2808 2809 if (sip->si_signo != 0 && SI_FROMUSER(sip) && sip->si_pid != 0) { 2810 (void) printf(" pid=%d uid=%d", sip->si_pid, sip->si_uid); 2811 if (sip->si_code != 0) 2812 (void) printf(" code=%d", sip->si_code); 2813 (void) fputc('\n', stdout); 2814 return; 2815 } 2816 2817 switch (sip->si_signo) { 2818 default: 2819 (void) fputc('\n', stdout); 2820 return; 2821 case SIGILL: 2822 case SIGTRAP: 2823 case SIGFPE: 2824 case SIGSEGV: 2825 case SIGBUS: 2826 case SIGEMT: 2827 case SIGCLD: 2828 case SIGPOLL: 2829 case SIGXFSZ: 2830 break; 2831 } 2832 2833 switch (sip->si_signo) { 2834 case SIGILL: 2835 switch (sip->si_code) { 2836 case ILL_ILLOPC: code = "ILL_ILLOPC"; break; 2837 case ILL_ILLOPN: code = "ILL_ILLOPN"; break; 2838 case ILL_ILLADR: code = "ILL_ILLADR"; break; 2839 case ILL_ILLTRP: code = "ILL_ILLTRP"; break; 2840 case ILL_PRVOPC: code = "ILL_PRVOPC"; break; 2841 case ILL_PRVREG: code = "ILL_PRVREG"; break; 2842 case ILL_COPROC: code = "ILL_COPROC"; break; 2843 case ILL_BADSTK: code = "ILL_BADSTK"; break; 2844 } 2845 break; 2846 case SIGTRAP: 2847 switch (sip->si_code) { 2848 case TRAP_BRKPT: code = "TRAP_BRKPT"; break; 2849 case TRAP_TRACE: code = "TRAP_TRACE"; break; 2850 case TRAP_RWATCH: code = "TRAP_RWATCH"; break; 2851 case TRAP_WWATCH: code = "TRAP_WWATCH"; break; 2852 case TRAP_XWATCH: code = "TRAP_XWATCH"; break; 2853 case TRAP_DTRACE: code = "TRAP_DTRACE"; break; 2854 } 2855 break; 2856 case SIGFPE: 2857 switch (sip->si_code) { 2858 case FPE_INTDIV: code = "FPE_INTDIV"; break; 2859 case FPE_INTOVF: code = "FPE_INTOVF"; break; 2860 case FPE_FLTDIV: code = "FPE_FLTDIV"; break; 2861 case FPE_FLTOVF: code = "FPE_FLTOVF"; break; 2862 case FPE_FLTUND: code = "FPE_FLTUND"; break; 2863 case FPE_FLTRES: code = "FPE_FLTRES"; break; 2864 case FPE_FLTINV: code = "FPE_FLTINV"; break; 2865 case FPE_FLTSUB: code = "FPE_FLTSUB"; break; 2866 #if defined(FPE_FLTDEN) 2867 case FPE_FLTDEN: code = "FPE_FLTDEN"; break; 2868 #endif 2869 } 2870 break; 2871 case SIGSEGV: 2872 switch (sip->si_code) { 2873 case SEGV_MAPERR: code = "SEGV_MAPERR"; break; 2874 case SEGV_ACCERR: code = "SEGV_ACCERR"; break; 2875 } 2876 break; 2877 case SIGEMT: 2878 switch (sip->si_code) { 2879 #ifdef EMT_TAGOVF 2880 case EMT_TAGOVF: code = "EMT_TAGOVF"; break; 2881 #endif 2882 case EMT_CPCOVF: code = "EMT_CPCOVF"; break; 2883 } 2884 break; 2885 case SIGBUS: 2886 switch (sip->si_code) { 2887 case BUS_ADRALN: code = "BUS_ADRALN"; break; 2888 case BUS_ADRERR: code = "BUS_ADRERR"; break; 2889 case BUS_OBJERR: code = "BUS_OBJERR"; break; 2890 } 2891 break; 2892 case SIGCLD: 2893 switch (sip->si_code) { 2894 case CLD_EXITED: code = "CLD_EXITED"; break; 2895 case CLD_KILLED: code = "CLD_KILLED"; break; 2896 case CLD_DUMPED: code = "CLD_DUMPED"; break; 2897 case CLD_TRAPPED: code = "CLD_TRAPPED"; break; 2898 case CLD_STOPPED: code = "CLD_STOPPED"; break; 2899 case CLD_CONTINUED: code = "CLD_CONTINUED"; break; 2900 } 2901 break; 2902 case SIGPOLL: 2903 switch (sip->si_code) { 2904 case POLL_IN: code = "POLL_IN"; break; 2905 case POLL_OUT: code = "POLL_OUT"; break; 2906 case POLL_MSG: code = "POLL_MSG"; break; 2907 case POLL_ERR: code = "POLL_ERR"; break; 2908 case POLL_PRI: code = "POLL_PRI"; break; 2909 case POLL_HUP: code = "POLL_HUP"; break; 2910 } 2911 break; 2912 } 2913 2914 if (code == NULL) { 2915 (void) sprintf(pri->code_buf, "code=%d", sip->si_code); 2916 code = (const char *)pri->code_buf; 2917 } 2918 2919 switch (sip->si_signo) { 2920 case SIGILL: 2921 case SIGTRAP: 2922 case SIGFPE: 2923 case SIGSEGV: 2924 case SIGBUS: 2925 case SIGEMT: 2926 (void) printf(" %s addr=0x%.8X", 2927 code, 2928 sip->si_addr); 2929 break; 2930 case SIGCLD: 2931 (void) printf(" %s pid=%d status=0x%.4X", 2932 code, 2933 sip->si_pid, 2934 sip->si_status); 2935 break; 2936 case SIGPOLL: 2937 case SIGXFSZ: 2938 (void) printf(" %s fd=%d band=%d", 2939 code, 2940 sip->si_fd, 2941 sip->si_band); 2942 break; 2943 } 2944 2945 if (sip->si_errno != 0) { 2946 const char *ename = errname(sip->si_errno); 2947 2948 (void) printf(" errno=%d", sip->si_errno); 2949 if (ename != NULL) 2950 (void) printf("(%s)", ename); 2951 } 2952 2953 (void) fputc('\n', stdout); 2954 } 2955 #endif /* _LP64 */ 2956 2957 void 2958 print_siginfo(private_t *pri, const siginfo_t *sip) 2959 { 2960 const char *code = NULL; 2961 2962 (void) printf("%s siginfo: %s", pri->pname, 2963 signame(pri, sip->si_signo)); 2964 2965 if (sip->si_signo != 0 && SI_FROMUSER(sip) && sip->si_pid != 0) { 2966 (void) printf(" pid=%d uid=%d", 2967 (int)sip->si_pid, 2968 (int)sip->si_uid); 2969 if (sip->si_code != 0) 2970 (void) printf(" code=%d", sip->si_code); 2971 (void) fputc('\n', stdout); 2972 return; 2973 } 2974 2975 switch (sip->si_signo) { 2976 default: 2977 (void) fputc('\n', stdout); 2978 return; 2979 case SIGILL: 2980 case SIGTRAP: 2981 case SIGFPE: 2982 case SIGSEGV: 2983 case SIGBUS: 2984 case SIGEMT: 2985 case SIGCLD: 2986 case SIGPOLL: 2987 case SIGXFSZ: 2988 break; 2989 } 2990 2991 switch (sip->si_signo) { 2992 case SIGILL: 2993 switch (sip->si_code) { 2994 case ILL_ILLOPC: code = "ILL_ILLOPC"; break; 2995 case ILL_ILLOPN: code = "ILL_ILLOPN"; break; 2996 case ILL_ILLADR: code = "ILL_ILLADR"; break; 2997 case ILL_ILLTRP: code = "ILL_ILLTRP"; break; 2998 case ILL_PRVOPC: code = "ILL_PRVOPC"; break; 2999 case ILL_PRVREG: code = "ILL_PRVREG"; break; 3000 case ILL_COPROC: code = "ILL_COPROC"; break; 3001 case ILL_BADSTK: code = "ILL_BADSTK"; break; 3002 } 3003 break; 3004 case SIGTRAP: 3005 switch (sip->si_code) { 3006 case TRAP_BRKPT: code = "TRAP_BRKPT"; break; 3007 case TRAP_TRACE: code = "TRAP_TRACE"; break; 3008 case TRAP_RWATCH: code = "TRAP_RWATCH"; break; 3009 case TRAP_WWATCH: code = "TRAP_WWATCH"; break; 3010 case TRAP_XWATCH: code = "TRAP_XWATCH"; break; 3011 case TRAP_DTRACE: code = "TRAP_DTRACE"; break; 3012 } 3013 break; 3014 case SIGFPE: 3015 switch (sip->si_code) { 3016 case FPE_INTDIV: code = "FPE_INTDIV"; break; 3017 case FPE_INTOVF: code = "FPE_INTOVF"; break; 3018 case FPE_FLTDIV: code = "FPE_FLTDIV"; break; 3019 case FPE_FLTOVF: code = "FPE_FLTOVF"; break; 3020 case FPE_FLTUND: code = "FPE_FLTUND"; break; 3021 case FPE_FLTRES: code = "FPE_FLTRES"; break; 3022 case FPE_FLTINV: code = "FPE_FLTINV"; break; 3023 case FPE_FLTSUB: code = "FPE_FLTSUB"; break; 3024 #if defined(FPE_FLTDEN) 3025 case FPE_FLTDEN: code = "FPE_FLTDEN"; break; 3026 #endif 3027 } 3028 break; 3029 case SIGSEGV: 3030 switch (sip->si_code) { 3031 case SEGV_MAPERR: code = "SEGV_MAPERR"; break; 3032 case SEGV_ACCERR: code = "SEGV_ACCERR"; break; 3033 } 3034 break; 3035 case SIGEMT: 3036 switch (sip->si_code) { 3037 #ifdef EMT_TAGOVF 3038 case EMT_TAGOVF: code = "EMT_TAGOVF"; break; 3039 #endif 3040 case EMT_CPCOVF: code = "EMT_CPCOVF"; break; 3041 } 3042 break; 3043 case SIGBUS: 3044 switch (sip->si_code) { 3045 case BUS_ADRALN: code = "BUS_ADRALN"; break; 3046 case BUS_ADRERR: code = "BUS_ADRERR"; break; 3047 case BUS_OBJERR: code = "BUS_OBJERR"; break; 3048 } 3049 break; 3050 case SIGCLD: 3051 switch (sip->si_code) { 3052 case CLD_EXITED: code = "CLD_EXITED"; break; 3053 case CLD_KILLED: code = "CLD_KILLED"; break; 3054 case CLD_DUMPED: code = "CLD_DUMPED"; break; 3055 case CLD_TRAPPED: code = "CLD_TRAPPED"; break; 3056 case CLD_STOPPED: code = "CLD_STOPPED"; break; 3057 case CLD_CONTINUED: code = "CLD_CONTINUED"; break; 3058 } 3059 break; 3060 case SIGPOLL: 3061 switch (sip->si_code) { 3062 case POLL_IN: code = "POLL_IN"; break; 3063 case POLL_OUT: code = "POLL_OUT"; break; 3064 case POLL_MSG: code = "POLL_MSG"; break; 3065 case POLL_ERR: code = "POLL_ERR"; break; 3066 case POLL_PRI: code = "POLL_PRI"; break; 3067 case POLL_HUP: code = "POLL_HUP"; break; 3068 } 3069 break; 3070 } 3071 3072 if (code == NULL) { 3073 (void) sprintf(pri->code_buf, "code=%d", sip->si_code); 3074 code = (const char *)pri->code_buf; 3075 } 3076 3077 switch (sip->si_signo) { 3078 case SIGILL: 3079 case SIGTRAP: 3080 case SIGFPE: 3081 case SIGSEGV: 3082 case SIGBUS: 3083 case SIGEMT: 3084 (void) printf(" %s addr=0x%.8lX", 3085 code, 3086 (long)sip->si_addr); 3087 break; 3088 case SIGCLD: 3089 (void) printf(" %s pid=%d status=0x%.4X", 3090 code, 3091 (int)sip->si_pid, 3092 sip->si_status); 3093 break; 3094 case SIGPOLL: 3095 case SIGXFSZ: 3096 (void) printf(" %s fd=%d band=%ld", 3097 code, 3098 sip->si_fd, 3099 sip->si_band); 3100 break; 3101 } 3102 3103 if (sip->si_errno != 0) { 3104 const char *ename = errname(sip->si_errno); 3105 3106 (void) printf(" errno=%d", sip->si_errno); 3107 if (ename != NULL) 3108 (void) printf("(%s)", ename); 3109 } 3110 3111 (void) fputc('\n', stdout); 3112 } 3113 3114 #ifdef _LP64 3115 void 3116 show_siginfo32(private_t *pri, long offset) 3117 { 3118 struct siginfo32 siginfo; 3119 3120 if (offset != NULL && 3121 Pread(Proc, &siginfo, sizeof (siginfo), offset) == sizeof (siginfo)) 3122 print_siginfo32(pri, &siginfo); 3123 } 3124 #endif /* _LP64 */ 3125 3126 void 3127 show_siginfo(private_t *pri, long offset) 3128 { 3129 struct siginfo siginfo; 3130 3131 #ifdef _LP64 3132 if (data_model != PR_MODEL_LP64) { 3133 show_siginfo32(pri, offset); 3134 return; 3135 } 3136 #endif 3137 if (offset != NULL && 3138 Pread(Proc, &siginfo, sizeof (siginfo), offset) == sizeof (siginfo)) 3139 print_siginfo(pri, &siginfo); 3140 } 3141 3142 void 3143 show_bool(private_t *pri, long offset, int count) 3144 { 3145 int serial = (count > MYBUFSIZ / 4); 3146 3147 /* enter region of lengthy output */ 3148 if (serial) 3149 Eserialize(); 3150 3151 while (count > 0) { 3152 char buf[32]; 3153 int nb = (count < 32)? count : 32; 3154 int i; 3155 3156 if (Pread(Proc, buf, (size_t)nb, offset) != nb) 3157 break; 3158 3159 (void) printf("%s ", pri->pname); 3160 for (i = 0; i < nb; i++) 3161 (void) printf(" %d", buf[i]); 3162 (void) fputc('\n', stdout); 3163 3164 count -= nb; 3165 offset += nb; 3166 } 3167 3168 /* exit region of lengthy output */ 3169 if (serial) 3170 Xserialize(); 3171 } 3172 3173 #ifdef _LP64 3174 void 3175 show_iovec32(private_t *pri, long offset, int niov, int showbuf, long count) 3176 { 3177 iovec32_t iovec[16]; 3178 iovec32_t *ip; 3179 long nb; 3180 int serial = (count > MYBUFSIZ / 4 && showbuf); 3181 3182 if (niov > 16) /* is this the real limit? */ 3183 niov = 16; 3184 3185 if (offset != NULL && niov > 0 && 3186 Pread(Proc, &iovec[0], niov*sizeof (iovec32_t), offset) 3187 == niov*sizeof (iovec32_t)) { 3188 /* enter region of lengthy output */ 3189 if (serial) 3190 Eserialize(); 3191 3192 for (ip = &iovec[0]; niov-- && !interrupt; ip++) { 3193 (void) printf("%s\tiov_base = 0x%.8X iov_len = %d\n", 3194 pri->pname, 3195 ip->iov_base, 3196 ip->iov_len); 3197 if ((nb = count) > 0) { 3198 if (nb > ip->iov_len) 3199 nb = ip->iov_len; 3200 if (nb > 0) 3201 count -= nb; 3202 } 3203 if (showbuf && nb > 0) 3204 showbuffer(pri, (long)ip->iov_base, nb); 3205 } 3206 3207 /* exit region of lengthy output */ 3208 if (serial) 3209 Xserialize(); 3210 } 3211 } 3212 #endif /* _LP64 */ 3213 3214 void 3215 show_iovec(private_t *pri, long offset, long niov, int showbuf, long count) 3216 { 3217 iovec_t iovec[16]; 3218 iovec_t *ip; 3219 long nb; 3220 int serial = (count > MYBUFSIZ / 4 && showbuf); 3221 3222 #ifdef _LP64 3223 if (data_model != PR_MODEL_LP64) { 3224 show_iovec32(pri, offset, niov, showbuf, count); 3225 return; 3226 } 3227 #endif 3228 if (niov > 16) /* is this the real limit? */ 3229 niov = 16; 3230 3231 if (offset != NULL && niov > 0 && 3232 Pread(Proc, &iovec[0], niov*sizeof (iovec_t), offset) 3233 == niov*sizeof (iovec_t)) { 3234 /* enter region of lengthy output */ 3235 if (serial) 3236 Eserialize(); 3237 3238 for (ip = &iovec[0]; niov-- && !interrupt; ip++) { 3239 (void) printf("%s\tiov_base = 0x%.8lX iov_len = %lu\n", 3240 pri->pname, 3241 (long)ip->iov_base, 3242 ip->iov_len); 3243 if ((nb = count) > 0) { 3244 if (nb > ip->iov_len) 3245 nb = ip->iov_len; 3246 if (nb > 0) 3247 count -= nb; 3248 } 3249 if (showbuf && nb > 0) 3250 showbuffer(pri, (long)ip->iov_base, nb); 3251 } 3252 3253 /* exit region of lengthy output */ 3254 if (serial) 3255 Xserialize(); 3256 } 3257 } 3258 3259 void 3260 show_dents32(private_t *pri, long offset, long count) 3261 { 3262 long buf[MYBUFSIZ / sizeof (long)]; 3263 struct dirent32 *dp; 3264 int serial = (count > 100); 3265 3266 if (offset == NULL) 3267 return; 3268 3269 /* enter region of lengthy output */ 3270 if (serial) 3271 Eserialize(); 3272 3273 while (count > 0 && !interrupt) { 3274 int nb = count < MYBUFSIZ? (int)count : MYBUFSIZ; 3275 3276 if ((nb = Pread(Proc, &buf[0], (size_t)nb, offset)) <= 0) 3277 break; 3278 3279 dp = (struct dirent32 *)&buf[0]; 3280 if (nb < (int)(dp->d_name - (char *)dp)) 3281 break; 3282 if ((unsigned)nb < dp->d_reclen) { 3283 /* getdents() error? */ 3284 (void) printf( 3285 "%s ino=%-5u off=%-4d rlen=%-3d\n", 3286 pri->pname, 3287 dp->d_ino, 3288 dp->d_off, 3289 dp->d_reclen); 3290 break; 3291 } 3292 3293 while (!interrupt && 3294 nb >= (int)(dp->d_name - (char *)dp) && 3295 (unsigned)nb >= dp->d_reclen) { 3296 (void) printf( 3297 "%s ino=%-5u off=%-4d rlen=%-3d \"%.*s\"\n", 3298 pri->pname, 3299 dp->d_ino, 3300 dp->d_off, 3301 dp->d_reclen, 3302 dp->d_reclen - (int)(dp->d_name - (char *)dp), 3303 dp->d_name); 3304 nb -= dp->d_reclen; 3305 count -= dp->d_reclen; 3306 offset += dp->d_reclen; 3307 /* LINTED improper alignment */ 3308 dp = (struct dirent32 *)((char *)dp + dp->d_reclen); 3309 } 3310 } 3311 3312 /* exit region of lengthy output */ 3313 if (serial) 3314 Xserialize(); 3315 } 3316 3317 void 3318 show_dents64(private_t *pri, long offset, long count) 3319 { 3320 long long buf[MYBUFSIZ / sizeof (long long)]; 3321 struct dirent64 *dp; 3322 int serial = (count > 100); 3323 3324 if (offset == NULL) 3325 return; 3326 3327 /* enter region of lengthy output */ 3328 if (serial) 3329 Eserialize(); 3330 3331 while (count > 0 && !interrupt) { 3332 int nb = count < MYBUFSIZ? (int)count : MYBUFSIZ; 3333 3334 if ((nb = Pread(Proc, &buf[0], (size_t)nb, offset)) <= 0) 3335 break; 3336 3337 dp = (struct dirent64 *)&buf[0]; 3338 if (nb < (int)(dp->d_name - (char *)dp)) 3339 break; 3340 if ((unsigned)nb < dp->d_reclen) { 3341 /* getdents() error? */ 3342 (void) printf( 3343 "%s ino=%-5llu off=%-4lld rlen=%-3d\n", 3344 pri->pname, 3345 (long long)dp->d_ino, 3346 (long long)dp->d_off, 3347 dp->d_reclen); 3348 break; 3349 } 3350 3351 while (!interrupt && 3352 nb >= (int)(dp->d_name - (char *)dp) && 3353 (unsigned)nb >= dp->d_reclen) { 3354 (void) printf( 3355 "%s ino=%-5llu off=%-4lld rlen=%-3d \"%.*s\"\n", 3356 pri->pname, 3357 (long long)dp->d_ino, 3358 (long long)dp->d_off, 3359 dp->d_reclen, 3360 dp->d_reclen - (int)(dp->d_name - (char *)dp), 3361 dp->d_name); 3362 nb -= dp->d_reclen; 3363 count -= dp->d_reclen; 3364 offset += dp->d_reclen; 3365 /* LINTED improper alignment */ 3366 dp = (struct dirent64 *)((char *)dp + dp->d_reclen); 3367 } 3368 } 3369 3370 /* exit region of lengthy output */ 3371 if (serial) 3372 Xserialize(); 3373 } 3374 3375 void 3376 show_rlimit32(private_t *pri, long offset) 3377 { 3378 struct rlimit32 rlimit; 3379 3380 if (offset != NULL && 3381 Pread(Proc, &rlimit, sizeof (rlimit), offset) == sizeof (rlimit)) { 3382 (void) printf("%s\t", pri->pname); 3383 switch (rlimit.rlim_cur) { 3384 case RLIM32_INFINITY: 3385 (void) fputs("cur = RLIM_INFINITY", stdout); 3386 break; 3387 case RLIM32_SAVED_MAX: 3388 (void) fputs("cur = RLIM_SAVED_MAX", stdout); 3389 break; 3390 case RLIM32_SAVED_CUR: 3391 (void) fputs("cur = RLIM_SAVED_CUR", stdout); 3392 break; 3393 default: 3394 (void) printf("cur = %lu", (long)rlimit.rlim_cur); 3395 break; 3396 } 3397 switch (rlimit.rlim_max) { 3398 case RLIM32_INFINITY: 3399 (void) fputs(" max = RLIM_INFINITY\n", stdout); 3400 break; 3401 case RLIM32_SAVED_MAX: 3402 (void) fputs(" max = RLIM_SAVED_MAX\n", stdout); 3403 break; 3404 case RLIM32_SAVED_CUR: 3405 (void) fputs(" max = RLIM_SAVED_CUR\n", stdout); 3406 break; 3407 default: 3408 (void) printf(" max = %lu\n", (long)rlimit.rlim_max); 3409 break; 3410 } 3411 } 3412 } 3413 3414 void 3415 show_rlimit64(private_t *pri, long offset) 3416 { 3417 struct rlimit64 rlimit; 3418 3419 if (offset != NULL && 3420 Pread(Proc, &rlimit, sizeof (rlimit), offset) == sizeof (rlimit)) { 3421 (void) printf("%s\t", pri->pname); 3422 switch (rlimit.rlim_cur) { 3423 case RLIM64_INFINITY: 3424 (void) fputs("cur = RLIM64_INFINITY", stdout); 3425 break; 3426 case RLIM64_SAVED_MAX: 3427 (void) fputs("cur = RLIM64_SAVED_MAX", stdout); 3428 break; 3429 case RLIM64_SAVED_CUR: 3430 (void) fputs("cur = RLIM64_SAVED_CUR", stdout); 3431 break; 3432 default: 3433 (void) printf("cur = %llu", 3434 (unsigned long long)rlimit.rlim_cur); 3435 break; 3436 } 3437 switch (rlimit.rlim_max) { 3438 case RLIM64_INFINITY: 3439 (void) fputs(" max = RLIM64_INFINITY\n", stdout); 3440 break; 3441 case RLIM64_SAVED_MAX: 3442 (void) fputs(" max = RLIM64_SAVED_MAX\n", stdout); 3443 break; 3444 case RLIM64_SAVED_CUR: 3445 (void) fputs(" max = RLIM64_SAVED_CUR\n", stdout); 3446 break; 3447 default: 3448 (void) printf(" max = %llu\n", 3449 (unsigned long long)rlimit.rlim_max); 3450 break; 3451 } 3452 } 3453 } 3454 3455 void 3456 show_nuname(private_t *pri, long offset) 3457 { 3458 struct utsname ubuf; 3459 3460 if (offset != NULL && 3461 Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) { 3462 (void) printf( 3463 "%s\tsys=%s nod=%s rel=%s ver=%s mch=%s\n", 3464 pri->pname, 3465 ubuf.sysname, 3466 ubuf.nodename, 3467 ubuf.release, 3468 ubuf.version, 3469 ubuf.machine); 3470 } 3471 } 3472 3473 void 3474 show_adjtime(private_t *pri, long off1, long off2) 3475 { 3476 show_timeval(pri, off1, " delta"); 3477 show_timeval(pri, off2, "olddelta"); 3478 } 3479 3480 void 3481 show_sockaddr(private_t *pri, 3482 const char *str, long addroff, long lenoff, long len) 3483 { 3484 /* 3485 * A buffer large enough for PATH_MAX size AF_UNIX address, which is 3486 * also large enough to store a sockaddr_in or a sockaddr_in6. 3487 */ 3488 long buf[(sizeof (short) + PATH_MAX + sizeof (long) - 1) 3489 / sizeof (long)]; 3490 struct sockaddr *sa = (struct sockaddr *)buf; 3491 struct sockaddr_in *sin = (struct sockaddr_in *)buf; 3492 struct sockaddr_un *soun = (struct sockaddr_un *)buf; 3493 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)buf; 3494 char addrbuf[INET6_ADDRSTRLEN]; 3495 3496 if (lenoff != 0) { 3497 uint_t ilen; 3498 if (Pread(Proc, &ilen, sizeof (ilen), lenoff) != sizeof (ilen)) 3499 return; 3500 len = ilen; 3501 } 3502 3503 if (len >= sizeof (buf)) /* protect against ridiculous length */ 3504 len = sizeof (buf) - 1; 3505 if (Pread(Proc, buf, len, addroff) != len) 3506 return; 3507 3508 switch (sa->sa_family) { 3509 case AF_INET6: 3510 (void) printf("%s\tAF_INET6 %s = %s port = %u\n", 3511 pri->pname, str, 3512 inet_ntop(AF_INET6, &sin6->sin6_addr, addrbuf, 3513 sizeof (addrbuf)), 3514 ntohs(sin6->sin6_port)); 3515 (void) printf("%s\tscope id = %u source id = 0x%x\n" 3516 "%s\tflow class = 0x%02x flow label = 0x%05x\n", 3517 pri->pname, ntohl(sin6->sin6_scope_id), 3518 ntohl(sin6->__sin6_src_id), 3519 pri->pname, 3520 ntohl((sin6->sin6_flowinfo & IPV6_FLOWINFO_TCLASS) >> 20), 3521 ntohl(sin6->sin6_flowinfo & IPV6_FLOWINFO_FLOWLABEL)); 3522 break; 3523 case AF_INET: 3524 case AF_NCA: 3525 (void) printf("%s\tAF_%s %s = %s port = %u\n", 3526 pri->pname, sa->sa_family == AF_INET ? "INET" : "NCA", 3527 str, inet_ntop(AF_INET, &sin->sin_addr, addrbuf, 3528 sizeof (addrbuf)), ntohs(sin->sin_port)); 3529 break; 3530 case AF_UNIX: 3531 len -= sizeof (soun->sun_family); 3532 if (len >= 0) { 3533 /* Null terminate */ 3534 soun->sun_path[len] = NULL; 3535 (void) printf("%s\tAF_UNIX %s = %s\n", pri->pname, 3536 str, soun->sun_path); 3537 } 3538 break; 3539 } 3540 } 3541 3542 void 3543 show_msghdr(private_t *pri, long offset) 3544 { 3545 struct msghdr msg; 3546 3547 if (Pread(Proc, &msg, sizeof (msg), offset) != sizeof (msg)) 3548 return; 3549 if (msg.msg_name != NULL && msg.msg_namelen != 0) 3550 show_sockaddr(pri, "msg_name", 3551 (long)msg.msg_name, 0, (long)msg.msg_namelen); 3552 /* XXX add msg_iov printing */ 3553 } 3554 3555 #ifdef _LP64 3556 void 3557 show_msghdr32(private_t *pri, long offset) 3558 { 3559 struct msghdr32 { 3560 caddr32_t msg_name; 3561 int32_t msg_namelen; 3562 } msg; 3563 3564 if (Pread(Proc, &msg, sizeof (msg), offset) != sizeof (msg)) 3565 return; 3566 if (msg.msg_name != NULL && msg.msg_namelen != 0) 3567 show_sockaddr(pri, "msg_name", 3568 (long)msg.msg_name, 0, (long)msg.msg_namelen); 3569 /* XXX add msg_iov printing */ 3570 } 3571 #endif /* _LP64 */ 3572 3573 static void 3574 show_doorargs(private_t *pri, long offset) 3575 { 3576 door_arg_t args; 3577 3578 if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) { 3579 (void) printf("%s\tdata_ptr=0x%lX data_size=%lu\n", 3580 pri->pname, 3581 (ulong_t)args.data_ptr, 3582 (ulong_t)args.data_size); 3583 (void) printf("%s\tdesc_ptr=0x%lX desc_num=%u\n", 3584 pri->pname, 3585 (ulong_t)args.desc_ptr, 3586 args.desc_num); 3587 (void) printf("%s\trbuf=0x%lX rsize=%lu\n", 3588 pri->pname, 3589 (ulong_t)args.rbuf, 3590 (ulong_t)args.rsize); 3591 } 3592 } 3593 3594 static void 3595 show_ucred_privsets(private_t *pri, ucred_t *uc) 3596 { 3597 int i = 0; 3598 const priv_set_t *s; 3599 priv_ptype_t sn; 3600 char *str; 3601 3602 while ((sn = priv_getsetbynum(i++)) != NULL) { 3603 s = ucred_getprivset(uc, sn); 3604 3605 if (s == NULL) 3606 continue; 3607 3608 (void) printf("%s\t%c: %s\n", 3609 pri->pname, 3610 *sn, 3611 str = priv_set_to_str(s, ',', PRIV_STR_SHORT)); 3612 3613 free(str); 3614 } 3615 } 3616 3617 static void 3618 show_ucred(private_t *pri, long offset) 3619 { 3620 ucred_t *uc = _ucred_alloc(); 3621 size_t sz; 3622 3623 if (uc == NULL) 3624 return; 3625 3626 sz = Pread(Proc, uc, uc->uc_size, offset); 3627 3628 /* 3629 * A new uc_size is read, it could be smaller than the previously 3630 * value. We accept short reads that fill the whole header. 3631 */ 3632 if (sz >= sizeof (ucred_t) && sz >= uc->uc_size) { 3633 (void) printf("%s\teuid=%d egid=%d\n", 3634 pri->pname, 3635 (int)ucred_geteuid(uc), 3636 (int)ucred_getegid(uc)); 3637 (void) printf("%s\truid=%d rgid=%d\n", 3638 pri->pname, 3639 (int)ucred_getruid(uc), 3640 (int)ucred_getrgid(uc)); 3641 (void) printf("%s\tpid=%d zoneid=%d\n", 3642 pri->pname, 3643 (int)ucred_getpid(uc), 3644 (int)ucred_getzoneid(uc)); 3645 show_ucred_privsets(pri, uc); 3646 } 3647 ucred_free(uc); 3648 } 3649 3650 static void 3651 show_privset(private_t *pri, long offset, size_t size) 3652 { 3653 priv_set_t *tmp = priv_allocset(); 3654 size_t sz; 3655 3656 if (tmp == NULL) 3657 return; 3658 3659 sz = Pread(Proc, tmp, size, offset); 3660 3661 if (sz == size) { 3662 char *str = priv_set_to_str(tmp, ',', PRIV_STR_SHORT); 3663 if (str != NULL) { 3664 (void) printf("%s\t%s\n", pri->pname, str); 3665 free(str); 3666 } 3667 } 3668 priv_freeset(tmp); 3669 } 3670 3671 static void 3672 show_doorinfo(private_t *pri, long offset) 3673 { 3674 door_info_t info; 3675 door_attr_t attr; 3676 3677 if (Pread(Proc, &info, sizeof (info), offset) != sizeof (info)) 3678 return; 3679 (void) printf("%s\ttarget=%d proc=0x%llX data=0x%llX\n", 3680 pri->pname, 3681 (int)info.di_target, 3682 info.di_proc, 3683 info.di_data); 3684 attr = info.di_attributes; 3685 (void) printf("%s\tattributes=%s\n", pri->pname, door_flags(pri, attr)); 3686 (void) printf("%s\tuniquifier=%llu\n", pri->pname, info.di_uniquifier); 3687 } 3688 3689 static void 3690 show_doorparam(private_t *pri, long offset) 3691 { 3692 ulong_t val; 3693 3694 if (Pread(Proc, &val, sizeof (val), offset) == sizeof (val)) { 3695 (void) printf("%s\tvalue=%lu\n", 3696 pri->pname, 3697 val); 3698 } 3699 } 3700 3701 #ifdef _LP64 3702 3703 static void 3704 show_doorargs32(private_t *pri, long offset) 3705 { 3706 struct door_arg32 args; 3707 3708 if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) { 3709 (void) printf("%s\tdata_ptr=%X data_size=%u\n", 3710 pri->pname, 3711 args.data_ptr, 3712 args.data_size); 3713 (void) printf("%s\tdesc_ptr=0x%X desc_num=%u\n", 3714 pri->pname, 3715 args.desc_ptr, 3716 args.desc_num); 3717 (void) printf("%s\trbuf=0x%X rsize=%u\n", 3718 pri->pname, 3719 args.rbuf, 3720 args.rsize); 3721 } 3722 } 3723 3724 static void 3725 show_doorparam32(private_t *pri, long offset) 3726 { 3727 uint_t val; 3728 3729 if (Pread(Proc, &val, sizeof (val), offset) == sizeof (val)) { 3730 (void) printf("%s\tvalue=%u\n", 3731 pri->pname, 3732 val); 3733 } 3734 } 3735 3736 #endif /* _LP64 */ 3737 3738 static void 3739 show_doors(private_t *pri) 3740 { 3741 switch (pri->sys_args[5]) { 3742 case DOOR_CALL: 3743 #ifdef _LP64 3744 if (data_model == PR_MODEL_LP64) 3745 show_doorargs(pri, (long)pri->sys_args[1]); 3746 else 3747 show_doorargs32(pri, (long)pri->sys_args[1]); 3748 #else 3749 show_doorargs(pri, (long)pri->sys_args[1]); 3750 #endif 3751 break; 3752 case DOOR_UCRED: 3753 if (!pri->Errno) 3754 show_ucred(pri, (long)pri->sys_args[0]); 3755 break; 3756 case DOOR_INFO: 3757 if (!pri->Errno) 3758 show_doorinfo(pri, (long)pri->sys_args[1]); 3759 break; 3760 case DOOR_GETPARAM: 3761 if (!pri->Errno) { 3762 #ifdef _LP64 3763 if (data_model == PR_MODEL_LP64) 3764 show_doorparam(pri, (long)pri->sys_args[2]); 3765 else 3766 show_doorparam32(pri, (long)pri->sys_args[2]); 3767 #else 3768 show_doorparam(pri, (long)pri->sys_args[2]); 3769 #endif 3770 } 3771 break; 3772 } 3773 } 3774 3775 static void 3776 show_portargs(private_t *pri, long offset) 3777 { 3778 port_event_t args; 3779 3780 if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) { 3781 (void) printf("%s\tevents=0x%x source=%u\n", 3782 pri->pname, 3783 args.portev_events, 3784 args.portev_source); 3785 (void) printf("%s\tobject=0x%p user=0x%p\n", 3786 pri->pname, 3787 (void *)args.portev_object, 3788 (void *)args.portev_user); 3789 } 3790 } 3791 3792 3793 #ifdef _LP64 3794 3795 static void 3796 show_portargs32(private_t *pri, long offset) 3797 { 3798 port_event32_t args; 3799 3800 if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) { 3801 (void) printf("%s\tevents=0x%x source=%u\n", 3802 pri->pname, 3803 args.portev_events, 3804 args.portev_source); 3805 (void) printf("%s\tobject=0x%x user=0x%x\n", 3806 pri->pname, 3807 args.portev_object, 3808 args.portev_user); 3809 } 3810 } 3811 3812 #endif /* _LP64 */ 3813 3814 static void 3815 show_ports(private_t *pri) 3816 { 3817 switch (pri->sys_args[0]) { 3818 case PORT_GET: 3819 #ifdef _LP64 3820 if (data_model == PR_MODEL_LP64) 3821 show_portargs(pri, (long)pri->sys_args[2]); 3822 else 3823 show_portargs32(pri, (long)pri->sys_args[2]); 3824 #else 3825 show_portargs(pri, (long)pri->sys_args[2]); 3826 #endif 3827 break; 3828 } 3829 } 3830 3831 #define MAX_SNDFL_PRD 16 3832 3833 #ifdef _LP64 3834 3835 static void 3836 show_ksendfilevec32(private_t *pri, int fd, 3837 ksendfilevec32_t *sndvec, int sfvcnt) 3838 { 3839 ksendfilevec32_t *snd_ptr, snd[MAX_SNDFL_PRD]; 3840 size_t cpy_rqst; 3841 3842 Eserialize(); 3843 while (sfvcnt > 0) { 3844 cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD); 3845 sfvcnt -= cpy_rqst; 3846 cpy_rqst *= sizeof (snd[0]); 3847 3848 if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst) 3849 break; 3850 3851 snd_ptr = &snd[0]; 3852 3853 while (cpy_rqst) { 3854 (void) printf( 3855 "sfv_fd=%d\tsfv_flag=0x%x\t" 3856 "sfv_off=%d\tsfv_len=%u\n", 3857 snd_ptr->sfv_fd, 3858 snd_ptr->sfv_flag, 3859 snd_ptr->sfv_off, 3860 snd_ptr->sfv_len); 3861 3862 if (snd_ptr->sfv_fd == SFV_FD_SELF && 3863 prismember(&writefd, fd)) { 3864 showbuffer(pri, 3865 (long)snd_ptr->sfv_off & 0xffffffff, 3866 (long)snd_ptr->sfv_len); 3867 } 3868 3869 cpy_rqst -= sizeof (snd[0]); 3870 snd_ptr++; 3871 } 3872 3873 sndvec += MAX_SNDFL_PRD; 3874 } 3875 Xserialize(); 3876 } 3877 3878 static void 3879 show_ksendfilevec64(private_t *pri, int fd, 3880 ksendfilevec64_t *sndvec, int sfvcnt) 3881 { 3882 ksendfilevec64_t *snd_ptr, snd[MAX_SNDFL_PRD]; 3883 size_t cpy_rqst; 3884 3885 Eserialize(); 3886 while (sfvcnt > 0) { 3887 cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD); 3888 sfvcnt -= cpy_rqst; 3889 cpy_rqst *= sizeof (snd[0]); 3890 3891 if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst) 3892 break; 3893 3894 snd_ptr = &snd[0]; 3895 3896 while (cpy_rqst) { 3897 (void) printf( 3898 "sfv_fd=%d\tsfv_flag=0x%x\t" 3899 "sfv_off=%ld\tsfv_len=%u\n", 3900 snd_ptr->sfv_fd, 3901 snd_ptr->sfv_flag, 3902 snd_ptr->sfv_off, 3903 snd_ptr->sfv_len); 3904 3905 if (snd_ptr->sfv_fd == SFV_FD_SELF && 3906 prismember(&writefd, fd)) { 3907 showbuffer(pri, 3908 (long)snd_ptr->sfv_off & 0xffffffff, 3909 (long)snd_ptr->sfv_len); 3910 } 3911 3912 cpy_rqst -= sizeof (snd[0]); 3913 snd_ptr++; 3914 } 3915 3916 sndvec += MAX_SNDFL_PRD; 3917 } 3918 Xserialize(); 3919 } 3920 3921 #endif /* _LP64 */ 3922 3923 /*ARGSUSED*/ 3924 static void 3925 show_sendfilevec(private_t *pri, int fd, sendfilevec_t *sndvec, int sfvcnt) 3926 { 3927 sendfilevec_t *snd_ptr, snd[MAX_SNDFL_PRD]; 3928 size_t cpy_rqst; 3929 3930 #ifdef _LP64 3931 if (data_model != PR_MODEL_LP64) { 3932 show_ksendfilevec32(pri, fd, 3933 (ksendfilevec32_t *)sndvec, sfvcnt); 3934 return; 3935 } 3936 #endif 3937 Eserialize(); 3938 while (sfvcnt > 0) { 3939 cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD); 3940 sfvcnt -= cpy_rqst; 3941 cpy_rqst *= sizeof (snd[0]); 3942 3943 if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst) 3944 break; 3945 3946 snd_ptr = &snd[0]; 3947 3948 while (cpy_rqst) { 3949 (void) printf( 3950 "sfv_fd=%d\tsfv_flag=0x%x\t" 3951 "sfv_off=%ld\tsfv_len=%lu\n", 3952 snd_ptr->sfv_fd, 3953 snd_ptr->sfv_flag, 3954 snd_ptr->sfv_off, 3955 (ulong_t)snd_ptr->sfv_len); 3956 3957 if (snd_ptr->sfv_fd == SFV_FD_SELF && 3958 prismember(&writefd, fd)) { 3959 showbuffer(pri, (long)snd_ptr->sfv_off, 3960 (long)snd_ptr->sfv_len); 3961 } 3962 3963 cpy_rqst -= sizeof (snd[0]); 3964 snd_ptr++; 3965 } 3966 3967 sndvec += MAX_SNDFL_PRD; 3968 } 3969 Xserialize(); 3970 } 3971 3972 /*ARGSUSED*/ 3973 static void 3974 show_sendfilevec64(private_t *pri, int fd, sendfilevec64_t *sndvec, int sfvcnt) 3975 { 3976 sendfilevec64_t *snd_ptr, snd[MAX_SNDFL_PRD]; 3977 size_t cpy_rqst; 3978 3979 #ifdef _LP64 3980 if (data_model != PR_MODEL_LP64) { 3981 show_ksendfilevec64(pri, fd, 3982 (ksendfilevec64_t *)sndvec, sfvcnt); 3983 return; 3984 } 3985 #endif 3986 3987 Eserialize(); 3988 while (sfvcnt > 0) { 3989 cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD); 3990 sfvcnt -= cpy_rqst; 3991 cpy_rqst *= sizeof (snd[0]); 3992 3993 if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst) 3994 break; 3995 3996 snd_ptr = &snd[0]; 3997 3998 while (cpy_rqst) { 3999 (void) printf( 4000 #ifdef _LP64 4001 "sfv_fd=%d\tsfv_flag=0x%x\t" 4002 "sfv_off=%ld\tsfv_len=%lu\n", 4003 #else 4004 "sfv_fd=%d\tsfv_flag=0x%x\t" 4005 "sfv_off=%lld\tsfv_len=%lu\n", 4006 #endif 4007 snd_ptr->sfv_fd, 4008 snd_ptr->sfv_flag, 4009 snd_ptr->sfv_off, 4010 (ulong_t)snd_ptr->sfv_len); 4011 4012 if (snd_ptr->sfv_fd == SFV_FD_SELF && 4013 prismember(&writefd, fd)) { 4014 showbuffer(pri, (long)snd_ptr->sfv_off, 4015 (long)snd_ptr->sfv_len); 4016 } 4017 4018 cpy_rqst -= sizeof (snd[0]); 4019 snd_ptr++; 4020 } 4021 4022 sndvec += MAX_SNDFL_PRD; 4023 } 4024 Xserialize(); 4025 } 4026 4027 static void 4028 show_memcntl_mha(private_t *pri, long offset) 4029 { 4030 struct memcntl_mha mha; 4031 const char *s = NULL; 4032 4033 if (Pread(Proc, &mha, sizeof (mha), offset) == sizeof (mha)) { 4034 switch (mha.mha_cmd) { 4035 case MHA_MAPSIZE_VA: s = "MHA_MAPSIZE_VA"; break; 4036 case MHA_MAPSIZE_BSSBRK: s = "MHA_MAPSIZE_BSSBRK"; break; 4037 case MHA_MAPSIZE_STACK: s = "MHA_MAPSIZE_STACK"; break; 4038 } 4039 if (s) 4040 (void) printf("%s\tmha_cmd=%s mha_flags=0x%x" 4041 " mha_pagesize=%lu\n", 4042 pri->pname, s, mha.mha_flags, 4043 (ulong_t)mha.mha_pagesize); 4044 else 4045 (void) printf("%s\tmha_cmd=0x%.8x mha_flags=0x%x" 4046 " mha_pagesize=%lu\n", 4047 pri->pname, mha.mha_cmd, mha.mha_flags, 4048 (ulong_t)mha.mha_pagesize); 4049 } 4050 } 4051 4052 #ifdef _LP64 4053 4054 static void 4055 show_memcntl_mha32(private_t *pri, long offset) 4056 { 4057 struct memcntl_mha32 mha32; 4058 const char *s = NULL; 4059 4060 if (Pread(Proc, &mha32, sizeof (mha32), offset) == 4061 sizeof (mha32)) { 4062 switch (mha32.mha_cmd) { 4063 case MHA_MAPSIZE_VA: s = "MHA_MAPSIZE_VA"; break; 4064 case MHA_MAPSIZE_BSSBRK: s = "MHA_MAPSIZE_BSSBRK"; break; 4065 case MHA_MAPSIZE_STACK: s = "MHA_MAPSIZE_STACK"; break; 4066 } 4067 if (s) 4068 (void) printf("%s\tmha_cmd=%s mha_flags=0x%x" 4069 " mha_pagesize=%u\n", 4070 pri->pname, s, mha32.mha_flags, mha32.mha_pagesize); 4071 else 4072 (void) printf("%s\tmha_cmd=0x%.8x mha_flags=0x%x" 4073 " mha_pagesize=%u\n", 4074 pri->pname, mha32.mha_cmd, mha32.mha_flags, 4075 mha32.mha_pagesize); 4076 } 4077 } 4078 4079 #endif /* _LP64 */ 4080 4081 static void 4082 show_memcntl(private_t *pri) 4083 { 4084 4085 if ((int)pri->sys_args[2] != MC_HAT_ADVISE) 4086 return; 4087 #ifdef _LP64 4088 if (data_model == PR_MODEL_LP64) 4089 show_memcntl_mha(pri, (long)pri->sys_args[3]); 4090 else 4091 show_memcntl_mha32(pri, (long)pri->sys_args[3]); 4092 #else 4093 show_memcntl_mha(pri, (long)pri->sys_args[3]); 4094 #endif 4095 } 4096 4097 void 4098 show_ids(private_t *pri, long offset, int count) 4099 { 4100 id_t buf[MYBUFSIZ / sizeof (id_t)]; 4101 id_t *idp; 4102 int serial = (count > MYBUFSIZ / 48); 4103 4104 if (offset == NULL) 4105 return; 4106 4107 /* enter region of lengthy output */ 4108 if (serial) 4109 Eserialize(); 4110 4111 while (count > 0 && !interrupt) { 4112 ssize_t nb = (count * sizeof (id_t) < MYBUFSIZ)? 4113 count * sizeof (id_t) : MYBUFSIZ; 4114 4115 if ((nb = Pread(Proc, &buf[0], (size_t)nb, offset)) < 0 || 4116 nb < sizeof (id_t)) 4117 break; 4118 4119 idp = buf; 4120 while (!interrupt && nb >= sizeof (id_t)) { 4121 (void) printf("%s\t%8d\n", pri->pname, (int)*idp); 4122 offset += sizeof (id_t); 4123 nb -= sizeof (id_t); 4124 idp++; 4125 count--; 4126 } 4127 } 4128 4129 /* exit region of lengthy output */ 4130 if (serial) 4131 Xserialize(); 4132 } 4133 4134 void 4135 show_ntp_gettime(private_t *pri) 4136 { 4137 struct ntptimeval ntv; 4138 long offset; 4139 4140 if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == NULL) 4141 return; 4142 4143 if (data_model == PR_MODEL_NATIVE) { 4144 if (Pread(Proc, &ntv, sizeof (ntv), offset) 4145 != sizeof (ntv)) 4146 return; 4147 } else { 4148 struct ntptimeval32 ntv32; 4149 4150 if (Pread(Proc, &ntv32, sizeof (ntv32), offset) 4151 != sizeof (ntv32)) 4152 return; 4153 4154 TIMEVAL32_TO_TIMEVAL(&ntv.time, &ntv32.time); 4155 ntv.maxerror = ntv32.maxerror; 4156 ntv.esterror = ntv32.esterror; 4157 } 4158 4159 (void) printf("\ttime: %ld.%6.6ld sec\n", 4160 ntv.time.tv_sec, ntv.time.tv_usec); 4161 (void) printf("\tmaxerror: %11d usec\n", ntv.maxerror); 4162 (void) printf("\testerror: %11d usec\n", ntv.esterror); 4163 } 4164 4165 static char * 4166 get_timex_modes(private_t *pri, uint32_t val) 4167 { 4168 char *str = pri->code_buf; 4169 size_t used = 0; 4170 4171 *str = '\0'; 4172 if (val & MOD_OFFSET) 4173 used = strlcat(str, "|MOD_OFFSET", sizeof (pri->code_buf)); 4174 if (val & MOD_FREQUENCY) 4175 used = strlcat(str, "|MOD_FREQUENCY", sizeof (pri->code_buf)); 4176 if (val & MOD_MAXERROR) 4177 used = strlcat(str, "|MOD_MAXERROR", sizeof (pri->code_buf)); 4178 if (val & MOD_ESTERROR) 4179 used = strlcat(str, "|MOD_ESTERROR", sizeof (pri->code_buf)); 4180 if (val & MOD_STATUS) 4181 used = strlcat(str, "|MOD_STATUS", sizeof (pri->code_buf)); 4182 if (val & MOD_TIMECONST) 4183 used = strlcat(str, "|MOD_TIMECONST", sizeof (pri->code_buf)); 4184 if (val & MOD_CLKB) 4185 used = strlcat(str, "|MOD_CLKB", sizeof (pri->code_buf)); 4186 if (val & MOD_CLKA) 4187 used = strlcat(str, "|MOD_CLKA", sizeof (pri->code_buf)); 4188 4189 if (used == 0 || used >= sizeof (pri->code_buf)) 4190 (void) snprintf(str, sizeof (pri->code_buf), " 0x%.4x", val); 4191 4192 return (str + 1); 4193 } 4194 4195 static char * 4196 get_timex_status(private_t *pri, int32_t val) 4197 { 4198 char *str = pri->code_buf; 4199 size_t used = 0; 4200 4201 *str = '\0'; 4202 if (val & STA_PLL) 4203 used = strlcat(str, "|STA_PLL", sizeof (pri->code_buf)); 4204 if (val & STA_PPSFREQ) 4205 used = strlcat(str, "|STA_PPSFREQ", sizeof (pri->code_buf)); 4206 if (val & STA_PPSTIME) 4207 used = strlcat(str, "|STA_PPSTIME", sizeof (pri->code_buf)); 4208 if (val & STA_FLL) 4209 used = strlcat(str, "|STA_FLL", sizeof (pri->code_buf)); 4210 4211 if (val & STA_INS) 4212 used = strlcat(str, "|STA_INS", sizeof (pri->code_buf)); 4213 if (val & STA_DEL) 4214 used = strlcat(str, "|STA_DEL", sizeof (pri->code_buf)); 4215 if (val & STA_UNSYNC) 4216 used = strlcat(str, "|STA_UNSYNC", sizeof (pri->code_buf)); 4217 if (val & STA_FREQHOLD) 4218 used = strlcat(str, "|STA_FREQHOLD", sizeof (pri->code_buf)); 4219 4220 if (val & STA_PPSSIGNAL) 4221 used = strlcat(str, "|STA_PPSSIGNAL", sizeof (pri->code_buf)); 4222 if (val & STA_PPSJITTER) 4223 used = strlcat(str, "|STA_PPSJITTER", sizeof (pri->code_buf)); 4224 if (val & STA_PPSWANDER) 4225 used = strlcat(str, "|STA_PPSWANDER", sizeof (pri->code_buf)); 4226 if (val & STA_PPSERROR) 4227 used = strlcat(str, "|STA_PPSERROR", sizeof (pri->code_buf)); 4228 4229 if (val & STA_CLOCKERR) 4230 used = strlcat(str, "|STA_CLOCKERR", sizeof (pri->code_buf)); 4231 4232 if (used == 0 || used >= sizeof (pri->code_buf)) 4233 (void) snprintf(str, sizeof (pri->code_buf), " 0x%.4x", val); 4234 4235 return (str + 1); 4236 } 4237 4238 void 4239 show_ntp_adjtime(private_t *pri) 4240 { 4241 struct timex timex; 4242 long offset; 4243 4244 if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == NULL) 4245 return; 4246 4247 if (Pread(Proc, &timex, sizeof (timex), offset) != sizeof (timex)) 4248 return; 4249 4250 (void) printf("\tmodes: %s\n", get_timex_modes(pri, timex.modes)); 4251 (void) printf("\toffset: %11d usec\n", timex.offset); 4252 (void) printf("\tfreq: %11d scaled ppm\n", timex.freq); 4253 (void) printf("\tmaxerror: %11d usec\n", timex.maxerror); 4254 (void) printf("\testerror: %11d usec\n", timex.esterror); 4255 (void) printf("\tstatus: %s\n", get_timex_status(pri, timex.status)); 4256 (void) printf("\tconstant: %11d\n", timex.constant); 4257 (void) printf("\tprecision: %11d usec\n", timex.precision); 4258 (void) printf("\ttolerance: %11d scaled ppm\n", timex.tolerance); 4259 (void) printf("\tppsfreq: %11d scaled ppm\n", timex.ppsfreq); 4260 (void) printf("\tjitter: %11d usec\n", timex.jitter); 4261 (void) printf("\tshift: %11d sec\n", timex.shift); 4262 (void) printf("\tstabil: %11d scaled ppm\n", timex.stabil); 4263 (void) printf("\tjitcnt: %11d\n", timex.jitcnt); 4264 (void) printf("\tcalcnt: %11d\n", timex.calcnt); 4265 (void) printf("\terrcnt: %11d\n", timex.errcnt); 4266 (void) printf("\tstbcnt: %11d\n", timex.stbcnt); 4267 } 4268 4269 void 4270 show_getrusage(long offset) 4271 { 4272 struct rusage r; 4273 if (Pread(Proc, &r, sizeof (r), offset) != sizeof (r)) 4274 return; 4275 (void) printf("\t user time: %ld.%6.6ld sec\n", 4276 r.ru_utime.tv_sec, 4277 r.ru_utime.tv_usec); 4278 (void) printf("\t system time: %ld.%6.6ld sec\n", 4279 r.ru_stime.tv_sec, 4280 r.ru_stime.tv_usec); 4281 (void) printf("\t max rss: <unimpl> %ld\n", 4282 r.ru_maxrss); 4283 (void) printf("\t shared data: <unimpl> %ld\n", 4284 r.ru_ixrss); 4285 (void) printf("\t unshared data: <unimpl> %ld\n", 4286 r.ru_idrss); 4287 (void) printf("\t unshared stack: <unimpl> %ld\n", 4288 r.ru_isrss); 4289 (void) printf("\t minor faults: %ld\n", 4290 r.ru_minflt); 4291 (void) printf("\t major faults: %ld\n", 4292 r.ru_majflt); 4293 (void) printf("\t # of swaps: %ld\n", 4294 r.ru_nswap); 4295 (void) printf("\t blocked inputs: %ld\n", 4296 r.ru_inblock); 4297 (void) printf("\t blocked outputs: %ld\n", 4298 r.ru_oublock); 4299 (void) printf("\t msgs sent: %ld\n", 4300 r.ru_msgsnd); 4301 (void) printf("\t msgs rcv'd: %ld\n", 4302 r.ru_msgrcv); 4303 (void) printf("\t signals rcv'd: %ld\n", 4304 r.ru_nsignals); 4305 (void) printf("\tvol cntxt swtchs: %ld\n", 4306 r.ru_nvcsw); 4307 (void) printf("\tinv cntxt swtchs: %ld\n", 4308 r.ru_nivcsw); 4309 } 4310 4311 #ifdef _LP64 4312 void 4313 show_getrusage32(long offset) 4314 { 4315 struct rusage32 r; 4316 if (Pread(Proc, &r, sizeof (r), offset) != sizeof (r)) 4317 return; 4318 (void) printf("\t user time: %d.%6.6d sec\n", 4319 r.ru_utime.tv_sec, 4320 r.ru_utime.tv_usec); 4321 (void) printf("\t system time: %d.%6.6d sec\n", 4322 r.ru_stime.tv_sec, 4323 r.ru_stime.tv_usec); 4324 (void) printf("\t max rss: <unimpl> %d\n", 4325 r.ru_maxrss); 4326 (void) printf("\t shared data: <unimpl> %d\n", 4327 r.ru_ixrss); 4328 (void) printf("\t unshared data: <unimpl> %d\n", 4329 r.ru_idrss); 4330 (void) printf("\t unshared stack: <unimpl> %d\n", 4331 r.ru_isrss); 4332 (void) printf("\t minor faults: %d\n", 4333 r.ru_minflt); 4334 (void) printf("\t major faults: %d\n", 4335 r.ru_majflt); 4336 (void) printf("\t # of swaps: %d\n", 4337 r.ru_nswap); 4338 (void) printf("\t blocked inputs: %d\n", 4339 r.ru_inblock); 4340 (void) printf("\t blocked outputs: %d\n", 4341 r.ru_oublock); 4342 (void) printf("\t msgs sent: %d\n", 4343 r.ru_msgsnd); 4344 (void) printf("\t msgs rcv'd: %d\n", 4345 r.ru_msgrcv); 4346 (void) printf("\t signals rcv'd: %d\n", 4347 r.ru_nsignals); 4348 (void) printf("\tvol cntxt swtchs: %d\n", 4349 r.ru_nvcsw); 4350 (void) printf("\tinv cntxt swtchs: %d\n", 4351 r.ru_nivcsw); 4352 } 4353 #endif 4354 4355 /* expound verbosely upon syscall arguments */ 4356 /*ARGSUSED*/ 4357 void 4358 expound(private_t *pri, long r0, int raw) 4359 { 4360 const lwpstatus_t *Lsp = pri->lwpstat; 4361 int lp64 = (data_model == PR_MODEL_LP64); 4362 int what = Lsp->pr_what; 4363 int err = pri->Errno; /* don't display output parameters */ 4364 /* for a failed system call */ 4365 #ifndef _LP64 4366 /* We are a 32-bit truss; we can't grok a 64-bit process */ 4367 if (lp64) 4368 return; 4369 #endif 4370 /* for reporting sleeping system calls */ 4371 if (what == 0 && (Lsp->pr_flags & (PR_ASLEEP|PR_VFORKP))) 4372 what = Lsp->pr_syscall; 4373 4374 switch (what) { 4375 case SYS_utime: 4376 show_utime(pri); 4377 break; 4378 case SYS_utimes: 4379 show_utimes(pri); 4380 break; 4381 case SYS_gettimeofday: 4382 if (!err) 4383 show_timeofday(pri); 4384 break; 4385 case SYS_getitimer: 4386 if (!err && pri->sys_nargs > 1) 4387 show_itimerval(pri, (long)pri->sys_args[1], 4388 " value"); 4389 break; 4390 case SYS_setitimer: 4391 if (pri->sys_nargs > 1) 4392 show_itimerval(pri, (long)pri->sys_args[1], 4393 " value"); 4394 if (!err && pri->sys_nargs > 2) 4395 show_itimerval(pri, (long)pri->sys_args[2], 4396 "ovalue"); 4397 break; 4398 case SYS_stime: 4399 show_stime(pri); 4400 break; 4401 case SYS_times: 4402 if (!err) 4403 show_times(pri); 4404 break; 4405 case SYS_utssys: 4406 if (err) 4407 break; 4408 #ifdef _LP64 4409 if (lp64) 4410 show_utssys(pri, r0); 4411 else 4412 show_utssys32(pri, r0); 4413 #else 4414 show_utssys(pri, r0); 4415 #endif 4416 break; 4417 case SYS_ioctl: 4418 if (pri->sys_nargs >= 3) /* each case must decide for itself */ 4419 show_ioctl(pri, pri->sys_args[1], 4420 (long)pri->sys_args[2]); 4421 break; 4422 case SYS_stat: 4423 case SYS_fstat: 4424 case SYS_lstat: 4425 if (!err && pri->sys_nargs >= 2) 4426 show_stat(pri, (long)pri->sys_args[1]); 4427 break; 4428 case SYS_stat64: 4429 case SYS_fstat64: 4430 case SYS_lstat64: 4431 if (!err && pri->sys_nargs >= 2) 4432 show_stat64_32(pri, (long)pri->sys_args[1]); 4433 break; 4434 case SYS_fsat: 4435 /* 4436 * subcodes for fstatat() and fstatat64(). 4437 */ 4438 if (!err && pri->sys_nargs >= 4) { 4439 if (pri->sys_args[0] == 3) 4440 show_statat(pri, (long)pri->sys_args[3]); 4441 else if (pri->sys_args[0] == 2) 4442 show_stat64_32(pri, (long)pri->sys_args[3]); 4443 } 4444 break; 4445 case SYS_xstat: 4446 case SYS_fxstat: 4447 case SYS_lxstat: 4448 if (!err && pri->sys_nargs >= 3) 4449 show_xstat(pri, (int)pri->sys_args[0], 4450 (long)pri->sys_args[2]); 4451 break; 4452 case SYS_statvfs: 4453 case SYS_fstatvfs: 4454 if (err) 4455 break; 4456 #ifdef _LP64 4457 if (!lp64) { 4458 show_statvfs32(pri); 4459 break; 4460 } 4461 #endif 4462 show_statvfs(pri); 4463 break; 4464 case SYS_statvfs64: 4465 case SYS_fstatvfs64: 4466 if (err) 4467 break; 4468 show_statvfs64(pri); 4469 break; 4470 case SYS_statfs: 4471 case SYS_fstatfs: 4472 if (err) 4473 break; 4474 #ifdef _LP64 4475 if (lp64) 4476 show_statfs(pri); 4477 else 4478 show_statfs32(pri); 4479 #else 4480 show_statfs(pri); 4481 #endif 4482 break; 4483 case SYS_fcntl: 4484 show_fcntl(pri); 4485 break; 4486 case SYS_msgsys: 4487 show_msgsys(pri, r0); /* each case must decide for itself */ 4488 break; 4489 case SYS_semsys: 4490 show_semsys(pri); /* each case must decide for itself */ 4491 break; 4492 case SYS_shmsys: 4493 show_shmsys(pri); /* each case must decide for itself */ 4494 break; 4495 case SYS_getdents: 4496 if (err || pri->sys_nargs <= 1 || r0 <= 0) 4497 break; 4498 #ifdef _LP64 4499 if (!lp64) { 4500 show_dents32(pri, (long)pri->sys_args[1], r0); 4501 break; 4502 } 4503 /* FALLTHROUGH */ 4504 #else 4505 show_dents32(pri, (long)pri->sys_args[1], r0); 4506 break; 4507 #endif 4508 case SYS_getdents64: 4509 if (err || pri->sys_nargs <= 1 || r0 <= 0) 4510 break; 4511 show_dents64(pri, (long)pri->sys_args[1], r0); 4512 break; 4513 case SYS_getmsg: 4514 show_gp_msg(pri, what); 4515 if (pri->sys_nargs > 3) 4516 show_hhex_int(pri, (long)pri->sys_args[3], "flags"); 4517 break; 4518 case SYS_getpmsg: 4519 show_gp_msg(pri, what); 4520 if (pri->sys_nargs > 3) 4521 show_hhex_int(pri, (long)pri->sys_args[3], "band"); 4522 if (pri->sys_nargs > 4) 4523 show_hhex_int(pri, (long)pri->sys_args[4], "flags"); 4524 break; 4525 case SYS_putmsg: 4526 case SYS_putpmsg: 4527 show_gp_msg(pri, what); 4528 break; 4529 case SYS_poll: 4530 show_poll(pri); 4531 break; 4532 case SYS_pollsys: 4533 show_pollsys(pri); 4534 break; 4535 case SYS_setgroups: 4536 if (pri->sys_nargs > 1 && (r0 = pri->sys_args[0]) > 0) 4537 show_groups(pri, (long)pri->sys_args[1], r0); 4538 break; 4539 case SYS_getgroups: 4540 if (!err && pri->sys_nargs > 1 && pri->sys_args[0] > 0) 4541 show_groups(pri, (long)pri->sys_args[1], r0); 4542 break; 4543 case SYS_sigprocmask: 4544 if (pri->sys_nargs > 1) 4545 show_sigset(pri, (long)pri->sys_args[1], " set"); 4546 if (!err && pri->sys_nargs > 2) 4547 show_sigset(pri, (long)pri->sys_args[2], "oset"); 4548 break; 4549 case SYS_sigsuspend: 4550 case SYS_sigtimedwait: 4551 if (pri->sys_nargs > 0) 4552 show_sigset(pri, (long)pri->sys_args[0], "sigmask"); 4553 if (!err && pri->sys_nargs > 1) 4554 show_siginfo(pri, (long)pri->sys_args[1]); 4555 if (pri->sys_nargs > 2) 4556 show_timestruc(pri, (long)pri->sys_args[2], "timeout"); 4557 break; 4558 case SYS_sigaltstack: 4559 if (pri->sys_nargs > 0) 4560 show_sigaltstack(pri, (long)pri->sys_args[0], 4561 "new"); 4562 if (!err && pri->sys_nargs > 1) 4563 show_sigaltstack(pri, (long)pri->sys_args[1], 4564 "old"); 4565 break; 4566 case SYS_sigaction: 4567 if (pri->sys_nargs > 1) 4568 show_sigaction(pri, (long)pri->sys_args[1], 4569 "new", NULL); 4570 if (!err && pri->sys_nargs > 2) 4571 show_sigaction(pri, (long)pri->sys_args[2], 4572 "old", r0); 4573 break; 4574 case SYS_sigpending: 4575 if (!err && pri->sys_nargs > 1) 4576 show_sigset(pri, (long)pri->sys_args[1], "sigmask"); 4577 break; 4578 case SYS_waitsys: 4579 if (!err && pri->sys_nargs > 2) 4580 show_siginfo(pri, (long)pri->sys_args[2]); 4581 break; 4582 case SYS_sigsendsys: 4583 if (pri->sys_nargs > 0) 4584 show_procset(pri, (long)pri->sys_args[0]); 4585 break; 4586 case SYS_priocntlsys: 4587 if (pri->sys_nargs > 1) 4588 show_procset(pri, (long)pri->sys_args[1]); 4589 break; 4590 case SYS_mincore: 4591 if (!err && pri->sys_nargs > 2) 4592 show_bool(pri, (long)pri->sys_args[2], 4593 (pri->sys_args[1] + pagesize - 1) / pagesize); 4594 break; 4595 case SYS_readv: 4596 case SYS_writev: 4597 if (pri->sys_nargs > 2) { 4598 int i = pri->sys_args[0]+1; 4599 int showbuf = FALSE; 4600 long nb = (what == SYS_readv)? r0 : 32*1024; 4601 4602 if ((what == SYS_readv && !err && 4603 prismember(&readfd, i)) || 4604 (what == SYS_writev && 4605 prismember(&writefd, i))) 4606 showbuf = TRUE; 4607 show_iovec(pri, (long)pri->sys_args[1], 4608 pri->sys_args[2], showbuf, nb); 4609 } 4610 break; 4611 case SYS_getrlimit: 4612 if (err) 4613 break; 4614 /*FALLTHROUGH*/ 4615 case SYS_setrlimit: 4616 if (pri->sys_nargs <= 1) 4617 break; 4618 #ifdef _LP64 4619 if (lp64) 4620 show_rlimit64(pri, (long)pri->sys_args[1]); 4621 else 4622 show_rlimit32(pri, (long)pri->sys_args[1]); 4623 #else 4624 show_rlimit32(pri, (long)pri->sys_args[1]); 4625 #endif 4626 break; 4627 case SYS_getrlimit64: 4628 if (err) 4629 break; 4630 /*FALLTHROUGH*/ 4631 case SYS_setrlimit64: 4632 if (pri->sys_nargs <= 1) 4633 break; 4634 show_rlimit64(pri, (long)pri->sys_args[1]); 4635 break; 4636 case SYS_uname: 4637 if (!err && pri->sys_nargs > 0) 4638 show_nuname(pri, (long)pri->sys_args[0]); 4639 break; 4640 case SYS_adjtime: 4641 if (!err && pri->sys_nargs > 1) 4642 show_adjtime(pri, (long)pri->sys_args[0], 4643 (long)pri->sys_args[1]); 4644 break; 4645 case SYS_lwp_info: 4646 if (!err && pri->sys_nargs > 0) 4647 show_timestruc(pri, (long)pri->sys_args[0], "cpu time"); 4648 break; 4649 case SYS_lwp_wait: 4650 if (!err && pri->sys_nargs > 1) 4651 show_int(pri, (long)pri->sys_args[1], "lwpid"); 4652 break; 4653 case SYS_lwp_mutex_wakeup: 4654 case SYS_lwp_mutex_lock: 4655 case SYS_lwp_mutex_unlock: 4656 case SYS_lwp_mutex_trylock: 4657 case SYS_lwp_mutex_init: 4658 if (pri->sys_nargs > 0) 4659 show_mutex(pri, (long)pri->sys_args[0]); 4660 break; 4661 case SYS_lwp_mutex_timedlock: 4662 if (pri->sys_nargs > 0) 4663 show_mutex(pri, (long)pri->sys_args[0]); 4664 if (pri->sys_nargs > 1) 4665 show_timestruc(pri, (long)pri->sys_args[1], "timeout"); 4666 break; 4667 case SYS_lwp_cond_wait: 4668 if (pri->sys_nargs > 0) 4669 show_condvar(pri, (long)pri->sys_args[0]); 4670 if (pri->sys_nargs > 1) 4671 show_mutex(pri, (long)pri->sys_args[1]); 4672 if (pri->sys_nargs > 2) 4673 show_timestruc(pri, (long)pri->sys_args[2], "timeout"); 4674 break; 4675 case SYS_lwp_cond_signal: 4676 case SYS_lwp_cond_broadcast: 4677 if (pri->sys_nargs > 0) 4678 show_condvar(pri, (long)pri->sys_args[0]); 4679 break; 4680 case SYS_lwp_sema_wait: 4681 case SYS_lwp_sema_trywait: 4682 case SYS_lwp_sema_post: 4683 if (pri->sys_nargs > 0) 4684 show_sema(pri, (long)pri->sys_args[0]); 4685 break; 4686 case SYS_lwp_sema_timedwait: 4687 if (pri->sys_nargs > 0) 4688 show_sema(pri, (long)pri->sys_args[0]); 4689 if (pri->sys_nargs > 1) 4690 show_timestruc(pri, (long)pri->sys_args[1], "timeout"); 4691 break; 4692 case SYS_lwp_rwlock_sys: 4693 if (pri->sys_nargs > 1) 4694 show_rwlock(pri, (long)pri->sys_args[1]); 4695 if (pri->sys_nargs > 2 && 4696 (pri->sys_args[0] == 0 || pri->sys_args[0] == 1)) 4697 show_timestruc(pri, (long)pri->sys_args[2], "timeout"); 4698 break; 4699 case SYS_lwp_create: 4700 /* XXX print some values in ucontext ??? */ 4701 if (!err && pri->sys_nargs > 2) 4702 show_int(pri, (long)pri->sys_args[2], "lwpid"); 4703 break; 4704 case SYS_kaio: 4705 if (pri->sys_args[0] == AIOWAIT && !err && pri->sys_nargs > 1) 4706 show_timeval(pri, (long)pri->sys_args[1], "timeout"); 4707 break; 4708 case SYS_nanosleep: 4709 if (pri->sys_nargs > 0) 4710 show_timestruc(pri, (long)pri->sys_args[0], "tmout"); 4711 if (pri->sys_nargs > 1 && (err == 0 || err == EINTR)) 4712 show_timestruc(pri, (long)pri->sys_args[1], "resid"); 4713 break; 4714 case SYS_privsys: 4715 switch (pri->sys_args[0]) { 4716 case PRIVSYS_SETPPRIV: 4717 case PRIVSYS_GETPPRIV: 4718 if (!err) 4719 show_privset(pri, (long)pri->sys_args[3], 4720 (size_t)pri->sys_args[4]); 4721 } 4722 break; 4723 case SYS_ucredsys: 4724 switch (pri->sys_args[0]) { 4725 case UCREDSYS_UCREDGET: 4726 case UCREDSYS_GETPEERUCRED: 4727 if (err == 0) 4728 show_ucred(pri, (long)pri->sys_args[2]); 4729 break; 4730 } 4731 break; 4732 case SYS_bind: 4733 case SYS_connect: 4734 if (pri->sys_nargs > 2) 4735 show_sockaddr(pri, "name", (long)pri->sys_args[1], 4736 0, (long)pri->sys_args[2]); 4737 break; 4738 case SYS_sendto: 4739 if (pri->sys_nargs > 5) 4740 show_sockaddr(pri, "to", (long)pri->sys_args[4], 0, 4741 pri->sys_args[5]); 4742 break; 4743 case SYS_accept: 4744 if (!err && pri->sys_nargs > 2) 4745 show_sockaddr(pri, "name", (long)pri->sys_args[1], 4746 (long)pri->sys_args[2], 0); 4747 break; 4748 case SYS_getsockname: 4749 case SYS_getpeername: 4750 if (!err && pri->sys_nargs > 2) 4751 show_sockaddr(pri, "name", (long)pri->sys_args[1], 4752 (long)pri->sys_args[2], 0); 4753 break; 4754 case SYS_cladm: 4755 if (!err && pri->sys_nargs > 2) 4756 show_cladm(pri, pri->sys_args[0], pri->sys_args[1], 4757 (long)pri->sys_args[2]); 4758 break; 4759 case SYS_recvfrom: 4760 if (!err && pri->sys_nargs > 5) 4761 show_sockaddr(pri, "from", (long)pri->sys_args[4], 4762 (long)pri->sys_args[5], 0); 4763 break; 4764 case SYS_recvmsg: 4765 if (err) 4766 break; 4767 /* FALLTHROUGH */ 4768 case SYS_sendmsg: 4769 if (pri->sys_nargs <= 1) 4770 break; 4771 #ifdef _LP64 4772 if (lp64) 4773 show_msghdr(pri, pri->sys_args[1]); 4774 else 4775 show_msghdr32(pri, pri->sys_args[1]); 4776 #else 4777 show_msghdr(pri, pri->sys_args[1]); 4778 #endif 4779 break; 4780 case SYS_door: 4781 show_doors(pri); 4782 break; 4783 case SYS_sendfilev: 4784 if (pri->sys_nargs != 5) 4785 break; 4786 4787 if (pri->sys_args[0] == SENDFILEV) { 4788 show_sendfilevec(pri, (int)pri->sys_args[1], 4789 (sendfilevec_t *)pri->sys_args[2], 4790 (int)pri->sys_args[3]); 4791 } else if (pri->sys_args[0] == SENDFILEV64) { 4792 show_sendfilevec64(pri, (int)pri->sys_args[1], 4793 (sendfilevec64_t *)pri->sys_args[2], 4794 (int)pri->sys_args[3]); 4795 } 4796 break; 4797 case SYS_memcntl: 4798 show_memcntl(pri); 4799 break; 4800 case SYS_lwp_park: 4801 /* subcode 0: lwp_park(timespec_t *, id_t) */ 4802 if (pri->sys_nargs > 1 && pri->sys_args[0] == 0) 4803 show_timestruc(pri, (long)pri->sys_args[1], "timeout"); 4804 /* subcode 2: lwp_unpark_all(id_t *, int) */ 4805 if (pri->sys_nargs > 2 && pri->sys_args[0] == 2) 4806 show_ids(pri, (long)pri->sys_args[1], 4807 (int)pri->sys_args[2]); 4808 break; 4809 case SYS_ntp_gettime: 4810 if (!err) 4811 show_ntp_gettime(pri); 4812 break; 4813 case SYS_ntp_adjtime: 4814 if (!err) 4815 show_ntp_adjtime(pri); 4816 break; 4817 case SYS_rusagesys: 4818 if (!err) 4819 if (pri->sys_args[0] == _RUSAGESYS_GETRUSAGE) { 4820 #ifdef _LP64 4821 if (!lp64) 4822 show_getrusage32(pri->sys_args[1]); 4823 else 4824 #endif 4825 show_getrusage(pri->sys_args[1]); 4826 } 4827 break; 4828 case SYS_port: 4829 show_ports(pri); 4830 break; 4831 } 4832 } 4833