1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28 /* All Rights Reserved */ 29 30 31 #pragma ident "%Z%%M% %I% %E% SMI" 32 33 #define _SYSCALL32 /* make 32-bit compat headers visible */ 34 35 #include <stdio.h> 36 #include <stdlib.h> 37 #include <unistd.h> 38 #include <string.h> 39 #include <signal.h> 40 #include <termio.h> 41 #include <stddef.h> 42 #include <limits.h> 43 #include <ctype.h> 44 #include <sys/types.h> 45 #include <sys/mman.h> 46 #include <sys/resource.h> 47 #include <sys/ulimit.h> 48 #include <sys/utsname.h> 49 #include <sys/kstat.h> 50 #include <sys/modctl.h> 51 #include <sys/acl.h> 52 #include <stropts.h> 53 #include <sys/isa_defs.h> 54 #include <sys/systeminfo.h> 55 #include <sys/cladm.h> 56 #include <sys/lwp.h> 57 #include <bsm/audit.h> 58 #include <libproc.h> 59 #include <priv.h> 60 #include <sys/aio.h> 61 #include <sys/aiocb.h> 62 #include <sys/corectl.h> 63 #include <sys/cpc_impl.h> 64 #include <sys/priocntl.h> 65 #include <sys/tspriocntl.h> 66 #include <sys/iapriocntl.h> 67 #include <sys/rtpriocntl.h> 68 #include <sys/fsspriocntl.h> 69 #include <sys/fxpriocntl.h> 70 #include <netdb.h> 71 #include <nss_dbdefs.h> 72 #include <sys/socketvar.h> 73 #include <netinet/in.h> 74 #include <netinet/tcp.h> 75 #include <netinet/udp.h> 76 #include <netinet/sctp.h> 77 #include <sys/utrap.h> 78 #include <sys/lgrp_user.h> 79 #include <sys/door.h> 80 #include "ramdata.h" 81 #include "print.h" 82 #include "proto.h" 83 #include "systable.h" 84 85 void grow(private_t *, int nbyte); 86 87 #define GROW(nb) if (pri->sys_leng + (nb) >= pri->sys_ssize) grow(pri, (nb)) 88 89 90 /*ARGSUSED*/ 91 void 92 prt_nov(private_t *pri, int raw, long val) /* print nothing */ 93 { 94 } 95 96 /*ARGSUSED*/ 97 void 98 prt_dec(private_t *pri, int raw, long val) /* print as decimal */ 99 { 100 GROW(24); 101 if (data_model == PR_MODEL_ILP32) 102 pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng, 103 "%d", (int)val); 104 else 105 pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng, 106 "%ld", val); 107 } 108 109 /*ARGSUSED*/ 110 void 111 prt_uns(private_t *pri, int raw, long val) /* print as unsigned decimal */ 112 { 113 GROW(24); 114 if (data_model == PR_MODEL_ILP32) 115 pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng, 116 "%u", (int)val); 117 else 118 pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng, 119 "%lu", val); 120 } 121 122 /*ARGSUSED*/ 123 void 124 prt_oct(private_t *pri, int raw, long val) /* print as octal */ 125 { 126 GROW(24); 127 if (data_model == PR_MODEL_ILP32) 128 pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng, 129 "%#o", (int)val); 130 else 131 pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng, 132 "%#lo", val); 133 } 134 135 /*ARGSUSED*/ 136 void 137 prt_hex(private_t *pri, int raw, long val) /* print as hexadecimal */ 138 { 139 GROW(20); 140 if (data_model == PR_MODEL_ILP32) 141 pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng, 142 "0x%.8X", (int)val); 143 else 144 pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng, 145 "0x%.8lX", val); 146 } 147 148 /* print as hexadecimal (half size) */ 149 /*ARGSUSED*/ 150 void 151 prt_hhx(private_t *pri, int raw, long val) 152 { 153 GROW(20); 154 if (data_model == PR_MODEL_ILP32) 155 pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng, 156 "0x%.4X", (int)val); 157 else 158 pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng, 159 "0x%.4lX", val); 160 } 161 162 /* print as decimal if small, else hexadecimal */ 163 /*ARGSUSED*/ 164 void 165 prt_dex(private_t *pri, int raw, long val) 166 { 167 if (val & 0xff000000) 168 prt_hex(pri, 0, val); 169 else 170 prt_dec(pri, 0, val); 171 } 172 173 /* print long long offset */ 174 /*ARGSUSED*/ 175 void 176 prt_llo(private_t *pri, int raw, long val1, long val2) 177 { 178 int hival; 179 int loval; 180 181 #ifdef _LONG_LONG_LTOH 182 hival = (int)val2; 183 loval = (int)val1; 184 #else 185 hival = (int)val1; 186 loval = (int)val2; 187 #endif 188 189 if (hival == 0) 190 prt_dex(pri, 0, loval); 191 else { 192 GROW(18); 193 pri->sys_leng += 194 sprintf(pri->sys_string + pri->sys_leng, "0x%.8X%.8X", 195 hival, loval); 196 } 197 } 198 199 void 200 escape_string(private_t *pri, const char *s) 201 { 202 /* 203 * We want to avoid outputting unprintable characters that may 204 * destroy the user's terminal. So we do one pass to find any 205 * unprintable characters, size the array appropriately, and 206 * then walk each character by hand. Those that are unprintable 207 * are replaced by a hex escape (\xNN). We also escape quotes for 208 * completeness. 209 */ 210 int i, unprintable, quotes; 211 size_t len = strlen(s); 212 for (i = 0, unprintable = 0, quotes = 0; i < len; i++) { 213 if (!isprint(s[i])) 214 unprintable++; 215 if (s[i] == '"') 216 quotes++; 217 } 218 219 GROW(len + 3 * unprintable + quotes + 2); 220 221 pri->sys_string[pri->sys_leng++] = '"'; 222 for (i = 0; i < len; i++) { 223 if (s[i] == '"') 224 pri->sys_string[pri->sys_leng++] = '\\'; 225 226 if (isprint(s[i])) { 227 pri->sys_string[pri->sys_leng++] = s[i]; 228 } else { 229 pri->sys_leng += sprintf(pri->sys_string + 230 pri->sys_leng, "\\x%02x", s[i]); 231 } 232 } 233 pri->sys_string[pri->sys_leng++] = '"'; 234 } 235 236 void 237 prt_stg(private_t *pri, int raw, long val) /* print as string */ 238 { 239 char *s = raw? NULL : fetchstring(pri, (long)val, PATH_MAX); 240 241 if (s == NULL) 242 prt_hex(pri, 0, val); 243 else 244 escape_string(pri, s); 245 } 246 247 /* print as string returned from syscall */ 248 void 249 prt_rst(private_t *pri, int raw, long val) 250 { 251 char *s = (raw || pri->Errno)? NULL : 252 fetchstring(pri, (long)val, PATH_MAX); 253 254 if (s == NULL) 255 prt_hex(pri, 0, val); 256 else { 257 GROW((int)strlen(s) + 2); 258 pri->sys_leng += snprintf(pri->sys_string + pri->sys_leng, 259 pri->sys_ssize - pri->sys_leng, "\"%s\"", s); 260 } 261 } 262 263 /* print contents of readlink() buffer */ 264 void 265 prt_rlk(private_t *pri, int raw, long val) 266 { 267 char *s = (raw || pri->Errno || pri->Rval1 <= 0)? NULL : 268 fetchstring(pri, (long)val, 269 (pri->Rval1 > PATH_MAX)? PATH_MAX : (int)pri->Rval1); 270 271 if (s == NULL) 272 prt_hex(pri, 0, val); 273 else { 274 GROW((int)strlen(s) + 2); 275 pri->sys_leng += snprintf(pri->sys_string + pri->sys_leng, 276 pri->sys_ssize - pri->sys_leng, "\"%s\"", s); 277 } 278 } 279 280 void 281 prt_ioc(private_t *pri, int raw, long val) /* print ioctl code */ 282 { 283 const char *s = raw? NULL : ioctlname(pri, (int)val); 284 285 if (s == NULL) 286 prt_hex(pri, 0, val); 287 else 288 outstring(pri, s); 289 } 290 291 void 292 prt_ioa(private_t *pri, int raw, long val) /* print ioctl argument */ 293 { 294 const char *s; 295 296 /* cheating -- look at the ioctl() code */ 297 switch (pri->sys_args[1]) { 298 299 /* kstat ioctl()s */ 300 case KSTAT_IOC_READ: 301 case KSTAT_IOC_WRITE: 302 #ifdef _LP64 303 if (data_model == PR_MODEL_ILP32) 304 prt_stg(pri, raw, 305 val + offsetof(kstat32_t, ks_name[0])); 306 else 307 #endif 308 prt_stg(pri, raw, 309 val + offsetof(kstat_t, ks_name[0])); 310 break; 311 312 /* streams ioctl()s */ 313 case I_LOOK: 314 prt_rst(pri, raw, val); 315 break; 316 case I_PUSH: 317 case I_FIND: 318 prt_stg(pri, raw, val); 319 break; 320 case I_LINK: 321 case I_UNLINK: 322 case I_SENDFD: 323 prt_dec(pri, 0, val); 324 break; 325 case I_SRDOPT: 326 if (raw || (s = strrdopt(val)) == NULL) 327 prt_dec(pri, 0, val); 328 else 329 outstring(pri, s); 330 break; 331 case I_SETSIG: 332 if (raw || (s = strevents(pri, val)) == NULL) 333 prt_hex(pri, 0, val); 334 else 335 outstring(pri, s); 336 break; 337 case I_FLUSH: 338 if (raw || (s = strflush(val)) == NULL) 339 prt_dec(pri, 0, val); 340 else 341 outstring(pri, s); 342 break; 343 344 /* tty ioctl()s */ 345 case TCSBRK: 346 case TCXONC: 347 case TCFLSH: 348 case TCDSET: 349 prt_dec(pri, 0, val); 350 break; 351 352 default: 353 prt_hex(pri, 0, val); 354 break; 355 } 356 } 357 358 void 359 prt_fcn(private_t *pri, int raw, long val) /* print fcntl code */ 360 { 361 const char *s = raw? NULL : fcntlname(val); 362 363 if (s == NULL) 364 prt_dec(pri, 0, val); 365 else 366 outstring(pri, s); 367 } 368 369 void 370 prt_s86(private_t *pri, int raw, long val) /* print sysi86 code */ 371 { 372 373 const char *s = raw? NULL : si86name(val); 374 375 if (s == NULL) 376 prt_dec(pri, 0, val); 377 else 378 outstring(pri, s); 379 } 380 381 void 382 prt_uts(private_t *pri, int raw, long val) /* print utssys code */ 383 { 384 const char *s = raw? NULL : utscode(val); 385 386 if (s == NULL) 387 prt_dec(pri, 0, val); 388 else 389 outstring(pri, s); 390 } 391 392 void 393 prt_msc(private_t *pri, int raw, long val) /* print msgsys command */ 394 { 395 const char *s = raw? NULL : msgcmd(val); 396 397 if (s == NULL) 398 prt_dec(pri, 0, val); 399 else 400 outstring(pri, s); 401 } 402 403 void 404 prt_msf(private_t *pri, int raw, long val) /* print msgsys flags */ 405 { 406 const char *s = raw? NULL : msgflags(pri, (int)val); 407 408 if (s == NULL) 409 prt_oct(pri, 0, val); 410 else 411 outstring(pri, s); 412 } 413 414 void 415 prt_smc(private_t *pri, int raw, long val) /* print semsys command */ 416 { 417 const char *s = raw? NULL : semcmd(val); 418 419 if (s == NULL) 420 prt_dec(pri, 0, val); 421 else 422 outstring(pri, s); 423 } 424 425 void 426 prt_sef(private_t *pri, int raw, long val) /* print semsys flags */ 427 { 428 const char *s = raw? NULL : semflags(pri, (int)val); 429 430 if (s == NULL) 431 prt_oct(pri, 0, val); 432 else 433 outstring(pri, s); 434 } 435 436 void 437 prt_shc(private_t *pri, int raw, long val) /* print shmsys command */ 438 { 439 const char *s = raw? NULL : shmcmd(val); 440 441 if (s == NULL) 442 prt_dec(pri, 0, val); 443 else 444 outstring(pri, s); 445 } 446 447 void 448 prt_shf(private_t *pri, int raw, long val) /* print shmsys flags */ 449 { 450 const char *s = raw? NULL : shmflags(pri, (int)val); 451 452 if (s == NULL) 453 prt_oct(pri, 0, val); 454 else 455 outstring(pri, s); 456 } 457 458 void 459 prt_sfs(private_t *pri, int raw, long val) /* print sysfs code */ 460 { 461 const char *s = raw? NULL : sfsname(val); 462 463 if (s == NULL) 464 prt_dec(pri, 0, val); 465 else 466 outstring(pri, s); 467 } 468 469 void 470 prt_opn(private_t *pri, int raw, long val) /* print open code */ 471 { 472 const char *s = raw? NULL : openarg(pri, val); 473 474 if (s == NULL) 475 prt_oct(pri, 0, val); 476 else 477 outstring(pri, s); 478 } 479 480 void 481 prt_sig(private_t *pri, int raw, long val) /* print signal name plus flags */ 482 { 483 const char *s = raw? NULL : sigarg(pri, (int)val); 484 485 if (s == NULL) 486 prt_hex(pri, 0, val); 487 else 488 outstring(pri, s); 489 } 490 491 /* print signal name, masked with SIGNO_MASK */ 492 void 493 prt_six(private_t *pri, int raw, long val) 494 { 495 const char *s = raw? NULL : sigarg(pri, (int)val & SIGNO_MASK); 496 497 if (s == NULL) 498 prt_hex(pri, 0, val); 499 else 500 outstring(pri, s); 501 } 502 503 void 504 prt_act(private_t *pri, int raw, long val) /* print signal action value */ 505 { 506 const char *s; 507 508 if (raw) 509 s = NULL; 510 else if (val == (int)SIG_DFL) 511 s = "SIG_DFL"; 512 else if (val == (int)SIG_IGN) 513 s = "SIG_IGN"; 514 else if (val == (int)SIG_HOLD) 515 s = "SIG_HOLD"; 516 else 517 s = NULL; 518 519 if (s == NULL) 520 prt_hex(pri, 0, val); 521 else 522 outstring(pri, s); 523 } 524 525 void 526 prt_smf(private_t *pri, int raw, long val) /* print streams message flags */ 527 { 528 switch (val) { 529 case 0: 530 prt_dec(pri, 0, val); 531 break; 532 case RS_HIPRI: 533 if (raw) 534 prt_hhx(pri, 0, val); 535 else 536 outstring(pri, "RS_HIPRI"); 537 break; 538 default: 539 prt_hhx(pri, 0, val); 540 break; 541 } 542 } 543 544 void 545 prt_plk(private_t *pri, int raw, long val) /* print plock code */ 546 { 547 const char *s = raw? NULL : plockname(val); 548 549 if (s == NULL) 550 prt_dec(pri, 0, val); 551 else 552 outstring(pri, s); 553 } 554 555 void 556 prt_mtf(private_t *pri, int raw, long val) /* print mount flags */ 557 { 558 const char *s = raw? NULL : mountflags(pri, val); 559 560 if (s == NULL) 561 prt_hex(pri, 0, val); 562 else 563 outstring(pri, s); 564 } 565 566 void 567 prt_mft(private_t *pri, int raw, long val) /* print mount file system type */ 568 { 569 if (val >= 0 && val < 256) 570 prt_dec(pri, 0, val); 571 else if (raw) 572 prt_hex(pri, 0, val); 573 else 574 prt_stg(pri, raw, val); 575 } 576 577 #define ISREAD(code) \ 578 ((code) == SYS_read || (code) == SYS_pread || (code) == SYS_pread64 || \ 579 (code) == SYS_recv || (code) == SYS_recvfrom) 580 #define ISWRITE(code) \ 581 ((code) == SYS_write || (code) == SYS_pwrite || \ 582 (code) == SYS_pwrite64 || (code) == SYS_send || (code) == SYS_sendto) 583 584 /* print contents of read() or write() I/O buffer */ 585 void 586 prt_iob(private_t *pri, int raw, long val) 587 { 588 const lwpstatus_t *Lsp = pri->lwpstat; 589 int syscall = Lsp->pr_what; 590 int fdp1 = pri->sys_args[0] + 1; 591 ssize_t nbyte = ISWRITE(syscall)? pri->sys_args[2] : 592 (pri->Errno? 0 : pri->Rval1); 593 int elsewhere = FALSE; /* TRUE iff dumped elsewhere */ 594 char buffer[IOBSIZE]; 595 596 pri->iob_buf[0] = '\0'; 597 598 if (Lsp->pr_why == PR_SYSEXIT && nbyte > IOBSIZE) { 599 if (ISREAD(syscall)) 600 elsewhere = prismember(&readfd, fdp1); 601 else 602 elsewhere = prismember(&writefd, fdp1); 603 } 604 605 if (nbyte <= 0 || elsewhere) 606 prt_hex(pri, 0, val); 607 else { 608 int nb = nbyte > IOBSIZE? IOBSIZE : (int)nbyte; 609 610 if (Pread(Proc, buffer, (size_t)nb, (long)val) != nb) 611 prt_hex(pri, 0, val); 612 else { 613 pri->iob_buf[0] = '"'; 614 showbytes(buffer, nb, pri->iob_buf + 1); 615 (void) strlcat(pri->iob_buf, 616 (nb == nbyte)? 617 (const char *)"\"" : (const char *)"\"..", 618 sizeof (pri->iob_buf)); 619 if (raw) 620 prt_hex(pri, 0, val); 621 else 622 outstring(pri, pri->iob_buf); 623 } 624 } 625 } 626 #undef ISREAD 627 #undef ISWRITE 628 629 void 630 prt_idt(private_t *pri, int raw, long val) /* print idtype_t, waitid() arg */ 631 { 632 const char *s = raw? NULL : idtype_enum(pri, val); 633 634 if (s == NULL) 635 prt_dec(pri, 0, val); 636 else 637 outstring(pri, s); 638 } 639 640 void 641 prt_wop(private_t *pri, int raw, long val) /* print waitid() options */ 642 { 643 const char *s = raw? NULL : woptions(pri, (int)val); 644 645 if (s == NULL) 646 prt_oct(pri, 0, val); 647 else 648 outstring(pri, s); 649 } 650 651 void 652 prt_whn(private_t *pri, int raw, long val) /* print lseek() whence argument */ 653 { 654 const char *s = raw? NULL : whencearg(val); 655 656 if (s == NULL) 657 prt_dec(pri, 0, val); 658 else 659 outstring(pri, s); 660 } 661 662 /*ARGSUSED*/ 663 void 664 prt_spm(private_t *pri, int raw, long val) /* print sigprocmask argument */ 665 { 666 const char *s = NULL; 667 668 if (!raw) { 669 switch (val) { 670 case SIG_BLOCK: s = "SIG_BLOCK"; break; 671 case SIG_UNBLOCK: s = "SIG_UNBLOCK"; break; 672 case SIG_SETMASK: s = "SIG_SETMASK"; break; 673 } 674 } 675 676 if (s == NULL) 677 prt_dec(pri, 0, val); 678 else 679 outstring(pri, s); 680 } 681 682 const char * 683 mmap_protect(private_t *pri, long arg) 684 { 685 char *str = pri->code_buf; 686 687 if (arg & ~(PROT_READ|PROT_WRITE|PROT_EXEC)) 688 return ((char *)NULL); 689 690 if (arg == PROT_NONE) 691 return ("PROT_NONE"); 692 693 *str = '\0'; 694 if (arg & PROT_READ) 695 (void) strlcat(str, "|PROT_READ", sizeof (pri->code_buf)); 696 if (arg & PROT_WRITE) 697 (void) strlcat(str, "|PROT_WRITE", sizeof (pri->code_buf)); 698 if (arg & PROT_EXEC) 699 (void) strlcat(str, "|PROT_EXEC", sizeof (pri->code_buf)); 700 return ((const char *)(str + 1)); 701 } 702 703 const char * 704 mmap_type(private_t *pri, long arg) 705 { 706 char *str = pri->code_buf; 707 size_t used; 708 709 #define CBSIZE sizeof (pri->code_buf) 710 switch (arg & MAP_TYPE) { 711 case MAP_SHARED: 712 used = strlcpy(str, "MAP_SHARED", CBSIZE); 713 break; 714 case MAP_PRIVATE: 715 used = strlcpy(str, "MAP_PRIVATE", CBSIZE); 716 break; 717 default: 718 used = snprintf(str, CBSIZE, "%ld", arg&MAP_TYPE); 719 break; 720 } 721 722 arg &= ~(_MAP_NEW|MAP_TYPE); 723 724 if (arg & ~(MAP_FIXED|MAP_RENAME|MAP_NORESERVE|MAP_ANON|MAP_ALIGN| 725 MAP_TEXT|MAP_INITDATA)) 726 (void) snprintf(str + used, sizeof (pri->code_buf) - used, 727 "|0x%lX", arg); 728 else { 729 if (arg & MAP_FIXED) 730 (void) strlcat(str, "|MAP_FIXED", CBSIZE); 731 if (arg & MAP_RENAME) 732 (void) strlcat(str, "|MAP_RENAME", CBSIZE); 733 if (arg & MAP_NORESERVE) 734 (void) strlcat(str, "|MAP_NORESERVE", CBSIZE); 735 if (arg & MAP_ANON) 736 (void) strlcat(str, "|MAP_ANON", CBSIZE); 737 if (arg & MAP_ALIGN) 738 (void) strlcat(str, "|MAP_ALIGN", CBSIZE); 739 if (arg & MAP_TEXT) 740 (void) strlcat(str, "|MAP_TEXT", CBSIZE); 741 if (arg & MAP_INITDATA) 742 (void) strlcat(str, "|MAP_INITDATA", CBSIZE); 743 } 744 745 return ((const char *)str); 746 #undef CBSIZE 747 } 748 749 void 750 prt_mpr(private_t *pri, int raw, long val) /* print mmap()/mprotect() flags */ 751 { 752 const char *s = raw? NULL : mmap_protect(pri, val); 753 754 if (s == NULL) 755 prt_hhx(pri, 0, val); 756 else 757 outstring(pri, s); 758 } 759 760 void 761 prt_mty(private_t *pri, int raw, long val) /* print mmap() mapping type flags */ 762 { 763 const char *s = raw? NULL : mmap_type(pri, val); 764 765 if (s == NULL) 766 prt_hhx(pri, 0, val); 767 else 768 outstring(pri, s); 769 } 770 771 /*ARGSUSED*/ 772 void 773 prt_mcf(private_t *pri, int raw, long val) /* print memcntl() function */ 774 { 775 const char *s = NULL; 776 777 if (!raw) { 778 switch (val) { 779 case MC_SYNC: s = "MC_SYNC"; break; 780 case MC_LOCK: s = "MC_LOCK"; break; 781 case MC_UNLOCK: s = "MC_UNLOCK"; break; 782 case MC_ADVISE: s = "MC_ADVISE"; break; 783 case MC_LOCKAS: s = "MC_LOCKAS"; break; 784 case MC_UNLOCKAS: s = "MC_UNLOCKAS"; break; 785 case MC_HAT_ADVISE: s = "MC_HAT_ADVISE"; break; 786 } 787 } 788 789 if (s == NULL) 790 prt_dec(pri, 0, val); 791 else 792 outstring(pri, s); 793 } 794 795 void 796 prt_mad(private_t *pri, int raw, long val) /* print madvise() argument */ 797 { 798 const char *s = NULL; 799 800 if (!raw) { 801 switch (val) { 802 case MADV_NORMAL: s = "MADV_NORMAL"; break; 803 case MADV_RANDOM: s = "MADV_RANDOM"; break; 804 case MADV_SEQUENTIAL: s = "MADV_SEQUENTIAL"; break; 805 case MADV_WILLNEED: s = "MADV_WILLNEED"; break; 806 case MADV_DONTNEED: s = "MADV_DONTNEED"; break; 807 case MADV_FREE: s = "MADV_FREE"; break; 808 case MADV_ACCESS_DEFAULT: s = "MADV_ACCESS_DEFAULT"; break; 809 case MADV_ACCESS_LWP: s = "MADV_ACCESS_LWP"; break; 810 case MADV_ACCESS_MANY: s = "MADV_ACCESS_MANY"; break; 811 } 812 } 813 814 if (s == NULL) 815 prt_dec(pri, 0, val); 816 else 817 outstring(pri, s); 818 } 819 820 void 821 prt_mc4(private_t *pri, int raw, long val) /* print memcntl() (4th) argument */ 822 { 823 if (val == 0) 824 prt_dec(pri, 0, val); 825 else if (raw) 826 prt_hhx(pri, 0, val); 827 else { 828 char *s = NULL; 829 830 #define CBSIZE sizeof (pri->code_buf) 831 /* cheating -- look at memcntl func */ 832 switch (pri->sys_args[2]) { 833 case MC_ADVISE: 834 prt_mad(pri, 0, val); 835 return; 836 837 case MC_SYNC: 838 if ((val & ~(MS_SYNC|MS_ASYNC|MS_INVALIDATE)) == 0) { 839 *(s = pri->code_buf) = '\0'; 840 if (val & MS_SYNC) 841 (void) strlcat(s, "|MS_SYNC", CBSIZE); 842 if (val & MS_ASYNC) 843 (void) strlcat(s, "|MS_ASYNC", CBSIZE); 844 if (val & MS_INVALIDATE) 845 (void) strlcat(s, "|MS_INVALIDATE", 846 CBSIZE); 847 } 848 break; 849 850 case MC_LOCKAS: 851 case MC_UNLOCKAS: 852 if ((val & ~(MCL_CURRENT|MCL_FUTURE)) == 0) { 853 *(s = pri->code_buf) = '\0'; 854 if (val & MCL_CURRENT) 855 (void) strlcat(s, "|MCL_CURRENT", 856 CBSIZE); 857 if (val & MCL_FUTURE) 858 (void) strlcat(s, "|MCL_FUTURE", 859 CBSIZE); 860 } 861 break; 862 } 863 #undef CBSIZE 864 865 if (s == NULL || *s == '\0') 866 prt_hhx(pri, 0, val); 867 else 868 outstring(pri, ++s); 869 } 870 } 871 872 void 873 prt_mc5(private_t *pri, int raw, long val) /* print memcntl() (5th) argument */ 874 { 875 char *s; 876 877 #define CBSIZE sizeof (pri->code_buf) 878 if (val == 0) 879 prt_dec(pri, 0, val); 880 else if (raw || (val & ~VALID_ATTR)) 881 prt_hhx(pri, 0, val); 882 else { 883 s = pri->code_buf; 884 *s = '\0'; 885 if (val & SHARED) 886 (void) strlcat(s, "|SHARED", CBSIZE); 887 if (val & PRIVATE) 888 (void) strlcat(s, "|PRIVATE", CBSIZE); 889 if (val & PROT_READ) 890 (void) strlcat(s, "|PROT_READ", CBSIZE); 891 if (val & PROT_WRITE) 892 (void) strlcat(s, "|PROT_WRITE", CBSIZE); 893 if (val & PROT_EXEC) 894 (void) strlcat(s, "|PROT_EXEC", CBSIZE); 895 if (*s == '\0') 896 prt_hhx(pri, 0, val); 897 else 898 outstring(pri, ++s); 899 } 900 #undef CBSIZE 901 } 902 903 void 904 prt_ulm(private_t *pri, int raw, long val) /* print ulimit() argument */ 905 { 906 const char *s = NULL; 907 908 if (!raw) { 909 switch (val) { 910 case UL_GFILLIM: s = "UL_GFILLIM"; break; 911 case UL_SFILLIM: s = "UL_SFILLIM"; break; 912 case UL_GMEMLIM: s = "UL_GMEMLIM"; break; 913 case UL_GDESLIM: s = "UL_GDESLIM"; break; 914 } 915 } 916 917 if (s == NULL) 918 prt_dec(pri, 0, val); 919 else 920 outstring(pri, s); 921 } 922 923 void 924 prt_rlm(private_t *pri, int raw, long val) /* print get/setrlimit() argument */ 925 { 926 const char *s = NULL; 927 928 if (!raw) { 929 switch (val) { 930 case RLIMIT_CPU: s = "RLIMIT_CPU"; break; 931 case RLIMIT_FSIZE: s = "RLIMIT_FSIZE"; break; 932 case RLIMIT_DATA: s = "RLIMIT_DATA"; break; 933 case RLIMIT_STACK: s = "RLIMIT_STACK"; break; 934 case RLIMIT_CORE: s = "RLIMIT_CORE"; break; 935 case RLIMIT_NOFILE: s = "RLIMIT_NOFILE"; break; 936 case RLIMIT_VMEM: s = "RLIMIT_VMEM"; break; 937 } 938 } 939 940 if (s == NULL) 941 prt_dec(pri, 0, val); 942 else 943 outstring(pri, s); 944 } 945 946 void 947 prt_cnf(private_t *pri, int raw, long val) /* print sysconfig code */ 948 { 949 const char *s = raw? NULL : sconfname(val); 950 951 if (s == NULL) 952 prt_dec(pri, 0, val); 953 else 954 outstring(pri, s); 955 } 956 957 void 958 prt_inf(private_t *pri, int raw, long val) /* print sysinfo code */ 959 { 960 const char *s = NULL; 961 962 if (!raw) { 963 switch (val) { 964 case SI_SYSNAME: s = "SI_SYSNAME"; break; 965 case SI_HOSTNAME: s = "SI_HOSTNAME"; break; 966 case SI_RELEASE: s = "SI_RELEASE"; break; 967 case SI_VERSION: s = "SI_VERSION"; break; 968 case SI_MACHINE: s = "SI_MACHINE"; break; 969 case SI_ARCHITECTURE: s = "SI_ARCHITECTURE"; break; 970 case SI_ARCHITECTURE_32:s = "SI_ARCHITECTURE_32"; break; 971 case SI_ARCHITECTURE_64:s = "SI_ARCHITECTURE_64"; break; 972 case SI_ARCHITECTURE_K: s = "SI_ARCHITECTURE_K"; break; 973 case SI_HW_SERIAL: s = "SI_HW_SERIAL"; break; 974 case SI_HW_PROVIDER: s = "SI_HW_PROVIDER"; break; 975 case SI_SRPC_DOMAIN: s = "SI_SRPC_DOMAIN"; break; 976 case SI_SET_HOSTNAME: s = "SI_SET_HOSTNAME"; break; 977 case SI_SET_SRPC_DOMAIN: s = "SI_SET_SRPC_DOMAIN"; break; 978 case SI_PLATFORM: s = "SI_PLATFORM"; break; 979 case SI_ISALIST: s = "SI_ISALIST"; break; 980 case SI_DHCP_CACHE: s = "SI_DHCP_CACHE"; break; 981 } 982 } 983 984 if (s == NULL) 985 prt_dec(pri, 0, val); 986 else 987 outstring(pri, s); 988 } 989 990 void 991 prt_ptc(private_t *pri, int raw, long val) /* print pathconf code */ 992 { 993 const char *s = raw? NULL : pathconfname(val); 994 995 if (s == NULL) 996 prt_dec(pri, 0, val); 997 else 998 outstring(pri, s); 999 } 1000 1001 void 1002 prt_fui(private_t *pri, int raw, long val) /* print fusers() input argument */ 1003 { 1004 const char *s = raw? NULL : fuiname(val); 1005 1006 if (s == NULL) 1007 prt_hhx(pri, 0, val); 1008 else 1009 outstring(pri, s); 1010 } 1011 1012 void 1013 prt_lwf(private_t *pri, int raw, long val) /* print lwp_create() flags */ 1014 { 1015 char *s; 1016 1017 if (val == 0) 1018 prt_dec(pri, 0, val); 1019 else if (raw || 1020 (val & ~(LWP_DAEMON|LWP_DETACHED|LWP_SUSPENDED))) 1021 prt_hhx(pri, 0, val); 1022 else { 1023 #define CBSIZE sizeof (pri->code_buf) 1024 s = pri->code_buf; 1025 *s = '\0'; 1026 if (val & LWP_DAEMON) 1027 (void) strlcat(s, "|LWP_DAEMON", CBSIZE); 1028 if (val & LWP_DETACHED) 1029 (void) strlcat(s, "|LWP_DETACHED", CBSIZE); 1030 if (val & LWP_SUSPENDED) 1031 (void) strlcat(s, "|LWP_SUSPENDED", CBSIZE); 1032 outstring(pri, ++s); 1033 #undef CBSIZE 1034 } 1035 } 1036 1037 void 1038 prt_itm(private_t *pri, int raw, long val) /* print [get|set]itimer() arg */ 1039 { 1040 const char *s = NULL; 1041 1042 if (!raw) { 1043 switch (val) { 1044 case ITIMER_REAL: s = "ITIMER_REAL"; break; 1045 case ITIMER_VIRTUAL: s = "ITIMER_VIRTUAL"; break; 1046 case ITIMER_PROF: s = "ITIMER_PROF"; break; 1047 #ifdef ITIMER_REALPROF 1048 case ITIMER_REALPROF: s = "ITIMER_REALPROF"; break; 1049 #endif 1050 } 1051 } 1052 1053 if (s == NULL) 1054 prt_dec(pri, 0, val); 1055 else 1056 outstring(pri, s); 1057 } 1058 1059 void 1060 prt_mod(private_t *pri, int raw, long val) /* print modctl() code */ 1061 { 1062 const char *s = NULL; 1063 1064 if (!raw) { 1065 switch (val) { 1066 case MODLOAD: s = "MODLOAD"; break; 1067 case MODUNLOAD: s = "MODUNLOAD"; break; 1068 case MODINFO: s = "MODINFO"; break; 1069 case MODRESERVED: s = "MODRESERVED"; break; 1070 case MODSETMINIROOT: s = "MODSETMINIROOT"; break; 1071 case MODADDMAJBIND: s = "MODADDMAJBIND"; break; 1072 case MODGETPATH: s = "MODGETPATH"; break; 1073 case MODGETPATHLEN: s = "MODGETPATHLEN"; break; 1074 case MODREADSYSBIND: s = "MODREADSYSBIND"; break; 1075 case MODGETMAJBIND: s = "MODGETMAJBIND"; break; 1076 case MODGETNAME: s = "MODGETNAME"; break; 1077 case MODSIZEOF_DEVID: s = "MODSIZEOF_DEVID"; break; 1078 case MODGETDEVID: s = "MODGETDEVID"; break; 1079 case MODSIZEOF_MINORNAME: s = "MODSIZEOF_MINORNAME"; break; 1080 case MODGETMINORNAME: s = "MODGETMINORNAME"; break; 1081 case MODGETFBNAME: s = "MODGETFBNAME"; break; 1082 case MODEVENTS: s = "MODEVENTS"; break; 1083 case MODREREADDACF: s = "MODREREADDACF"; break; 1084 case MODLOADDRVCONF: s = "MODLOADDRVCONF"; break; 1085 case MODUNLOADDRVCONF: s = "MODUNLOADDRVCONF"; break; 1086 case MODREMMAJBIND: s = "MODREMMAJBIND"; break; 1087 case MODDEVT2INSTANCE: s = "MODDEVT2INSTANCE"; break; 1088 case MODGETDEVFSPATH_LEN: s = "MODGETDEVFSPATH_LEN"; break; 1089 case MODGETDEVFSPATH: s = "MODGETDEVFSPATH"; break; 1090 case MODDEVID2PATHS: s = "MODDEVID2PATHS"; break; 1091 case MODSETDEVPOLICY: s = "MODSETDEVPOLICY"; break; 1092 case MODGETDEVPOLICY: s = "MODGETDEVPOLICY"; break; 1093 case MODALLOCPRIV: s = "MODALLOCPRIV"; break; 1094 case MODGETDEVPOLICYBYNAME: 1095 s = "MODGETDEVPOLICYBYNAME"; break; 1096 case MODCLEANUP: s = "MODCLEANUP"; break; 1097 case MODLOADMINORPERM: s = "MODLOADMINORPERM"; break; 1098 case MODADDMINORPERM: s = "MODADDMINORPERM"; break; 1099 case MODREMMINORPERM: s = "MODREMMINORPERM"; break; 1100 case MODREMDRVCLEANUP: s = "MODREMDRVCLEANUP"; break; 1101 } 1102 } 1103 1104 if (s == NULL) 1105 prt_dec(pri, 0, val); 1106 else 1107 outstring(pri, s); 1108 } 1109 1110 void 1111 prt_acl(private_t *pri, int raw, long val) /* print acl() code */ 1112 { 1113 const char *s = NULL; 1114 1115 if (!raw) { 1116 switch (val) { 1117 case GETACL: s = "GETACL"; break; 1118 case SETACL: s = "SETACL"; break; 1119 case GETACLCNT: s = "GETACLCNT"; break; 1120 } 1121 } 1122 1123 if (s == NULL) 1124 prt_dec(pri, 0, val); 1125 else 1126 outstring(pri, s); 1127 } 1128 1129 void 1130 prt_aio(private_t *pri, int raw, long val) /* print kaio() code */ 1131 { 1132 const char *s = NULL; 1133 char buf[32]; 1134 1135 if (!raw) { 1136 switch (val & ~AIO_POLL_BIT) { 1137 case AIOREAD: s = "AIOREAD"; break; 1138 case AIOWRITE: s = "AIOWRITE"; break; 1139 case AIOWAIT: s = "AIOWAIT"; break; 1140 case AIOCANCEL: s = "AIOCANCEL"; break; 1141 case AIONOTIFY: s = "AIONOTIFY"; break; 1142 case AIOINIT: s = "AIOINIT"; break; 1143 case AIOSTART: s = "AIOSTART"; break; 1144 case AIOLIO: s = "AIOLIO"; break; 1145 case AIOSUSPEND: s = "AIOSUSPEND"; break; 1146 case AIOERROR: s = "AIOERROR"; break; 1147 case AIOLIOWAIT: s = "AIOLIOWAIT"; break; 1148 case AIOAREAD: s = "AIOAREAD"; break; 1149 case AIOAWRITE: s = "AIOAWRITE"; break; 1150 /* 1151 * We have to hardcode the values for the 64-bit versions of 1152 * these calls, because <sys/aio.h> defines them to be identical 1153 * when compiled 64-bit. If our target is 32-bit, we still need 1154 * to decode them correctly. 1155 */ 1156 case 13: s = "AIOLIO64"; break; 1157 case 14: s = "AIOSUSPEND64"; break; 1158 case 15: s = "AUIOERROR64"; break; 1159 case 16: s = "AIOLIOWAIT64"; break; 1160 case 17: s = "AIOAREAD64"; break; 1161 case 18: s = "AIOAWRITE64"; break; 1162 case 19: s = "AIOCANCEL64"; break; 1163 1164 /* 1165 * AIOFSYNC doesn't correspond to a syscall. 1166 */ 1167 case AIOWAITN: s = "AIOWAITN"; break; 1168 } 1169 if (s != NULL && (val & AIO_POLL_BIT)) { 1170 (void) strlcpy(buf, s, sizeof (buf)); 1171 (void) strlcat(buf, "|AIO_POLL_BIT", sizeof (buf)); 1172 s = (const char *)buf; 1173 } 1174 } 1175 1176 if (s == NULL) 1177 prt_dec(pri, 0, val); 1178 else 1179 outstring(pri, s); 1180 } 1181 1182 void 1183 prt_aud(private_t *pri, int raw, long val) /* print auditsys() code */ 1184 { 1185 const char *s = NULL; 1186 1187 if (!raw) { 1188 switch (val) { 1189 case BSM_GETAUID: s = "BSM_GETAUID"; break; 1190 case BSM_SETAUID: s = "BSM_SETAUID"; break; 1191 case BSM_GETAUDIT: s = "BSM_GETAUDIT"; break; 1192 case BSM_SETAUDIT: s = "BSM_SETAUDIT"; break; 1193 case BSM_GETUSERAUDIT: s = "BSM_GETUSERAUDIT"; break; 1194 case BSM_SETUSERAUDIT: s = "BSM_SETUSERAUDIT"; break; 1195 case BSM_AUDIT: s = "BSM_AUDIT"; break; 1196 case BSM_AUDITUSER: s = "BSM_AUDITUSER"; break; 1197 case BSM_AUDITSVC: s = "BSM_AUDITSVC"; break; 1198 case BSM_AUDITON: s = "BSM_AUDITON"; break; 1199 case BSM_AUDITCTL: s = "BSM_AUDITCTL"; break; 1200 case BSM_GETKERNSTATE: s = "BSM_GETKERNSTATE"; break; 1201 case BSM_SETKERNSTATE: s = "BSM_SETKERNSTATE"; break; 1202 case BSM_GETPORTAUDIT: s = "BSM_GETPORTAUDIT"; break; 1203 case BSM_REVOKE: s = "BSM_REVOKE"; break; 1204 case BSM_AUDITSTAT: s = "BSM_AUDITSTAT"; break; 1205 case BSM_GETAUDIT_ADDR: s = "BSM_GETAUDIT_ADDR"; break; 1206 case BSM_SETAUDIT_ADDR: s = "BSM_SETAUDIT_ADDR"; break; 1207 } 1208 } 1209 1210 if (s == NULL) 1211 prt_dec(pri, 0, val); 1212 else 1213 outstring(pri, s); 1214 } 1215 1216 void 1217 prt_cor(private_t *pri, int raw, long val) /* print corectl() subcode */ 1218 { 1219 const char *s = NULL; 1220 1221 if (!raw) { 1222 switch (val) { 1223 case CC_SET_OPTIONS: 1224 s = "CC_SET_OPTIONS"; break; 1225 case CC_GET_OPTIONS: 1226 s = "CC_GET_OPTIONS"; break; 1227 case CC_SET_GLOBAL_PATH: 1228 s = "CC_SET_GLOBAL_PATH"; break; 1229 case CC_GET_GLOBAL_PATH: 1230 s = "CC_GET_GLOBAL_PATH"; break; 1231 case CC_SET_PROCESS_PATH: 1232 s = "CC_SET_PROCESS_PATH"; break; 1233 case CC_GET_PROCESS_PATH: 1234 s = "CC_GET_PROCESS_PATH"; break; 1235 case CC_SET_GLOBAL_CONTENT: 1236 s = "CC_SET_GLOBAL_CONTENT"; break; 1237 case CC_GET_GLOBAL_CONTENT: 1238 s = "CC_GET_GLOBAL_CONTENT"; break; 1239 case CC_SET_PROCESS_CONTENT: 1240 s = "CC_SET_PROCESS_CONTENT"; break; 1241 case CC_GET_PROCESS_CONTENT: 1242 s = "CC_GET_PROCESS_CONTENT"; break; 1243 case CC_SET_DEFAULT_PATH: 1244 s = "CC_SET_DEFAULT_PATH"; break; 1245 case CC_GET_DEFAULT_PATH: 1246 s = "CC_GET_DEFAULT_PATH"; break; 1247 case CC_SET_DEFAULT_CONTENT: 1248 s = "CC_SET_DEFAULT_CONTENT"; break; 1249 case CC_GET_DEFAULT_CONTENT: 1250 s = "CC_GET_DEFAULT_CONTENT"; break; 1251 } 1252 } 1253 1254 if (s == NULL) 1255 prt_dec(pri, 0, val); 1256 else 1257 outstring(pri, s); 1258 } 1259 1260 void 1261 prt_cco(private_t *pri, int raw, long val) /* print corectl() options */ 1262 { 1263 char *s; 1264 1265 if (val == 0) 1266 prt_dec(pri, 0, val); 1267 else if (raw || (val & ~CC_OPTIONS)) 1268 prt_hhx(pri, 0, val); 1269 else { 1270 #define CBSIZE sizeof (pri->code_buf) 1271 s = pri->code_buf; 1272 *s = '\0'; 1273 if (val & CC_GLOBAL_PATH) 1274 (void) strlcat(s, "|CC_GLOBAL_PATH", CBSIZE); 1275 if (val & CC_PROCESS_PATH) 1276 (void) strlcat(s, "|CC_PROCESS_PATH", CBSIZE); 1277 if (val & CC_GLOBAL_SETID) 1278 (void) strlcat(s, "|CC_GLOBAL_SETID", CBSIZE); 1279 if (val & CC_PROCESS_SETID) 1280 (void) strlcat(s, "|CC_PROCESS_SETID", CBSIZE); 1281 if (val & CC_GLOBAL_LOG) 1282 (void) strlcat(s, "|CC_GLOBAL_LOG", CBSIZE); 1283 if (*s == '\0') 1284 prt_hhx(pri, 0, val); 1285 else 1286 outstring(pri, ++s); 1287 #undef CBSIZE 1288 } 1289 } 1290 1291 void 1292 prt_ccc(private_t *pri, int raw, long val) /* print corectl() content */ 1293 { 1294 core_content_t ccc; 1295 1296 if (Pread(Proc, &ccc, sizeof (ccc), val) != sizeof (ccc)) 1297 prt_hex(pri, 0, val); 1298 else if (!raw && proc_content2str(ccc, pri->code_buf, 1299 sizeof (pri->code_buf)) >= 0) 1300 outstring(pri, pri->code_buf); 1301 else 1302 prt_hhx(pri, 0, (long)ccc); 1303 } 1304 1305 void 1306 prt_rcc(private_t *pri, int raw, long val) /* print corectl() ret. cont. */ 1307 { 1308 core_content_t ccc; 1309 1310 if (pri->Errno || Pread(Proc, &ccc, sizeof (ccc), val) != sizeof (ccc)) 1311 prt_hex(pri, 0, val); 1312 else if (!raw && proc_content2str(ccc, pri->code_buf, 1313 sizeof (pri->code_buf)) >= 0) 1314 outstring(pri, pri->code_buf); 1315 else 1316 prt_hhx(pri, 0, (long)ccc); 1317 } 1318 1319 void 1320 prt_cpc(private_t *pri, int raw, long val) /* print cpc() subcode */ 1321 { 1322 const char *s = NULL; 1323 1324 if (!raw) { 1325 switch (val) { 1326 case CPC_BIND: s = "CPC_BIND"; break; 1327 case CPC_SAMPLE: s = "CPC_SAMPLE"; break; 1328 case CPC_INVALIDATE: s = "CPC_INVALIDATE"; break; 1329 case CPC_RELE: s = "CPC_RELE"; break; 1330 case CPC_EVLIST_SIZE: s = "CPC_EVLIST_SIZE"; break; 1331 case CPC_LIST_EVENTS: s = "CPC_LIST_EVENTS"; break; 1332 case CPC_ATTRLIST_SIZE: s = "CPC_ATTRLIST_SIZE"; break; 1333 case CPC_LIST_ATTRS: s = "CPC_LIST_ATTRS"; break; 1334 case CPC_IMPL_NAME: s = "CPC_IMPL_NAME"; break; 1335 case CPC_CPUREF: s = "CPC_CPUREF"; break; 1336 case CPC_USR_EVENTS: s = "CPC_USR_EVENTS"; break; 1337 case CPC_SYS_EVENTS: s = "CPC_SYS_EVENTS"; break; 1338 case CPC_NPIC: s = "CPC_NPIC"; break; 1339 case CPC_CAPS: s = "CPC_CAPS"; break; 1340 case CPC_ENABLE: s = "CPC_ENABLE"; break; 1341 case CPC_DISABLE: s = "CPC_DISABLE"; break; 1342 } 1343 } 1344 1345 if (s == NULL) 1346 prt_dec(pri, 0, val); 1347 else 1348 outstring(pri, s); 1349 } 1350 1351 void 1352 outstring(private_t *pri, const char *s) 1353 { 1354 int len = strlen(s); 1355 1356 GROW(len); 1357 (void) strcpy(pri->sys_string + pri->sys_leng, s); 1358 pri->sys_leng += len; 1359 } 1360 1361 void 1362 grow(private_t *pri, int nbyte) /* reallocate format buffer if necessary */ 1363 { 1364 while (pri->sys_leng + nbyte >= pri->sys_ssize) 1365 pri->sys_string = my_realloc(pri->sys_string, 1366 pri->sys_ssize *= 2, "format buffer"); 1367 } 1368 1369 void 1370 prt_clc(private_t *pri, int raw, long val) 1371 { 1372 const char *s = NULL; 1373 1374 if (!raw) { 1375 switch (val) { 1376 case CL_INITIALIZE: s = "CL_INITIALIZE"; break; 1377 case CL_CONFIG: s = "CL_CONFIG"; break; 1378 } 1379 } 1380 1381 if (s == NULL) 1382 prt_dec(pri, 0, val); 1383 else 1384 outstring(pri, s); 1385 } 1386 1387 void 1388 prt_clf(private_t *pri, int raw, long val) 1389 { 1390 const char *s = NULL; 1391 1392 if (!raw) { 1393 switch (pri->sys_args[0]) { 1394 case CL_CONFIG: 1395 switch (pri->sys_args[1]) { 1396 case CL_NODEID: 1397 s = "CL_NODEID"; break; 1398 case CL_HIGHEST_NODEID: 1399 s = "CL_HIGHEST_NODEID"; break; 1400 } 1401 break; 1402 case CL_INITIALIZE: 1403 switch (pri->sys_args[1]) { 1404 case CL_GET_BOOTFLAG: 1405 s = "CL_GET_BOOTFLAG"; break; 1406 } 1407 break; 1408 } 1409 } 1410 1411 if (s == NULL) 1412 prt_dec(pri, 0, val); 1413 else 1414 outstring(pri, s); 1415 } 1416 1417 void 1418 prt_sqc(private_t *pri, int raw, long val) /* print sigqueue() si_code */ 1419 { 1420 const char *s = NULL; 1421 1422 if (!raw) { 1423 switch ((int)val) { 1424 case SI_QUEUE: s = "SI_QUEUE"; break; 1425 case SI_TIMER: s = "SI_TIMER"; break; 1426 case SI_ASYNCIO: s = "SI_ASYNCIO"; break; 1427 case SI_MESGQ: s = "SI_MESGQ"; break; 1428 } 1429 } 1430 1431 if (s == NULL) 1432 prt_dec(pri, 0, val); 1433 else 1434 outstring(pri, s); 1435 } 1436 1437 /* 1438 * print priocntlsys() (key, value) pair key. 1439 */ 1440 void 1441 print_pck(private_t *pri, int raw, long val) 1442 { 1443 const char *s = NULL; 1444 char clname[PC_CLNMSZ]; 1445 1446 if ((pri->sys_args[2] != PC_GETXPARMS && 1447 pri->sys_args[2] != PC_SETXPARMS) || val == 0 || raw) { 1448 prt_dec(pri, 0, val); 1449 return; 1450 } 1451 1452 if (pri->sys_args[3] == NULL) { 1453 if (val == PC_KY_CLNAME) { 1454 s = "PC_KY_CLNAME"; 1455 outstring(pri, s); 1456 } else 1457 prt_dec(pri, 0, val); 1458 return; 1459 } 1460 1461 if (Pread(Proc, &clname, PC_CLNMSZ, pri->sys_args[3]) != PC_CLNMSZ) { 1462 prt_dec(pri, 0, val); 1463 return; 1464 } 1465 1466 if (strcmp(clname, "TS") == 0) { 1467 switch (val) { 1468 case TS_KY_UPRILIM: s = "TS_KY_UPRILIM"; break; 1469 case TS_KY_UPRI: s = "TS_KY_UPRI"; break; 1470 default: break; 1471 } 1472 } else if (strcmp(clname, "IA") == 0) { 1473 switch (val) { 1474 case IA_KY_UPRILIM: s = "IA_KY_UPRILIM"; break; 1475 case IA_KY_UPRI: s = "IA_KY_UPRI"; break; 1476 case IA_KY_MODE: s = "IA_KY_MODE"; break; 1477 default: break; 1478 } 1479 } else if (strcmp(clname, "RT") == 0) { 1480 switch (val) { 1481 case RT_KY_PRI: s = "RT_KY_PRI"; break; 1482 case RT_KY_TQSECS: s = "RT_KY_TQSECS"; break; 1483 case RT_KY_TQNSECS: s = "RT_KY_TQNSECS"; break; 1484 case RT_KY_TQSIG: s = "RT_KY_TQSIG"; break; 1485 default: break; 1486 } 1487 } else if (strcmp(clname, "FSS") == 0) { 1488 switch (val) { 1489 case FSS_KY_UPRILIM: s = "FSS_KY_UPRILIM"; break; 1490 case FSS_KY_UPRI: s = "FSS_KY_UPRI"; break; 1491 default: break; 1492 } 1493 } else if (strcmp(clname, "FX") == 0) { 1494 switch (val) { 1495 case FX_KY_UPRILIM: s = "FX_KY_UPRILIM"; break; 1496 case FX_KY_UPRI: s = "FX_KY_UPRI"; break; 1497 case FX_KY_TQSECS: s = "FX_KY_TQSECS"; break; 1498 case FX_KY_TQNSECS: s = "FX_KY_TQNSECS"; break; 1499 default: break; 1500 } 1501 } 1502 1503 if (s == NULL) 1504 prt_dec(pri, 0, val); 1505 else 1506 outstring(pri, s); 1507 } 1508 1509 /* 1510 * print priocntlsys() fourth argument. 1511 */ 1512 /*ARGSUSED*/ 1513 void 1514 prt_pc4(private_t *pri, int raw, long val) 1515 { 1516 /* look at pricntlsys function */ 1517 if ((pri->sys_args[2] != PC_GETXPARMS && 1518 pri->sys_args[2] != PC_SETXPARMS)) 1519 prt_hex(pri, 0, val); 1520 else if (val) 1521 prt_stg(pri, 0, val); 1522 else 1523 prt_dec(pri, 0, val); 1524 } 1525 1526 /* 1527 * print priocntlsys() (key, value) pairs (5th argument). 1528 */ 1529 /*ARGSUSED*/ 1530 void 1531 prt_pc5(private_t *pri, int raw, long val) 1532 { 1533 pc_vaparms_t prms; 1534 pc_vaparm_t *vpp = &prms.pc_parms[0]; 1535 uint_t cnt; 1536 1537 1538 /* look at pricntlsys function */ 1539 if ((pri->sys_args[2] != PC_GETXPARMS && 1540 pri->sys_args[2] != PC_SETXPARMS) || val == 0) { 1541 prt_dec(pri, 0, 0); 1542 return; 1543 } 1544 1545 if (Pread(Proc, &prms, sizeof (prms), val) != sizeof (prms)) { 1546 prt_hex(pri, 0, val); 1547 return; 1548 } 1549 1550 if ((cnt = prms.pc_vaparmscnt) > PC_VAPARMCNT) 1551 return; 1552 1553 for (; cnt--; vpp++) { 1554 print_pck(pri, 0, vpp->pc_key); 1555 outstring(pri, ", "); 1556 prt_hex(pri, 0, (long)vpp->pc_parm); 1557 outstring(pri, ", "); 1558 } 1559 1560 prt_dec(pri, 0, PC_KY_NULL); 1561 } 1562 1563 /* 1564 * Print processor set id, including logical expansion of "special" ids. 1565 */ 1566 void 1567 prt_pst(private_t *pri, int raw, long val) 1568 { 1569 const char *s = NULL; 1570 1571 if (!raw) { 1572 switch ((psetid_t)val) { 1573 case PS_NONE: s = "PS_NONE"; break; 1574 case PS_QUERY: s = "PS_QUERY"; break; 1575 case PS_MYID: s = "PS_MYID"; break; 1576 } 1577 } 1578 1579 if (s == NULL) 1580 prt_dec(pri, 0, val); 1581 else 1582 outstring(pri, s); 1583 } 1584 1585 /* 1586 * Print meminfo() argument. 1587 */ 1588 /*ARGSUSED*/ 1589 void 1590 prt_mif(private_t *pri, int raw, long val) 1591 { 1592 struct meminfo minfo; 1593 1594 #ifdef _LP64 1595 if (data_model == PR_MODEL_ILP32) { 1596 struct meminfo32 minfo32; 1597 1598 if (Pread(Proc, &minfo32, sizeof (struct meminfo32), val) != 1599 sizeof (struct meminfo32)) { 1600 prt_dec(pri, 0, pri->sys_args[1]); /* addr_count */ 1601 outstring(pri, ", "); 1602 prt_hex(pri, 0, val); 1603 return; 1604 } 1605 /* 1606 * arrange the arguments in the order that user calls with 1607 */ 1608 prt_hex(pri, 0, minfo32.mi_inaddr); 1609 outstring(pri, ", "); 1610 prt_dec(pri, 0, pri->sys_args[1]); /* addr_count */ 1611 outstring(pri, ", "); 1612 prt_hex(pri, 0, minfo32.mi_info_req); 1613 outstring(pri, ", "); 1614 prt_dec(pri, 0, minfo32.mi_info_count); 1615 outstring(pri, ", "); 1616 prt_hex(pri, 0, minfo32.mi_outdata); 1617 outstring(pri, ", "); 1618 prt_hex(pri, 0, minfo32.mi_validity); 1619 return; 1620 } 1621 #endif 1622 if (Pread(Proc, &minfo, sizeof (struct meminfo), val) != 1623 sizeof (struct meminfo)) { 1624 prt_dec(pri, 0, pri->sys_args[1]); /* addr_count */ 1625 outstring(pri, ", "); 1626 prt_hex(pri, 0, val); 1627 return; 1628 } 1629 /* 1630 * arrange the arguments in the order that user calls with 1631 */ 1632 prt_hex(pri, 0, (long)minfo.mi_inaddr); 1633 outstring(pri, ", "); 1634 prt_dec(pri, 0, pri->sys_args[1]); /* addr_count */ 1635 outstring(pri, ", "); 1636 prt_hex(pri, 0, (long)minfo.mi_info_req); 1637 outstring(pri, ", "); 1638 prt_dec(pri, 0, minfo.mi_info_count); 1639 outstring(pri, ", "); 1640 prt_hex(pri, 0, (long)minfo.mi_outdata); 1641 outstring(pri, ", "); 1642 prt_hex(pri, 0, (long)minfo.mi_validity); 1643 } 1644 1645 1646 /* 1647 * Print so_socket() 1st argument. 1648 */ 1649 /*ARGSUSED*/ 1650 void 1651 prt_pfm(private_t *pri, int raw, long val) 1652 { 1653 /* Protocol Families have same names as Address Families */ 1654 if ((ulong_t)val < MAX_AFCODES) { 1655 outstring(pri, "PF_"); 1656 outstring(pri, afcodes[val]); 1657 } else { 1658 prt_dec(pri, 0, val); 1659 } 1660 } 1661 1662 1663 /* 1664 * Print so_socket() 2nd argument. 1665 */ 1666 /*ARGSUSED*/ 1667 void 1668 prt_skt(private_t *pri, int raw, long val) 1669 { 1670 const char *s; 1671 1672 if ((ulong_t)val <= MAX_SOCKTYPES && (s = socktype_codes[val]) != NULL) 1673 outstring(pri, s); 1674 else 1675 prt_dec(pri, 0, val); 1676 } 1677 1678 1679 /* 1680 * Print so_socket() 3rd argument. 1681 */ 1682 /*ARGSUSED*/ 1683 void 1684 prt_skp(private_t *pri, int raw, long val) 1685 { 1686 const char *s; 1687 1688 /* cheating -- look at the protocol-family */ 1689 switch (pri->sys_args[0]) { 1690 case PF_INET6: 1691 case PF_INET: 1692 case PF_NCA: if ((s = ipprotos((int)val)) != NULL) { 1693 outstring(pri, s); 1694 break; 1695 } 1696 /* FALLTHROUGH */ 1697 default: prt_dec(pri, 0, val); 1698 break; 1699 } 1700 } 1701 1702 1703 /* 1704 * Print so_socket() 5th argument. 1705 */ 1706 /*ARGSUSED*/ 1707 void 1708 prt_skv(private_t *pri, int raw, long val) 1709 { 1710 switch (val) { 1711 case SOV_STREAM: outstring(pri, "SOV_STREAM"); break; 1712 case SOV_DEFAULT: outstring(pri, "SOV_DEFAULT"); break; 1713 case SOV_SOCKSTREAM: outstring(pri, "SOV_SOCKSTREAM"); break; 1714 case SOV_SOCKBSD: outstring(pri, "SOV_SOCKBSD"); break; 1715 case SOV_XPG4_2: outstring(pri, "SOV_XPG4_2"); break; 1716 default: prt_dec(pri, 0, val); break; 1717 } 1718 } 1719 1720 1721 /* 1722 * Print setsockopt()/getsockopt() 2nd argument. 1723 */ 1724 /*ARGSUSED*/ 1725 void 1726 prt_sol(private_t *pri, int raw, long val) 1727 { 1728 if (val == SOL_SOCKET) { 1729 outstring(pri, "SOL_SOCKET"); 1730 } else { 1731 const struct protoent *p; 1732 struct protoent res; 1733 char buf[NSS_BUFLEN_PROTOCOLS]; 1734 1735 if ((p = getprotobynumber_r(val, &res, 1736 (char *)buf, sizeof (buf))) != NULL) 1737 outstring(pri, p->p_name); 1738 else 1739 prt_dec(pri, 0, val); 1740 } 1741 } 1742 1743 1744 const char * 1745 sol_optname(private_t *pri, long val) 1746 { 1747 #define CBSIZE sizeof (pri->code_buf) 1748 if (val >= SO_SNDBUF) { 1749 switch (val) { 1750 case SO_SNDBUF: return ("SO_SNDBUF"); 1751 case SO_RCVBUF: return ("SO_RCVBUF"); 1752 case SO_SNDLOWAT: return ("SO_SNDLOWAT"); 1753 case SO_RCVLOWAT: return ("SO_RCVLOWAT"); 1754 case SO_SNDTIMEO: return ("SO_SNDTIMEO"); 1755 case SO_RCVTIMEO: return ("SO_RCVTIMEO"); 1756 case SO_ERROR: return ("SO_ERROR"); 1757 case SO_TYPE: return ("SO_TYPE"); 1758 case SO_PROTOTYPE: return ("SO_PROTOTYPE"); 1759 1760 default: (void) snprintf(pri->code_buf, CBSIZE, 1761 "0x%lx", val); 1762 return (pri->code_buf); 1763 } 1764 } else { 1765 char *s = pri->code_buf; 1766 size_t used = 1; 1767 long val2; 1768 1769 *s = '\0'; 1770 val2 = val & ~(SO_DEBUG|SO_ACCEPTCONN|SO_REUSEADDR|SO_KEEPALIVE| 1771 SO_DONTROUTE|SO_BROADCAST|SO_USELOOPBACK|SO_LINGER| 1772 SO_OOBINLINE|SO_DGRAM_ERRIND|SO_RECVUCRED); 1773 if (val2) 1774 used = snprintf(s, CBSIZE, "|0x%lx", val2); 1775 if (val & SO_DEBUG) 1776 used = strlcat(s, "|SO_DEBUG", CBSIZE); 1777 if (val & SO_ACCEPTCONN) 1778 used = strlcat(s, "|SO_ACCEPTCONN", CBSIZE); 1779 if (val & SO_REUSEADDR) 1780 used = strlcat(s, "|SO_REUSEADDR", CBSIZE); 1781 if (val & SO_KEEPALIVE) 1782 used = strlcat(s, "|SO_KEEPALIVE", CBSIZE); 1783 if (val & SO_DONTROUTE) 1784 used = strlcat(s, "|SO_DONTROUTE", CBSIZE); 1785 if (val & SO_BROADCAST) 1786 used = strlcat(s, "|SO_BROADCAST", CBSIZE); 1787 if (val & SO_USELOOPBACK) 1788 used = strlcat(s, "|SO_USELOOPBACK", CBSIZE); 1789 if (val & SO_LINGER) 1790 used = strlcat(s, "|SO_LINGER", CBSIZE); 1791 if (val & SO_OOBINLINE) 1792 used = strlcat(s, "|SO_OOBINLINE", CBSIZE); 1793 if (val & SO_DGRAM_ERRIND) 1794 used = strlcat(s, "|SO_DGRAM_ERRIND", CBSIZE); 1795 if (val & SO_RECVUCRED) 1796 used = strlcat(s, "|SO_RECVUCRED", CBSIZE); 1797 if (used >= CBSIZE || val == 0) 1798 (void) snprintf(s + 1, CBSIZE-1, "0x%lx", val); 1799 return ((const char *)(s + 1)); 1800 } 1801 #undef CBSIZE 1802 } 1803 1804 1805 const char * 1806 tcp_optname(private_t *pri, long val) 1807 { 1808 switch (val) { 1809 case TCP_NODELAY: return ("TCP_NODELAY"); 1810 case TCP_MAXSEG: return ("TCP_MAXSEG"); 1811 case TCP_KEEPALIVE: return ("TCP_KEEPALIVE"); 1812 case TCP_NOTIFY_THRESHOLD: return ("TCP_NOTIFY_THRESHOLD"); 1813 case TCP_ABORT_THRESHOLD: return ("TCP_ABORT_THRESHOLD"); 1814 case TCP_CONN_NOTIFY_THRESHOLD: return ("TCP_CONN_NOTIFY_THRESHOLD"); 1815 case TCP_CONN_ABORT_THRESHOLD: return ("TCP_CONN_ABORT_THRESHOLD"); 1816 case TCP_RECVDSTADDR: return ("TCP_RECVDSTADDR"); 1817 case TCP_ANONPRIVBIND: return ("TCP_ANONPRIVBIND"); 1818 case TCP_EXCLBIND: return ("TCP_EXCLBIND"); 1819 1820 default: (void) snprintf(pri->code_buf, 1821 sizeof (pri->code_buf), 1822 "0x%lx", val); 1823 return (pri->code_buf); 1824 } 1825 } 1826 1827 1828 const char * 1829 sctp_optname(private_t *pri, long val) 1830 { 1831 switch (val) { 1832 case SCTP_RTOINFO: return ("SCTP_RTOINFO"); 1833 case SCTP_ASSOCINFO: return ("SCTP_ASSOCINFO"); 1834 case SCTP_INITMSG: return ("SCTP_INITMSG"); 1835 case SCTP_NODELAY: return ("SCTP_NODELAY"); 1836 case SCTP_AUTOCLOSE: return ("SCTP_AUTOCLOSE"); 1837 case SCTP_SET_PEER_PRIMARY_ADDR: 1838 return ("SCTP_SET_PEER_PRIMARY_ADDR"); 1839 case SCTP_PRIMARY_ADDR: return ("SCTP_PRIMARY_ADDR"); 1840 case SCTP_ADAPTION_LAYER: return ("SCTP_ADAPTION_LAYER"); 1841 case SCTP_DISABLE_FRAGMENTS: return ("SCTP_DISABLE_FRAGMENTS"); 1842 case SCTP_PEER_ADDR_PARAMS: return ("SCTP_PEER_ADDR_PARAMS"); 1843 case SCTP_DEFAULT_SEND_PARAM: return ("SCTP_DEFAULT_SEND_PARAM"); 1844 case SCTP_EVENTS: return ("SCTP_EVENTS"); 1845 case SCTP_I_WANT_MAPPED_V4_ADDR: 1846 return ("SCTP_I_WANT_MAPPED_V4_ADDR"); 1847 case SCTP_MAXSEG: return ("SCTP_MAXSEG"); 1848 case SCTP_STATUS: return ("SCTP_STATUS"); 1849 case SCTP_GET_PEER_ADDR_INFO: return ("SCTP_GET_PEER_ADDR_INFO"); 1850 1851 case SCTP_ADD_ADDR: return ("SCTP_ADD_ADDR"); 1852 case SCTP_REM_ADDR: return ("SCTP_REM_ADDR"); 1853 1854 default: (void) snprintf(pri->code_buf, 1855 sizeof (pri->code_buf), 1856 "0x%lx", val); 1857 return (pri->code_buf); 1858 } 1859 } 1860 1861 1862 const char * 1863 udp_optname(private_t *pri, long val) 1864 { 1865 if (val == UDP_CHECKSUM) 1866 return ("UDP_CHECKSUM"); 1867 1868 (void) snprintf(pri->code_buf, sizeof (pri->code_buf), "0x%lx", val); 1869 return (pri->code_buf); 1870 } 1871 1872 1873 /* 1874 * Print setsockopt()/getsockopt() 3rd argument. 1875 */ 1876 /*ARGSUSED*/ 1877 void 1878 prt_son(private_t *pri, int raw, long val) 1879 { 1880 /* cheating -- look at the level */ 1881 switch (pri->sys_args[1]) { 1882 case SOL_SOCKET: outstring(pri, sol_optname(pri, val)); 1883 break; 1884 case IPPROTO_TCP: outstring(pri, tcp_optname(pri, val)); 1885 break; 1886 case IPPROTO_UDP: outstring(pri, udp_optname(pri, val)); 1887 break; 1888 case IPPROTO_SCTP: outstring(pri, sctp_optname(pri, val)); 1889 break; 1890 default: prt_dec(pri, 0, val); 1891 break; 1892 } 1893 } 1894 1895 1896 /* 1897 * Print utrap type 1898 */ 1899 /*ARGSUSED*/ 1900 void 1901 prt_utt(private_t *pri, int raw, long val) 1902 { 1903 const char *s = NULL; 1904 1905 #ifdef __sparc 1906 if (!raw) { 1907 switch (val) { 1908 case UT_INSTRUCTION_DISABLED: 1909 s = "UT_INSTRUCTION_DISABLED"; break; 1910 case UT_INSTRUCTION_ERROR: 1911 s = "UT_INSTRUCTION_ERROR"; break; 1912 case UT_INSTRUCTION_PROTECTION: 1913 s = "UT_INSTRUCTION_PROTECTION"; break; 1914 case UT_ILLTRAP_INSTRUCTION: 1915 s = "UT_ILLTRAP_INSTRUCTION"; break; 1916 case UT_ILLEGAL_INSTRUCTION: 1917 s = "UT_ILLEGAL_INSTRUCTION"; break; 1918 case UT_PRIVILEGED_OPCODE: 1919 s = "UT_PRIVILEGED_OPCODE"; break; 1920 case UT_FP_DISABLED: 1921 s = "UT_FP_DISABLED"; break; 1922 case UT_FP_EXCEPTION_IEEE_754: 1923 s = "UT_FP_EXCEPTION_IEEE_754"; break; 1924 case UT_FP_EXCEPTION_OTHER: 1925 s = "UT_FP_EXCEPTION_OTHER"; break; 1926 case UT_TAG_OVERFLOW: 1927 s = "UT_TAG_OVERFLOW"; break; 1928 case UT_DIVISION_BY_ZERO: 1929 s = "UT_DIVISION_BY_ZERO"; break; 1930 case UT_DATA_EXCEPTION: 1931 s = "UT_DATA_EXCEPTION"; break; 1932 case UT_DATA_ERROR: 1933 s = "UT_DATA_ERROR"; break; 1934 case UT_DATA_PROTECTION: 1935 s = "UT_DATA_PROTECTION"; break; 1936 case UT_MEM_ADDRESS_NOT_ALIGNED: 1937 s = "UT_MEM_ADDRESS_NOT_ALIGNED"; break; 1938 case UT_PRIVILEGED_ACTION: 1939 s = "UT_PRIVILEGED_ACTION"; break; 1940 case UT_ASYNC_DATA_ERROR: 1941 s = "UT_ASYNC_DATA_ERROR"; break; 1942 case UT_TRAP_INSTRUCTION_16: 1943 s = "UT_TRAP_INSTRUCTION_16"; break; 1944 case UT_TRAP_INSTRUCTION_17: 1945 s = "UT_TRAP_INSTRUCTION_17"; break; 1946 case UT_TRAP_INSTRUCTION_18: 1947 s = "UT_TRAP_INSTRUCTION_18"; break; 1948 case UT_TRAP_INSTRUCTION_19: 1949 s = "UT_TRAP_INSTRUCTION_19"; break; 1950 case UT_TRAP_INSTRUCTION_20: 1951 s = "UT_TRAP_INSTRUCTION_20"; break; 1952 case UT_TRAP_INSTRUCTION_21: 1953 s = "UT_TRAP_INSTRUCTION_21"; break; 1954 case UT_TRAP_INSTRUCTION_22: 1955 s = "UT_TRAP_INSTRUCTION_22"; break; 1956 case UT_TRAP_INSTRUCTION_23: 1957 s = "UT_TRAP_INSTRUCTION_23"; break; 1958 case UT_TRAP_INSTRUCTION_24: 1959 s = "UT_TRAP_INSTRUCTION_24"; break; 1960 case UT_TRAP_INSTRUCTION_25: 1961 s = "UT_TRAP_INSTRUCTION_25"; break; 1962 case UT_TRAP_INSTRUCTION_26: 1963 s = "UT_TRAP_INSTRUCTION_26"; break; 1964 case UT_TRAP_INSTRUCTION_27: 1965 s = "UT_TRAP_INSTRUCTION_27"; break; 1966 case UT_TRAP_INSTRUCTION_28: 1967 s = "UT_TRAP_INSTRUCTION_28"; break; 1968 case UT_TRAP_INSTRUCTION_29: 1969 s = "UT_TRAP_INSTRUCTION_29"; break; 1970 case UT_TRAP_INSTRUCTION_30: 1971 s = "UT_TRAP_INSTRUCTION_30"; break; 1972 case UT_TRAP_INSTRUCTION_31: 1973 s = "UT_TRAP_INSTRUCTION_31"; break; 1974 } 1975 } 1976 #endif /* __sparc */ 1977 1978 if (s == NULL) 1979 prt_dec(pri, 0, val); 1980 else 1981 outstring(pri, s); 1982 } 1983 1984 1985 /* 1986 * Print utrap handler 1987 */ 1988 void 1989 prt_uth(private_t *pri, int raw, long val) 1990 { 1991 const char *s = NULL; 1992 1993 if (!raw) { 1994 switch (val) { 1995 case (long)UTH_NOCHANGE: s = "UTH_NOCHANGE"; break; 1996 } 1997 } 1998 1999 if (s == NULL) 2000 prt_hex(pri, 0, val); 2001 else 2002 outstring(pri, s); 2003 } 2004 2005 const char * 2006 access_flags(private_t *pri, long arg) 2007 { 2008 #define E_OK 010 2009 char *str = pri->code_buf; 2010 2011 if (arg & ~(R_OK|W_OK|X_OK|E_OK)) 2012 return (NULL); 2013 2014 /* NB: F_OK == 0 */ 2015 if (arg == F_OK) 2016 return ("F_OK"); 2017 if (arg == E_OK) 2018 return ("F_OK|E_OK"); 2019 2020 *str = '\0'; 2021 if (arg & R_OK) 2022 (void) strlcat(str, "|R_OK", sizeof (pri->code_buf)); 2023 if (arg & W_OK) 2024 (void) strlcat(str, "|W_OK", sizeof (pri->code_buf)); 2025 if (arg & X_OK) 2026 (void) strlcat(str, "|X_OK", sizeof (pri->code_buf)); 2027 if (arg & E_OK) 2028 (void) strlcat(str, "|E_OK", sizeof (pri->code_buf)); 2029 return ((const char *)(str + 1)); 2030 #undef E_OK 2031 } 2032 2033 /* 2034 * Print access() flags. 2035 */ 2036 void 2037 prt_acc(private_t *pri, int raw, long val) 2038 { 2039 const char *s = raw? NULL : access_flags(pri, val); 2040 2041 if (s == NULL) 2042 prt_dex(pri, 0, val); 2043 else 2044 outstring(pri, s); 2045 } 2046 2047 /* 2048 * Print shutdown() "how" (2nd) argument 2049 */ 2050 void 2051 prt_sht(private_t *pri, int raw, long val) 2052 { 2053 if (raw) { 2054 prt_dex(pri, 0, val); 2055 return; 2056 } 2057 switch (val) { 2058 case SHUT_RD: outstring(pri, "SHUT_RD"); break; 2059 case SHUT_WR: outstring(pri, "SHUT_WR"); break; 2060 case SHUT_RDWR: outstring(pri, "SHUT_RDWR"); break; 2061 default: prt_dec(pri, 0, val); break; 2062 } 2063 } 2064 2065 /* 2066 * Print fcntl() F_SETFL flags (3rd) argument or fdsync flag (2nd arg) 2067 */ 2068 static struct fcntl_flags { 2069 long val; 2070 const char *name; 2071 } fcntl_flags[] = { 2072 #define FC_FL(flag) { (long)flag, "|" # flag } 2073 #ifdef C2_AUDIT 2074 FC_FL(FREVOKED), 2075 #endif 2076 FC_FL(FREAD), 2077 FC_FL(FWRITE), 2078 FC_FL(FNDELAY), 2079 FC_FL(FAPPEND), 2080 FC_FL(FSYNC), 2081 FC_FL(FDSYNC), 2082 FC_FL(FRSYNC), 2083 FC_FL(FOFFMAX), 2084 FC_FL(FNONBLOCK), 2085 FC_FL(FCREAT), 2086 FC_FL(FTRUNC), 2087 FC_FL(FEXCL), 2088 FC_FL(FNOCTTY), 2089 FC_FL(FXATTR), 2090 FC_FL(FASYNC), 2091 FC_FL(FNODSYNC) 2092 #undef FC_FL 2093 }; 2094 2095 void 2096 prt_ffg(private_t *pri, int raw, long val) 2097 { 2098 #define CBSIZE sizeof (pri->code_buf) 2099 char *s = pri->code_buf; 2100 size_t used = 1; 2101 struct fcntl_flags *fp; 2102 2103 if (raw) { 2104 (void) snprintf(s, CBSIZE, "0x%lx", val); 2105 outstring(pri, s); 2106 return; 2107 } 2108 if (val == 0) { 2109 outstring(pri, "(no flags)"); 2110 return; 2111 } 2112 2113 *s = '\0'; 2114 for (fp = fcntl_flags; 2115 fp < &fcntl_flags[sizeof (fcntl_flags) / sizeof (*fp)]; fp++) { 2116 if (val & fp->val) { 2117 used = strlcat(s, fp->name, CBSIZE); 2118 val &= ~fp->val; 2119 } 2120 } 2121 2122 if (val != 0 && used <= CBSIZE) 2123 used += snprintf(s + used, CBSIZE - used, "|0x%lx", val); 2124 2125 if (used >= CBSIZE) 2126 (void) snprintf(s + 1, CBSIZE-1, "0x%lx", val); 2127 outstring(pri, s + 1); 2128 #undef CBSIZE 2129 } 2130 2131 void 2132 prt_prs(private_t *pri, int raw, long val) 2133 { 2134 static size_t setsize; 2135 priv_set_t *set = priv_allocset(); 2136 2137 if (setsize == 0) { 2138 const priv_impl_info_t *info = getprivimplinfo(); 2139 if (info != NULL) 2140 setsize = info->priv_setsize * sizeof (priv_chunk_t); 2141 } 2142 2143 if (setsize != 0 && !raw && set != NULL && 2144 Pread(Proc, set, setsize, val) == setsize) { 2145 int i; 2146 2147 outstring(pri, "{"); 2148 for (i = 0; i < setsize / sizeof (priv_chunk_t); i++) { 2149 char buf[9]; /* 8 hex digits + '\0' */ 2150 (void) snprintf(buf, sizeof (buf), "%08x", 2151 ((priv_chunk_t *)set)[i]); 2152 outstring(pri, buf); 2153 } 2154 2155 outstring(pri, "}"); 2156 } else { 2157 prt_hex(pri, 0, val); 2158 } 2159 2160 if (set != NULL) 2161 priv_freeset(set); 2162 } 2163 2164 /* 2165 * Print privilege set operation. 2166 */ 2167 void 2168 prt_pro(private_t *pri, int raw, long val) 2169 { 2170 const char *s = NULL; 2171 2172 if (!raw) { 2173 switch ((priv_op_t)val) { 2174 case PRIV_ON: s = "PRIV_ON"; break; 2175 case PRIV_OFF: s = "PRIV_OFF"; break; 2176 case PRIV_SET: s = "PRIV_SET"; break; 2177 } 2178 } 2179 2180 if (s == NULL) 2181 prt_dec(pri, 0, val); 2182 else 2183 outstring(pri, s); 2184 } 2185 2186 /* 2187 * Print privilege set name 2188 */ 2189 void 2190 prt_prn(private_t *pri, int raw, long val) 2191 { 2192 const char *s = NULL; 2193 2194 if (!raw) 2195 s = priv_getsetbynum((int)val); 2196 2197 if (s == NULL) 2198 prt_dec(pri, 0, val); 2199 else { 2200 char *dup = strdup(s); 2201 char *q; 2202 2203 /* Do the best we can in this case */ 2204 if (dup == NULL) { 2205 outstring(pri, s); 2206 return; 2207 } 2208 2209 outstring(pri, "PRIV_"); 2210 2211 q = dup; 2212 2213 while (*q != '\0') { 2214 *q = toupper(*q); 2215 q++; 2216 } 2217 outstring(pri, dup); 2218 free(dup); 2219 } 2220 } 2221 2222 /* 2223 * Print process flag names. 2224 */ 2225 void 2226 prt_pfl(private_t *pri, int raw, long val) 2227 { 2228 const char *s = NULL; 2229 2230 if (!raw) { 2231 switch ((int)val) { 2232 case PRIV_DEBUG: s = "PRIV_DEBUG"; break; 2233 case PRIV_AWARE: s = "PRIV_AWARE"; break; 2234 } 2235 } 2236 2237 if (s == NULL) 2238 prt_dec(pri, 0, val); 2239 else 2240 outstring(pri, s); 2241 } 2242 2243 /* 2244 * Print lgrp_affinity_{get,set}() arguments. 2245 */ 2246 /*ARGSUSED*/ 2247 void 2248 prt_laf(private_t *pri, int raw, long val) 2249 { 2250 lgrp_affinity_args_t laff; 2251 2252 if (Pread(Proc, &laff, sizeof (lgrp_affinity_args_t), val) != 2253 sizeof (lgrp_affinity_args_t)) { 2254 prt_hex(pri, 0, val); 2255 return; 2256 } 2257 /* 2258 * arrange the arguments in the order that user calls with 2259 */ 2260 prt_dec(pri, 0, laff.idtype); 2261 outstring(pri, ", "); 2262 prt_dec(pri, 0, laff.id); 2263 outstring(pri, ", "); 2264 prt_dec(pri, 0, laff.lgrp); 2265 outstring(pri, ", "); 2266 if (pri->sys_args[0] == LGRP_SYS_AFFINITY_SET) 2267 prt_dec(pri, 0, laff.aff); 2268 } 2269 2270 /* 2271 * Print a key_t as IPC_PRIVATE if it is 0. 2272 */ 2273 void 2274 prt_key(private_t *pri, int raw, long val) 2275 { 2276 if (!raw && val == 0) 2277 outstring(pri, "IPC_PRIVATE"); 2278 else 2279 prt_dec(pri, 0, val); 2280 } 2281 2282 2283 /* 2284 * Print zone_getattr() attribute types. 2285 */ 2286 void 2287 prt_zga(private_t *pri, int raw, long val) 2288 { 2289 const char *s = NULL; 2290 2291 if (!raw) { 2292 switch ((int)val) { 2293 case ZONE_ATTR_NAME: s = "ZONE_ATTR_NAME"; break; 2294 case ZONE_ATTR_ROOT: s = "ZONE_ATTR_ROOT"; break; 2295 case ZONE_ATTR_STATUS: s = "ZONE_ATTR_STATUS"; break; 2296 case ZONE_ATTR_PRIVSET: s = "ZONE_ATTR_PRIVSET"; break; 2297 case ZONE_ATTR_UNIQID: s = "ZONE_ATTR_UNIQID"; break; 2298 case ZONE_ATTR_POOLID: s = "ZONE_ATTR_POOLID"; break; 2299 case ZONE_ATTR_INITPID: s = "ZONE_ATTR_INITPID"; break; 2300 } 2301 } 2302 2303 if (s == NULL) 2304 prt_dec(pri, 0, val); 2305 else 2306 outstring(pri, s); 2307 } 2308 2309 /* 2310 * Print a file descriptor as AT_FDCWD if necessary 2311 */ 2312 void 2313 prt_atc(private_t *pri, int raw, long val) 2314 { 2315 if (!raw && val == AT_FDCWD) 2316 outstring(pri, "AT_FDCWD"); 2317 else 2318 prt_dec(pri, 0, val); 2319 } 2320 2321 /* 2322 * Print LIO_XX flags 2323 */ 2324 void 2325 prt_lio(private_t *pri, int raw, long val) 2326 { 2327 if (raw) 2328 prt_dec(pri, 0, val); 2329 else if (val == LIO_WAIT) 2330 outstring(pri, "LIO_WAIT"); 2331 else if (val == LIO_NOWAIT) 2332 outstring(pri, "LIO_NOWAIT"); 2333 else 2334 prt_dec(pri, 0, val); 2335 } 2336 2337 const char * 2338 door_flags(private_t *pri, long val) 2339 { 2340 door_attr_t attr = (door_attr_t)val; 2341 char *str = pri->code_buf; 2342 2343 *str = '\0'; 2344 #define PROCESS_FLAG(flg) \ 2345 if (attr & flg) { \ 2346 (void) strlcat(str, "|" #flg, sizeof (pri->code_buf)); \ 2347 attr &= ~flg; \ 2348 } 2349 2350 PROCESS_FLAG(DOOR_UNREF); 2351 PROCESS_FLAG(DOOR_UNREF_MULTI); 2352 PROCESS_FLAG(DOOR_PRIVATE); 2353 PROCESS_FLAG(DOOR_REFUSE_DESC); 2354 PROCESS_FLAG(DOOR_NO_CANCEL); 2355 PROCESS_FLAG(DOOR_LOCAL); 2356 PROCESS_FLAG(DOOR_REVOKED); 2357 PROCESS_FLAG(DOOR_IS_UNREF); 2358 #undef PROCESS_FLAG 2359 2360 if (attr != 0 || *str == '\0') { 2361 size_t len = strlen(str); 2362 (void) snprintf(str + len, sizeof (pri->code_buf) - len, 2363 "|0x%X", attr); 2364 } 2365 2366 return (str + 1); 2367 } 2368 2369 /* 2370 * Print door_create() flags 2371 */ 2372 void 2373 prt_dfl(private_t *pri, int raw, long val) 2374 { 2375 if (raw) 2376 prt_hex(pri, 0, val); 2377 else 2378 outstring(pri, door_flags(pri, val)); 2379 } 2380 2381 /* 2382 * Print door_*param() param argument 2383 */ 2384 void 2385 prt_dpm(private_t *pri, int raw, long val) 2386 { 2387 if (raw) 2388 prt_hex(pri, 0, val); 2389 else if (val == DOOR_PARAM_DESC_MAX) 2390 outstring(pri, "DOOR_PARAM_DESC_MAX"); 2391 else if (val == DOOR_PARAM_DATA_MIN) 2392 outstring(pri, "DOOR_PARAM_DATA_MIN"); 2393 else if (val == DOOR_PARAM_DATA_MAX) 2394 outstring(pri, "DOOR_PARAM_DATA_MAX"); 2395 else 2396 prt_hex(pri, 0, val); 2397 } 2398 2399 /* 2400 * Array of pointers to print functions, one for each format. 2401 */ 2402 void (* const Print[])() = { 2403 prt_nov, /* NOV -- no value */ 2404 prt_dec, /* DEC -- print value in decimal */ 2405 prt_oct, /* OCT -- print value in octal */ 2406 prt_hex, /* HEX -- print value in hexadecimal */ 2407 prt_dex, /* DEX -- print value in hexadecimal if big enough */ 2408 prt_stg, /* STG -- print value as string */ 2409 prt_ioc, /* IOC -- print ioctl code */ 2410 prt_fcn, /* FCN -- print fcntl code */ 2411 prt_s86, /* S86 -- print sysi86 code */ 2412 prt_uts, /* UTS -- print utssys code */ 2413 prt_opn, /* OPN -- print open code */ 2414 prt_sig, /* SIG -- print signal name plus flags */ 2415 prt_act, /* ACT -- print signal action value */ 2416 prt_msc, /* MSC -- print msgsys command */ 2417 prt_msf, /* MSF -- print msgsys flags */ 2418 prt_smc, /* SMC -- print semsys command */ 2419 prt_sef, /* SEF -- print semsys flags */ 2420 prt_shc, /* SHC -- print shmsys command */ 2421 prt_shf, /* SHF -- print shmsys flags */ 2422 prt_plk, /* PLK -- print plock code */ 2423 prt_sfs, /* SFS -- print sysfs code */ 2424 prt_rst, /* RST -- print string returned by syscall */ 2425 prt_smf, /* SMF -- print streams message flags */ 2426 prt_ioa, /* IOA -- print ioctl argument */ 2427 prt_six, /* SIX -- print signal, masked with SIGNO_MASK */ 2428 prt_mtf, /* MTF -- print mount flags */ 2429 prt_mft, /* MFT -- print mount file system type */ 2430 prt_iob, /* IOB -- print contents of I/O buffer */ 2431 prt_hhx, /* HHX -- print value in hexadecimal (half size) */ 2432 prt_wop, /* WOP -- print waitsys() options */ 2433 prt_spm, /* SPM -- print sigprocmask argument */ 2434 prt_rlk, /* RLK -- print readlink buffer */ 2435 prt_mpr, /* MPR -- print mmap()/mprotect() flags */ 2436 prt_mty, /* MTY -- print mmap() mapping type flags */ 2437 prt_mcf, /* MCF -- print memcntl() function */ 2438 prt_mc4, /* MC4 -- print memcntl() (fourth) argument */ 2439 prt_mc5, /* MC5 -- print memcntl() (fifth) argument */ 2440 prt_mad, /* MAD -- print madvise() argument */ 2441 prt_ulm, /* ULM -- print ulimit() argument */ 2442 prt_rlm, /* RLM -- print get/setrlimit() argument */ 2443 prt_cnf, /* CNF -- print sysconfig() argument */ 2444 prt_inf, /* INF -- print sysinfo() argument */ 2445 prt_ptc, /* PTC -- print pathconf/fpathconf() argument */ 2446 prt_fui, /* FUI -- print fusers() input argument */ 2447 prt_idt, /* IDT -- print idtype_t, waitid() argument */ 2448 prt_lwf, /* LWF -- print lwp_create() flags */ 2449 prt_itm, /* ITM -- print [get|set]itimer() arg */ 2450 prt_llo, /* LLO -- print long long offset arg */ 2451 prt_mod, /* MOD -- print modctl() subcode */ 2452 prt_whn, /* WHN -- print lseek() whence arguiment */ 2453 prt_acl, /* ACL -- print acl() code */ 2454 prt_aio, /* AIO -- print kaio() code */ 2455 prt_aud, /* AUD -- print auditsys() code */ 2456 prt_uns, /* DEC -- print value in unsigned decimal */ 2457 prt_clc, /* CLC -- print cladm command argument */ 2458 prt_clf, /* CLF -- print cladm flag argument */ 2459 prt_cor, /* COR -- print corectl() subcode */ 2460 prt_cco, /* CCO -- print corectl() options */ 2461 prt_ccc, /* CCC -- print corectl() content */ 2462 prt_rcc, /* RCC -- print corectl() returned content */ 2463 prt_cpc, /* CPC -- print cpc() subcode */ 2464 prt_sqc, /* SQC -- print sigqueue() si_code argument */ 2465 prt_pc4, /* PC4 -- print priocntlsys() (fourth) argument */ 2466 prt_pc5, /* PC5 -- print priocntlsys() (key, value) pairs */ 2467 prt_pst, /* PST -- print processor set id */ 2468 prt_mif, /* MIF -- print meminfo() arguments */ 2469 prt_pfm, /* PFM -- print so_socket() proto-family (1st) arg */ 2470 prt_skt, /* SKT -- print so_socket() socket-type (2nd) arg */ 2471 prt_skp, /* SKP -- print so_socket() protocol (3rd) arg */ 2472 prt_skv, /* SKV -- print socket version arg */ 2473 prt_sol, /* SOL -- print [sg]etsockopt() level (2nd) arg */ 2474 prt_son, /* SON -- print [sg]etsockopt() opt-name (3rd) arg */ 2475 prt_utt, /* UTT -- print utrap type */ 2476 prt_uth, /* UTH -- print utrap handler */ 2477 prt_acc, /* ACC -- print access() flags */ 2478 prt_sht, /* SHT -- print shutdown() how (2nd) argument */ 2479 prt_ffg, /* FFG -- print fcntl() flags (3rd) argument */ 2480 prt_prs, /* PRS -- print privilege set */ 2481 prt_pro, /* PRO -- print privilege set operation */ 2482 prt_prn, /* PRN -- print privilege set name */ 2483 prt_pfl, /* PFL -- print privilege/process flag name */ 2484 prt_laf, /* LAF -- print lgrp_affinity arguments */ 2485 prt_key, /* KEY -- print key_t 0 as IPC_PRIVATE */ 2486 prt_zga, /* ZGA -- print zone_getattr attribute types */ 2487 prt_atc, /* ATC -- print AT_FDCWD or file descriptor */ 2488 prt_lio, /* LIO -- print LIO_XX flags */ 2489 prt_dfl, /* DFL -- print door_create() flags */ 2490 prt_dpm, /* DPM -- print DOOR_PARAM_XX flags */ 2491 prt_dec, /* HID -- hidden argument, make this the last one */ 2492 }; 2493