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