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 (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. 24 * Copyright 2020 Joyent, Inc. 25 * Copyright 2022 Garrett D'Amore 26 * Copyright 2022 Oxide Computer Company 27 */ 28 29 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 30 /* All Rights Reserved */ 31 32 /* Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. */ 33 34 #define _SYSCALL32 /* make 32-bit compat headers visible */ 35 36 #include <stdio.h> 37 #include <stdlib.h> 38 #include <unistd.h> 39 #include <string.h> 40 #include <signal.h> 41 #include <termio.h> 42 #include <stddef.h> 43 #include <limits.h> 44 #include <fcntl.h> 45 #include <ctype.h> 46 #include <sys/types.h> 47 #include <sys/mman.h> 48 #include <sys/resource.h> 49 #include <sys/ulimit.h> 50 #include <sys/utsname.h> 51 #include <sys/kstat.h> 52 #include <sys/modctl.h> 53 #include <sys/acl.h> 54 #include <stropts.h> 55 #include <sys/isa_defs.h> 56 #include <sys/systeminfo.h> 57 #include <sys/cladm.h> 58 #include <sys/lwp.h> 59 #include <bsm/audit.h> 60 #include <libproc.h> 61 #include <priv.h> 62 #include <sys/aio.h> 63 #include <sys/aiocb.h> 64 #include <sys/corectl.h> 65 #include <sys/cpc_impl.h> 66 #include <sys/priocntl.h> 67 #include <sys/tspriocntl.h> 68 #include <sys/iapriocntl.h> 69 #include <sys/rtpriocntl.h> 70 #include <sys/fsspriocntl.h> 71 #include <sys/fxpriocntl.h> 72 #include <sys/proc.h> 73 #include <netdb.h> 74 #include <nss_dbdefs.h> 75 #include <sys/socketvar.h> 76 #include <netinet/in.h> 77 #include <netinet/tcp.h> 78 #include <netinet/udp.h> 79 #include <netinet/sctp.h> 80 #include <netinet/ip_mroute.h> 81 #include <netinet/icmp6.h> 82 #include <net/route.h> 83 #include <sys/utrap.h> 84 #include <sys/lgrp_user.h> 85 #include <sys/door.h> 86 #include <sys/tsol/tndb.h> 87 #include <sys/rctl.h> 88 #include <sys/rctl_impl.h> 89 #include <sys/fork.h> 90 #include <sys/task.h> 91 #include <sys/random.h> 92 #include "ramdata.h" 93 #include "print.h" 94 #include "proto.h" 95 #include "systable.h" 96 97 void grow(private_t *, int nbyte); 98 99 #define GROW(nb) if (pri->sys_leng + (nb) >= pri->sys_ssize) grow(pri, (nb)) 100 101 102 /*ARGSUSED*/ 103 void 104 prt_nov(private_t *pri, int raw, long val) /* print nothing */ 105 { 106 } 107 108 /*ARGSUSED*/ 109 void 110 prt_dec(private_t *pri, int raw, long val) /* print as decimal */ 111 { 112 GROW(24); 113 if (data_model == PR_MODEL_ILP32) 114 pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng, 115 "%d", (int)val); 116 else 117 pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng, 118 "%ld", val); 119 } 120 121 /*ARGSUSED*/ 122 void 123 prt_uns(private_t *pri, int raw, long val) /* print as unsigned decimal */ 124 { 125 GROW(24); 126 if (data_model == PR_MODEL_ILP32) 127 pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng, 128 "%u", (int)val); 129 else 130 pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng, 131 "%lu", val); 132 } 133 134 /* print as unsigned decimal, except for -1 */ 135 void 136 prt_un1(private_t *pri, int raw, long val) 137 { 138 if ((int)val == -1) 139 prt_dec(pri, raw, val); 140 else 141 prt_uns(pri, raw, val); 142 } 143 144 /*ARGSUSED*/ 145 void 146 prt_oct(private_t *pri, int raw, long val) /* print as octal */ 147 { 148 GROW(24); 149 if (data_model == PR_MODEL_ILP32) 150 pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng, 151 "%#o", (int)val); 152 else 153 pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng, 154 "%#lo", val); 155 } 156 157 /*ARGSUSED*/ 158 void 159 prt_hex(private_t *pri, int raw, long val) /* print as hexadecimal */ 160 { 161 GROW(20); 162 if (data_model == PR_MODEL_ILP32) 163 pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng, 164 "0x%.8X", (int)val); 165 else 166 pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng, 167 "0x%.8lX", val); 168 } 169 170 /* print as hexadecimal (half size) */ 171 /*ARGSUSED*/ 172 void 173 prt_hhx(private_t *pri, int raw, long val) 174 { 175 GROW(20); 176 if (data_model == PR_MODEL_ILP32) 177 pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng, 178 "0x%.4X", (int)val); 179 else 180 pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng, 181 "0x%.4lX", val); 182 } 183 184 /* print as decimal if small, else hexadecimal */ 185 /*ARGSUSED*/ 186 void 187 prt_dex(private_t *pri, int raw, long val) 188 { 189 if (val & 0xff000000) 190 prt_hex(pri, 0, val); 191 else 192 prt_dec(pri, 0, val); 193 } 194 195 /* print long long offset */ 196 /*ARGSUSED*/ 197 void 198 prt_llo(private_t *pri, int raw, long val1, long val2) 199 { 200 int hival; 201 int loval; 202 203 #ifdef _LONG_LONG_LTOH 204 hival = (int)val2; 205 loval = (int)val1; 206 #else 207 hival = (int)val1; 208 loval = (int)val2; 209 #endif 210 211 if (hival == 0) { 212 prt_dex(pri, 0, loval); 213 } else { 214 GROW(18); 215 pri->sys_leng += 216 sprintf(pri->sys_string + pri->sys_leng, "0x%.8X%.8X", 217 hival, loval); 218 } 219 } 220 221 void 222 escape_string(private_t *pri, const char *s) 223 { 224 /* 225 * We want to avoid outputting unprintable characters that may 226 * destroy the user's terminal. So we do one pass to find any 227 * unprintable characters, size the array appropriately, and 228 * then walk each character by hand. Those that are unprintable 229 * are replaced by a hex escape (\xNN). We also escape quotes for 230 * completeness. 231 */ 232 int i, unprintable, quotes; 233 size_t len = strlen(s); 234 for (i = 0, unprintable = 0, quotes = 0; i < len; i++) { 235 if (!isprint(s[i])) 236 unprintable++; 237 if (s[i] == '"') 238 quotes++; 239 } 240 241 GROW(len + 3 * unprintable + quotes + 2); 242 243 pri->sys_string[pri->sys_leng++] = '"'; 244 for (i = 0; i < len; i++) { 245 if (s[i] == '"') 246 pri->sys_string[pri->sys_leng++] = '\\'; 247 248 if (isprint(s[i])) { 249 pri->sys_string[pri->sys_leng++] = s[i]; 250 } else { 251 pri->sys_leng += sprintf(pri->sys_string + 252 pri->sys_leng, "\\x%02x", (uint8_t)s[i]); 253 } 254 } 255 pri->sys_string[pri->sys_leng++] = '"'; 256 } 257 258 void 259 prt_stg(private_t *pri, int raw, long val) /* print as string */ 260 { 261 char *s = raw? NULL : fetchstring(pri, (long)val, PATH_MAX); 262 263 if (s == NULL) 264 prt_hex(pri, 0, val); 265 else 266 escape_string(pri, s); 267 } 268 269 /* print as string returned from syscall */ 270 void 271 prt_rst(private_t *pri, int raw, long val) 272 { 273 char *s = (raw || pri->Errno)? NULL : 274 fetchstring(pri, (long)val, PATH_MAX); 275 276 if (s == NULL) 277 prt_hex(pri, 0, val); 278 else { 279 GROW((int)strlen(s) + 2); 280 pri->sys_leng += snprintf(pri->sys_string + pri->sys_leng, 281 pri->sys_ssize - pri->sys_leng, "\"%s\"", s); 282 } 283 } 284 285 /* print contents of readlink() buffer */ 286 void 287 prt_rlk(private_t *pri, int raw, long val) 288 { 289 char *s = (raw || pri->Errno || pri->Rval1 <= 0)? NULL : 290 fetchstring(pri, (long)val, 291 (pri->Rval1 > PATH_MAX)? PATH_MAX : (int)pri->Rval1); 292 293 if (s == NULL) 294 prt_hex(pri, 0, val); 295 else { 296 GROW((int)strlen(s) + 2); 297 pri->sys_leng += snprintf(pri->sys_string + pri->sys_leng, 298 pri->sys_ssize - pri->sys_leng, "\"%s\"", s); 299 } 300 } 301 302 void 303 prt_ioc(private_t *pri, int raw, long val) /* print ioctl code */ 304 { 305 const char *s = raw? NULL : ioctlname(pri, (int)val); 306 307 if (s == NULL) 308 prt_hex(pri, 0, val); 309 else 310 outstring(pri, s); 311 } 312 313 void 314 prt_ioa(private_t *pri, int raw, long val) /* print ioctl argument */ 315 { 316 const char *s; 317 318 /* cheating -- look at the ioctl() code */ 319 switch (pri->sys_args[1]) { 320 321 /* kstat ioctl()s */ 322 case KSTAT_IOC_READ: 323 case KSTAT_IOC_WRITE: 324 if (data_model == PR_MODEL_ILP32) 325 prt_stg(pri, raw, 326 val + offsetof(kstat32_t, ks_name[0])); 327 else 328 prt_stg(pri, raw, 329 val + offsetof(kstat_t, ks_name[0])); 330 break; 331 332 /* streams ioctl()s */ 333 case I_LOOK: 334 prt_rst(pri, raw, val); 335 break; 336 case I_PUSH: 337 case I_FIND: 338 prt_stg(pri, raw, val); 339 break; 340 case I_LINK: 341 case I_UNLINK: 342 case I_SENDFD: 343 prt_dec(pri, 0, val); 344 break; 345 case I_SRDOPT: 346 if (raw || (s = strrdopt(val)) == NULL) 347 prt_dec(pri, 0, val); 348 else 349 outstring(pri, s); 350 break; 351 case I_SETSIG: 352 if (raw || (s = strevents(pri, val)) == NULL) 353 prt_hex(pri, 0, val); 354 else 355 outstring(pri, s); 356 break; 357 case I_FLUSH: 358 if (raw || (s = strflush(val)) == NULL) 359 prt_dec(pri, 0, val); 360 else 361 outstring(pri, s); 362 break; 363 364 /* tty ioctl()s */ 365 case TCSBRK: 366 case TCXONC: 367 case TCFLSH: 368 case TCDSET: 369 prt_dec(pri, 0, val); 370 break; 371 372 default: 373 prt_hex(pri, 0, val); 374 break; 375 } 376 } 377 378 void 379 prt_pip(private_t *pri, int raw, long val) /* print pipe code */ 380 { 381 const char *s = NULL; 382 383 if (!raw) { 384 switch (val) { 385 case O_CLOEXEC: 386 s = "O_CLOEXEC"; 387 break; 388 case O_NONBLOCK: 389 s = "O_NONBLOCK"; 390 break; 391 case O_CLOEXEC|O_NONBLOCK: 392 s = "O_CLOEXEC|O_NONBLOCK"; 393 break; 394 } 395 } 396 397 if (s == NULL) 398 prt_dex(pri, 0, val); 399 else 400 outstring(pri, s); 401 } 402 403 void 404 prt_pfd(private_t *pri, int raw, long val) /* print pipe code */ 405 { 406 int fds[2]; 407 char str[32]; 408 409 /* the fds only have meaning if the return value is 0 */ 410 if (!raw && 411 pri->Rval1 >= 0 && 412 Pread(Proc, fds, sizeof (fds), (long)val) == sizeof (fds)) { 413 (void) snprintf(str, sizeof (str), "[%d,%d]", fds[0], fds[1]); 414 outstring(pri, str); 415 } else { 416 prt_hex(pri, 0, val); 417 } 418 } 419 420 void 421 prt_fcn(private_t *pri, int raw, long val) /* print fcntl code */ 422 { 423 const char *s = raw? NULL : fcntlname(val); 424 425 if (s == NULL) 426 prt_dec(pri, 0, val); 427 else 428 outstring(pri, s); 429 } 430 431 void 432 prt_s86(private_t *pri, int raw, long val) /* print sysi86 code */ 433 { 434 435 const char *s = raw? NULL : si86name(val); 436 437 if (s == NULL) 438 prt_dec(pri, 0, val); 439 else 440 outstring(pri, s); 441 } 442 443 void 444 prt_uts(private_t *pri, int raw, long val) /* print utssys code */ 445 { 446 const char *s = raw? NULL : utscode(val); 447 448 if (s == NULL) 449 prt_dec(pri, 0, val); 450 else 451 outstring(pri, s); 452 } 453 454 void 455 prt_msc(private_t *pri, int raw, long val) /* print msgsys command */ 456 { 457 const char *s = raw? NULL : msgcmd(val); 458 459 if (s == NULL) 460 prt_dec(pri, 0, val); 461 else 462 outstring(pri, s); 463 } 464 465 void 466 prt_msf(private_t *pri, int raw, long val) /* print msgsys flags */ 467 { 468 const char *s = raw? NULL : msgflags(pri, (int)val); 469 470 if (s == NULL) 471 prt_oct(pri, 0, val); 472 else 473 outstring(pri, s); 474 } 475 476 void 477 prt_smc(private_t *pri, int raw, long val) /* print semsys command */ 478 { 479 const char *s = raw? NULL : semcmd(val); 480 481 if (s == NULL) 482 prt_dec(pri, 0, val); 483 else 484 outstring(pri, s); 485 } 486 487 void 488 prt_sef(private_t *pri, int raw, long val) /* print semsys flags */ 489 { 490 const char *s = raw? NULL : semflags(pri, (int)val); 491 492 if (s == NULL) 493 prt_oct(pri, 0, val); 494 else 495 outstring(pri, s); 496 } 497 498 void 499 prt_shc(private_t *pri, int raw, long val) /* print shmsys command */ 500 { 501 const char *s = raw? NULL : shmcmd(val); 502 503 if (s == NULL) 504 prt_dec(pri, 0, val); 505 else 506 outstring(pri, s); 507 } 508 509 void 510 prt_shf(private_t *pri, int raw, long val) /* print shmsys flags */ 511 { 512 const char *s = raw? NULL : shmflags(pri, (int)val); 513 514 if (s == NULL) 515 prt_oct(pri, 0, val); 516 else 517 outstring(pri, s); 518 } 519 520 void 521 prt_sfs(private_t *pri, int raw, long val) /* print sysfs code */ 522 { 523 const char *s = raw? NULL : sfsname(val); 524 525 if (s == NULL) 526 prt_dec(pri, 0, val); 527 else 528 outstring(pri, s); 529 } 530 531 void 532 prt_opn(private_t *pri, int raw, long val) /* print open code */ 533 { 534 const char *s = raw? NULL : openarg(pri, val); 535 536 if (s == NULL) 537 prt_oct(pri, 0, val); 538 else 539 outstring(pri, s); 540 } 541 542 void 543 prt_sig(private_t *pri, int raw, long val) /* print signal name */ 544 { 545 const char *s = raw? NULL : signame(pri, (int)val); 546 547 if (s == NULL) 548 prt_hex(pri, 0, val); 549 else 550 outstring(pri, s); 551 } 552 553 void 554 prt_smf(private_t *pri, int raw, long val) /* print streams message flags */ 555 { 556 switch (val) { 557 case 0: 558 prt_dec(pri, 0, val); 559 break; 560 case RS_HIPRI: 561 if (raw) 562 prt_hhx(pri, 0, val); 563 else 564 outstring(pri, "RS_HIPRI"); 565 break; 566 default: 567 prt_hhx(pri, 0, val); 568 break; 569 } 570 } 571 572 void 573 prt_mtf(private_t *pri, int raw, long val) /* print mount flags */ 574 { 575 const char *s = raw? NULL : mountflags(pri, val); 576 577 if (s == NULL) 578 prt_hex(pri, 0, val); 579 else 580 outstring(pri, s); 581 } 582 583 void 584 prt_mft(private_t *pri, int raw, long val) /* print mount file system type */ 585 { 586 if (val >= 0 && val < 256) 587 prt_dec(pri, 0, val); 588 else if (raw) 589 prt_hex(pri, 0, val); 590 else 591 prt_stg(pri, raw, val); 592 } 593 594 #define ISREAD(code) \ 595 ((code) == SYS_read || (code) == SYS_pread || (code) == SYS_pread64 || \ 596 (code) == SYS_recv || (code) == SYS_recvfrom) 597 #define ISWRITE(code) \ 598 ((code) == SYS_write || (code) == SYS_pwrite || \ 599 (code) == SYS_pwrite64 || (code) == SYS_send || (code) == SYS_sendto) 600 601 /* print contents of read() or write() I/O buffer */ 602 void 603 prt_iob(private_t *pri, int raw, long val) 604 { 605 const lwpstatus_t *Lsp = pri->lwpstat; 606 int syscall = Lsp->pr_what; 607 int fdp1 = pri->sys_args[0] + 1; 608 ssize_t nbyte = ISWRITE(syscall)? pri->sys_args[2] : 609 (pri->Errno? 0 : pri->Rval1); 610 int elsewhere = FALSE; /* TRUE iff dumped elsewhere */ 611 char buffer[IOBSIZE]; 612 613 pri->iob_buf[0] = '\0'; 614 615 if (Lsp->pr_why == PR_SYSEXIT && nbyte > IOBSIZE) { 616 if (ISREAD(syscall)) 617 elsewhere = prismember(&readfd, fdp1); 618 else 619 elsewhere = prismember(&writefd, fdp1); 620 } 621 622 if (nbyte <= 0 || elsewhere) 623 prt_hex(pri, 0, val); 624 else { 625 int nb = nbyte > IOBSIZE? IOBSIZE : (int)nbyte; 626 627 if (Pread(Proc, buffer, (size_t)nb, (long)val) != nb) 628 prt_hex(pri, 0, val); 629 else { 630 pri->iob_buf[0] = '"'; 631 showbytes(buffer, nb, pri->iob_buf + 1); 632 (void) strlcat(pri->iob_buf, 633 (nb == nbyte)? 634 (const char *)"\"" : (const char *)"\"..", 635 sizeof (pri->iob_buf)); 636 if (raw) 637 prt_hex(pri, 0, val); 638 else 639 outstring(pri, pri->iob_buf); 640 } 641 } 642 } 643 #undef ISREAD 644 #undef ISWRITE 645 646 void 647 prt_idt(private_t *pri, int raw, long val) /* print idtype_t, waitid() arg */ 648 { 649 const char *s = raw? NULL : idtype_enum(pri, val); 650 651 if (s == NULL) 652 prt_dec(pri, 0, val); 653 else 654 outstring(pri, s); 655 } 656 657 void 658 prt_wop(private_t *pri, int raw, long val) /* print waitid() options */ 659 { 660 const char *s = raw? NULL : woptions(pri, (int)val); 661 662 if (s == NULL) 663 prt_oct(pri, 0, val); 664 else 665 outstring(pri, s); 666 } 667 668 void 669 prt_whn(private_t *pri, int raw, long val) /* print lseek() whence argument */ 670 { 671 const char *s = raw? NULL : whencearg(val); 672 673 if (s == NULL) 674 prt_dec(pri, 0, val); 675 else 676 outstring(pri, s); 677 } 678 679 /*ARGSUSED*/ 680 void 681 prt_spm(private_t *pri, int raw, long val) /* print sigprocmask argument */ 682 { 683 const char *s = NULL; 684 685 if (!raw) { 686 switch (val) { 687 case SIG_BLOCK: s = "SIG_BLOCK"; break; 688 case SIG_UNBLOCK: s = "SIG_UNBLOCK"; break; 689 case SIG_SETMASK: s = "SIG_SETMASK"; break; 690 } 691 } 692 693 if (s == NULL) 694 prt_dec(pri, 0, val); 695 else 696 outstring(pri, s); 697 } 698 699 const char * 700 mmap_protect(private_t *pri, long arg) 701 { 702 char *str = pri->code_buf; 703 704 if (arg & ~(PROT_READ|PROT_WRITE|PROT_EXEC)) 705 return ((char *)NULL); 706 707 if (arg == PROT_NONE) 708 return ("PROT_NONE"); 709 710 *str = '\0'; 711 if (arg & PROT_READ) 712 (void) strlcat(str, "|PROT_READ", sizeof (pri->code_buf)); 713 if (arg & PROT_WRITE) 714 (void) strlcat(str, "|PROT_WRITE", sizeof (pri->code_buf)); 715 if (arg & PROT_EXEC) 716 (void) strlcat(str, "|PROT_EXEC", sizeof (pri->code_buf)); 717 return ((const char *)(str + 1)); 718 } 719 720 const char * 721 mmap_type(private_t *pri, long arg) 722 { 723 char *str = pri->code_buf; 724 size_t used; 725 726 #define CBSIZE sizeof (pri->code_buf) 727 switch (arg & MAP_TYPE) { 728 case MAP_SHARED: 729 used = strlcpy(str, "MAP_SHARED", CBSIZE); 730 break; 731 case MAP_PRIVATE: 732 used = strlcpy(str, "MAP_PRIVATE", CBSIZE); 733 break; 734 default: 735 used = snprintf(str, CBSIZE, "%ld", arg&MAP_TYPE); 736 break; 737 } 738 739 arg &= ~(_MAP_NEW|MAP_TYPE); 740 741 if (arg & ~(MAP_FIXED|MAP_RENAME|MAP_NORESERVE|MAP_ANON|MAP_ALIGN| 742 MAP_TEXT|MAP_INITDATA|MAP_32BIT)) 743 (void) snprintf(str + used, sizeof (pri->code_buf) - used, 744 "|0x%lX", arg); 745 else { 746 if (arg & MAP_FIXED) 747 (void) strlcat(str, "|MAP_FIXED", CBSIZE); 748 if (arg & MAP_RENAME) 749 (void) strlcat(str, "|MAP_RENAME", CBSIZE); 750 if (arg & MAP_NORESERVE) 751 (void) strlcat(str, "|MAP_NORESERVE", CBSIZE); 752 if (arg & MAP_ANON) 753 (void) strlcat(str, "|MAP_ANON", CBSIZE); 754 if (arg & MAP_ALIGN) 755 (void) strlcat(str, "|MAP_ALIGN", CBSIZE); 756 if (arg & MAP_TEXT) 757 (void) strlcat(str, "|MAP_TEXT", CBSIZE); 758 if (arg & MAP_INITDATA) 759 (void) strlcat(str, "|MAP_INITDATA", CBSIZE); 760 if (arg & MAP_32BIT) 761 (void) strlcat(str, "|MAP_32BIT", CBSIZE); 762 } 763 764 return ((const char *)str); 765 #undef CBSIZE 766 } 767 768 void 769 prt_mpr(private_t *pri, int raw, long val) /* print mmap()/mprotect() flags */ 770 { 771 const char *s = raw? NULL : mmap_protect(pri, val); 772 773 if (s == NULL) 774 prt_hhx(pri, 0, val); 775 else 776 outstring(pri, s); 777 } 778 779 void 780 prt_mty(private_t *pri, int raw, long val) /* print mmap() mapping type flags */ 781 { 782 const char *s = raw? NULL : mmap_type(pri, val); 783 784 if (s == NULL) 785 prt_hhx(pri, 0, val); 786 else 787 outstring(pri, s); 788 } 789 790 void 791 prt_mob(private_t *pri, int raw, long val) /* print mmapobj() flags */ 792 { 793 if (val == 0) 794 prt_dec(pri, 0, val); 795 else if (raw || (val & ~(MMOBJ_PADDING|MMOBJ_INTERPRET)) != 0) 796 prt_hhx(pri, 0, val); 797 else { 798 #define CBSIZE sizeof (pri->code_buf) 799 char *s = pri->code_buf; 800 801 *s = '\0'; 802 if (val & MMOBJ_PADDING) 803 (void) strlcat(s, "|MMOBJ_PADDING", CBSIZE); 804 if (val & MMOBJ_INTERPRET) 805 (void) strlcat(s, "|MMOBJ_INTERPRET", CBSIZE); 806 outstring(pri, s + 1); 807 #undef CBSIZE 808 } 809 } 810 811 /*ARGSUSED*/ 812 void 813 prt_mcf(private_t *pri, int raw, long val) /* print memcntl() function */ 814 { 815 const char *s = NULL; 816 817 if (!raw) { 818 switch (val) { 819 case MC_SYNC: s = "MC_SYNC"; break; 820 case MC_LOCK: s = "MC_LOCK"; break; 821 case MC_UNLOCK: s = "MC_UNLOCK"; break; 822 case MC_ADVISE: s = "MC_ADVISE"; break; 823 case MC_LOCKAS: s = "MC_LOCKAS"; break; 824 case MC_UNLOCKAS: s = "MC_UNLOCKAS"; break; 825 case MC_HAT_ADVISE: s = "MC_HAT_ADVISE"; break; 826 } 827 } 828 829 if (s == NULL) 830 prt_dec(pri, 0, val); 831 else 832 outstring(pri, s); 833 } 834 835 void 836 prt_mad(private_t *pri, int raw, long val) /* print madvise() argument */ 837 { 838 const char *s = NULL; 839 840 if (!raw) { 841 switch (val) { 842 case MADV_NORMAL: s = "MADV_NORMAL"; break; 843 case MADV_RANDOM: s = "MADV_RANDOM"; break; 844 case MADV_SEQUENTIAL: s = "MADV_SEQUENTIAL"; break; 845 case MADV_WILLNEED: s = "MADV_WILLNEED"; break; 846 case MADV_DONTNEED: s = "MADV_DONTNEED"; break; 847 case MADV_FREE: s = "MADV_FREE"; break; 848 case MADV_ACCESS_DEFAULT: s = "MADV_ACCESS_DEFAULT"; break; 849 case MADV_ACCESS_LWP: s = "MADV_ACCESS_LWP"; break; 850 case MADV_ACCESS_MANY: s = "MADV_ACCESS_MANY"; break; 851 case MADV_PURGE: s = "MADV_PURGE"; break; 852 } 853 } 854 855 if (s == NULL) 856 prt_dec(pri, 0, val); 857 else 858 outstring(pri, s); 859 } 860 861 void 862 prt_mc4(private_t *pri, int raw, long val) /* print memcntl() (4th) argument */ 863 { 864 if (val == 0) 865 prt_dec(pri, 0, val); 866 else if (raw) 867 prt_hhx(pri, 0, val); 868 else { 869 char *s = NULL; 870 871 #define CBSIZE sizeof (pri->code_buf) 872 /* cheating -- look at memcntl func */ 873 switch (pri->sys_args[2]) { 874 case MC_ADVISE: 875 prt_mad(pri, 0, val); 876 return; 877 878 case MC_SYNC: 879 if ((val & ~(MS_SYNC|MS_ASYNC|MS_INVALIDATE)) == 0) { 880 *(s = pri->code_buf) = '\0'; 881 if (val & MS_SYNC) 882 (void) strlcat(s, "|MS_SYNC", CBSIZE); 883 if (val & MS_ASYNC) 884 (void) strlcat(s, "|MS_ASYNC", CBSIZE); 885 if (val & MS_INVALIDATE) 886 (void) strlcat(s, "|MS_INVALIDATE", 887 CBSIZE); 888 } 889 break; 890 891 case MC_LOCKAS: 892 case MC_UNLOCKAS: 893 if ((val & ~(MCL_CURRENT|MCL_FUTURE)) == 0) { 894 *(s = pri->code_buf) = '\0'; 895 if (val & MCL_CURRENT) 896 (void) strlcat(s, "|MCL_CURRENT", 897 CBSIZE); 898 if (val & MCL_FUTURE) 899 (void) strlcat(s, "|MCL_FUTURE", 900 CBSIZE); 901 } 902 break; 903 } 904 #undef CBSIZE 905 906 if (s == NULL || *s == '\0') 907 prt_hhx(pri, 0, val); 908 else 909 outstring(pri, ++s); 910 } 911 } 912 913 void 914 prt_mc5(private_t *pri, int raw, long val) /* print memcntl() (5th) argument */ 915 { 916 char *s; 917 918 #define CBSIZE sizeof (pri->code_buf) 919 if (val == 0) 920 prt_dec(pri, 0, val); 921 else if (raw || (val & ~VALID_ATTR)) 922 prt_hhx(pri, 0, val); 923 else { 924 s = pri->code_buf; 925 *s = '\0'; 926 if (val & SHARED) 927 (void) strlcat(s, "|SHARED", CBSIZE); 928 if (val & PRIVATE) 929 (void) strlcat(s, "|PRIVATE", CBSIZE); 930 if (val & PROT_READ) 931 (void) strlcat(s, "|PROT_READ", CBSIZE); 932 if (val & PROT_WRITE) 933 (void) strlcat(s, "|PROT_WRITE", CBSIZE); 934 if (val & PROT_EXEC) 935 (void) strlcat(s, "|PROT_EXEC", CBSIZE); 936 if (*s == '\0') 937 prt_hhx(pri, 0, val); 938 else 939 outstring(pri, ++s); 940 } 941 #undef CBSIZE 942 } 943 944 void 945 prt_ulm(private_t *pri, int raw, long val) /* print ulimit() argument */ 946 { 947 const char *s = NULL; 948 949 if (!raw) { 950 switch (val) { 951 case UL_GFILLIM: s = "UL_GFILLIM"; break; 952 case UL_SFILLIM: s = "UL_SFILLIM"; break; 953 case UL_GMEMLIM: s = "UL_GMEMLIM"; break; 954 case UL_GDESLIM: s = "UL_GDESLIM"; break; 955 } 956 } 957 958 if (s == NULL) 959 prt_dec(pri, 0, val); 960 else 961 outstring(pri, s); 962 } 963 964 void 965 prt_rlm(private_t *pri, int raw, long val) /* print get/setrlimit() argument */ 966 { 967 const char *s = NULL; 968 969 if (!raw) { 970 switch (val) { 971 case RLIMIT_CPU: s = "RLIMIT_CPU"; break; 972 case RLIMIT_FSIZE: s = "RLIMIT_FSIZE"; break; 973 case RLIMIT_DATA: s = "RLIMIT_DATA"; break; 974 case RLIMIT_STACK: s = "RLIMIT_STACK"; break; 975 case RLIMIT_CORE: s = "RLIMIT_CORE"; break; 976 case RLIMIT_NOFILE: s = "RLIMIT_NOFILE"; break; 977 case RLIMIT_VMEM: s = "RLIMIT_VMEM"; break; 978 } 979 } 980 981 if (s == NULL) 982 prt_dec(pri, 0, val); 983 else 984 outstring(pri, s); 985 } 986 987 void 988 prt_cnf(private_t *pri, int raw, long val) /* print sysconfig code */ 989 { 990 const char *s = raw? NULL : sconfname(val); 991 992 if (s == NULL) 993 prt_dec(pri, 0, val); 994 else 995 outstring(pri, s); 996 } 997 998 void 999 prt_inf(private_t *pri, int raw, long val) /* print sysinfo code */ 1000 { 1001 const char *s = NULL; 1002 1003 if (!raw) { 1004 switch (val) { 1005 case SI_SYSNAME: s = "SI_SYSNAME"; break; 1006 case SI_HOSTNAME: s = "SI_HOSTNAME"; break; 1007 case SI_RELEASE: s = "SI_RELEASE"; break; 1008 case SI_VERSION: s = "SI_VERSION"; break; 1009 case SI_MACHINE: s = "SI_MACHINE"; break; 1010 case SI_ARCHITECTURE: s = "SI_ARCHITECTURE"; break; 1011 case SI_ARCHITECTURE_32:s = "SI_ARCHITECTURE_32"; break; 1012 case SI_ARCHITECTURE_64:s = "SI_ARCHITECTURE_64"; break; 1013 case SI_ARCHITECTURE_K: s = "SI_ARCHITECTURE_K"; break; 1014 case SI_HW_SERIAL: s = "SI_HW_SERIAL"; break; 1015 case SI_HW_PROVIDER: s = "SI_HW_PROVIDER"; break; 1016 case SI_SRPC_DOMAIN: s = "SI_SRPC_DOMAIN"; break; 1017 case SI_SET_HOSTNAME: s = "SI_SET_HOSTNAME"; break; 1018 case SI_SET_SRPC_DOMAIN: s = "SI_SET_SRPC_DOMAIN"; break; 1019 case SI_PLATFORM: s = "SI_PLATFORM"; break; 1020 case SI_ISALIST: s = "SI_ISALIST"; break; 1021 case SI_DHCP_CACHE: s = "SI_DHCP_CACHE"; break; 1022 } 1023 } 1024 1025 if (s == NULL) 1026 prt_dec(pri, 0, val); 1027 else 1028 outstring(pri, s); 1029 } 1030 1031 void 1032 prt_ptc(private_t *pri, int raw, long val) /* print pathconf code */ 1033 { 1034 const char *s = raw? NULL : pathconfname(val); 1035 1036 if (s == NULL) 1037 prt_dec(pri, 0, val); 1038 else 1039 outstring(pri, s); 1040 } 1041 1042 void 1043 prt_fui(private_t *pri, int raw, long val) /* print fusers() input argument */ 1044 { 1045 const char *s = raw? NULL : fuiname(val); 1046 1047 if (s == NULL) 1048 prt_hhx(pri, 0, val); 1049 else 1050 outstring(pri, s); 1051 } 1052 1053 void 1054 prt_lwf(private_t *pri, int raw, long val) /* print lwp_create() flags */ 1055 { 1056 char *s; 1057 1058 if (val == 0) 1059 prt_dec(pri, 0, val); 1060 else if (raw || 1061 (val & ~(LWP_DAEMON|LWP_DETACHED|LWP_SUSPENDED))) 1062 prt_hhx(pri, 0, val); 1063 else { 1064 #define CBSIZE sizeof (pri->code_buf) 1065 s = pri->code_buf; 1066 *s = '\0'; 1067 if (val & LWP_DAEMON) 1068 (void) strlcat(s, "|LWP_DAEMON", CBSIZE); 1069 if (val & LWP_DETACHED) 1070 (void) strlcat(s, "|LWP_DETACHED", CBSIZE); 1071 if (val & LWP_SUSPENDED) 1072 (void) strlcat(s, "|LWP_SUSPENDED", CBSIZE); 1073 outstring(pri, ++s); 1074 #undef CBSIZE 1075 } 1076 } 1077 1078 void 1079 prt_itm(private_t *pri, int raw, long val) /* print [get|set]itimer() arg */ 1080 { 1081 const char *s = NULL; 1082 1083 if (!raw) { 1084 switch (val) { 1085 case ITIMER_REAL: s = "ITIMER_REAL"; break; 1086 case ITIMER_VIRTUAL: s = "ITIMER_VIRTUAL"; break; 1087 case ITIMER_PROF: s = "ITIMER_PROF"; break; 1088 #ifdef ITIMER_REALPROF 1089 case ITIMER_REALPROF: s = "ITIMER_REALPROF"; break; 1090 #endif 1091 } 1092 } 1093 1094 if (s == NULL) 1095 prt_dec(pri, 0, val); 1096 else 1097 outstring(pri, s); 1098 } 1099 1100 void 1101 prt_mod(private_t *pri, int raw, long val) /* print modctl() code */ 1102 { 1103 const char *s = NULL; 1104 1105 if (!raw) { 1106 switch (val) { 1107 case MODLOAD: s = "MODLOAD"; break; 1108 case MODUNLOAD: s = "MODUNLOAD"; break; 1109 case MODINFO: s = "MODINFO"; break; 1110 case MODRESERVED: s = "MODRESERVED"; break; 1111 case MODSETMINIROOT: s = "MODSETMINIROOT"; break; 1112 case MODADDMAJBIND: s = "MODADDMAJBIND"; break; 1113 case MODGETPATH: s = "MODGETPATH"; break; 1114 case MODGETPATHLEN: s = "MODGETPATHLEN"; break; 1115 case MODREADSYSBIND: s = "MODREADSYSBIND"; break; 1116 case MODGETMAJBIND: s = "MODGETMAJBIND"; break; 1117 case MODGETNAME: s = "MODGETNAME"; break; 1118 case MODSIZEOF_DEVID: s = "MODSIZEOF_DEVID"; break; 1119 case MODGETDEVID: s = "MODGETDEVID"; break; 1120 case MODSIZEOF_MINORNAME: s = "MODSIZEOF_MINORNAME"; break; 1121 case MODGETMINORNAME: s = "MODGETMINORNAME"; break; 1122 case MODGETFBNAME: s = "MODGETFBNAME"; break; 1123 case MODEVENTS: s = "MODEVENTS"; break; 1124 case MODREREADDACF: s = "MODREREADDACF"; break; 1125 case MODLOADDRVCONF: s = "MODLOADDRVCONF"; break; 1126 case MODUNLOADDRVCONF: s = "MODUNLOADDRVCONF"; break; 1127 case MODREMMAJBIND: s = "MODREMMAJBIND"; break; 1128 case MODDEVT2INSTANCE: s = "MODDEVT2INSTANCE"; break; 1129 case MODGETDEVFSPATH_LEN: s = "MODGETDEVFSPATH_LEN"; break; 1130 case MODGETDEVFSPATH: s = "MODGETDEVFSPATH"; break; 1131 case MODDEVID2PATHS: s = "MODDEVID2PATHS"; break; 1132 case MODSETDEVPOLICY: s = "MODSETDEVPOLICY"; break; 1133 case MODGETDEVPOLICY: s = "MODGETDEVPOLICY"; break; 1134 case MODALLOCPRIV: s = "MODALLOCPRIV"; break; 1135 case MODGETDEVPOLICYBYNAME: 1136 s = "MODGETDEVPOLICYBYNAME"; break; 1137 case MODLOADMINORPERM: s = "MODLOADMINORPERM"; break; 1138 case MODADDMINORPERM: s = "MODADDMINORPERM"; break; 1139 case MODREMMINORPERM: s = "MODREMMINORPERM"; break; 1140 case MODREMDRVCLEANUP: s = "MODREMDRVCLEANUP"; break; 1141 case MODDEVEXISTS: s = "MODDEVEXISTS"; break; 1142 case MODDEVREADDIR: s = "MODDEVREADDIR"; break; 1143 case MODDEVEMPTYDIR: s = "MODDEVEMPTYDIR"; break; 1144 case MODDEVNAME: s = "MODDEVNAME"; break; 1145 case MODGETDEVFSPATH_MI_LEN: 1146 s = "MODGETDEVFSPATH_MI_LEN"; break; 1147 case MODGETDEVFSPATH_MI: 1148 s = "MODGETDEVFSPATH_MI"; break; 1149 case MODREMDRVALIAS: s = "MODREMDRVALIAS"; break; 1150 case MODHPOPS: s = "MODHPOPS"; break; 1151 } 1152 } 1153 1154 if (s == NULL) 1155 prt_dec(pri, 0, val); 1156 else 1157 outstring(pri, s); 1158 } 1159 1160 void 1161 prt_acl(private_t *pri, int raw, long val) /* print acl() code */ 1162 { 1163 const char *s = NULL; 1164 1165 if (!raw) { 1166 switch (val) { 1167 case GETACL: s = "GETACL"; break; 1168 case SETACL: s = "SETACL"; break; 1169 case GETACLCNT: s = "GETACLCNT"; break; 1170 case ACE_GETACL: s = "ACE_GETACL"; break; 1171 case ACE_SETACL: s = "ACE_SETACL"; break; 1172 case ACE_GETACLCNT: s = "ACE_GETACLCNT"; break; 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_aio(private_t *pri, int raw, long val) /* print kaio() code */ 1184 { 1185 const char *s = NULL; 1186 char buf[32]; 1187 1188 if (!raw) { 1189 switch (val & ~AIO_POLL_BIT) { 1190 case AIOREAD: s = "AIOREAD"; break; 1191 case AIOWRITE: s = "AIOWRITE"; break; 1192 case AIOWAIT: s = "AIOWAIT"; break; 1193 case AIOCANCEL: s = "AIOCANCEL"; break; 1194 case AIONOTIFY: s = "AIONOTIFY"; break; 1195 case AIOINIT: s = "AIOINIT"; break; 1196 case AIOSTART: s = "AIOSTART"; break; 1197 case AIOLIO: s = "AIOLIO"; break; 1198 case AIOSUSPEND: s = "AIOSUSPEND"; break; 1199 case AIOERROR: s = "AIOERROR"; break; 1200 case AIOLIOWAIT: s = "AIOLIOWAIT"; break; 1201 case AIOAREAD: s = "AIOAREAD"; break; 1202 case AIOAWRITE: s = "AIOAWRITE"; break; 1203 /* 1204 * We have to hardcode the values for the 64-bit versions of 1205 * these calls, because <sys/aio.h> defines them to be identical 1206 * when compiled 64-bit. If our target is 32-bit, we still need 1207 * to decode them correctly. 1208 */ 1209 case 13: s = "AIOLIO64"; break; 1210 case 14: s = "AIOSUSPEND64"; break; 1211 case 15: s = "AUIOERROR64"; break; 1212 case 16: s = "AIOLIOWAIT64"; break; 1213 case 17: s = "AIOAREAD64"; break; 1214 case 18: s = "AIOAWRITE64"; break; 1215 case 19: s = "AIOCANCEL64"; break; 1216 1217 /* 1218 * AIOFSYNC doesn't correspond to a syscall. 1219 */ 1220 case AIOWAITN: s = "AIOWAITN"; break; 1221 } 1222 if (s != NULL && (val & AIO_POLL_BIT)) { 1223 (void) strlcpy(buf, s, sizeof (buf)); 1224 (void) strlcat(buf, "|AIO_POLL_BIT", sizeof (buf)); 1225 s = (const char *)buf; 1226 } 1227 } 1228 1229 if (s == NULL) 1230 prt_dec(pri, 0, val); 1231 else 1232 outstring(pri, s); 1233 } 1234 1235 void 1236 prt_aud(private_t *pri, int raw, long val) /* print auditsys() code */ 1237 { 1238 const char *s = NULL; 1239 1240 if (!raw) { 1241 switch (val) { 1242 case BSM_GETAUID: s = "BSM_GETAUID"; break; 1243 case BSM_SETAUID: s = "BSM_SETAUID"; break; 1244 case BSM_GETAUDIT: s = "BSM_GETAUDIT"; break; 1245 case BSM_SETAUDIT: s = "BSM_SETAUDIT"; break; 1246 case BSM_AUDIT: s = "BSM_AUDIT"; break; 1247 case BSM_AUDITCTL: s = "BSM_AUDITCTL"; break; 1248 case BSM_GETAUDIT_ADDR: s = "BSM_GETAUDIT_ADDR"; break; 1249 case BSM_SETAUDIT_ADDR: s = "BSM_SETAUDIT_ADDR"; break; 1250 } 1251 } 1252 1253 if (s == NULL) 1254 prt_dec(pri, 0, val); 1255 else 1256 outstring(pri, s); 1257 } 1258 1259 void 1260 prt_cor(private_t *pri, int raw, long val) /* print corectl() subcode */ 1261 { 1262 const char *s = NULL; 1263 1264 if (!raw) { 1265 switch (val) { 1266 case CC_SET_OPTIONS: 1267 s = "CC_SET_OPTIONS"; break; 1268 case CC_GET_OPTIONS: 1269 s = "CC_GET_OPTIONS"; break; 1270 case CC_SET_GLOBAL_PATH: 1271 s = "CC_SET_GLOBAL_PATH"; break; 1272 case CC_GET_GLOBAL_PATH: 1273 s = "CC_GET_GLOBAL_PATH"; break; 1274 case CC_SET_PROCESS_PATH: 1275 s = "CC_SET_PROCESS_PATH"; break; 1276 case CC_GET_PROCESS_PATH: 1277 s = "CC_GET_PROCESS_PATH"; break; 1278 case CC_SET_GLOBAL_CONTENT: 1279 s = "CC_SET_GLOBAL_CONTENT"; break; 1280 case CC_GET_GLOBAL_CONTENT: 1281 s = "CC_GET_GLOBAL_CONTENT"; break; 1282 case CC_SET_PROCESS_CONTENT: 1283 s = "CC_SET_PROCESS_CONTENT"; break; 1284 case CC_GET_PROCESS_CONTENT: 1285 s = "CC_GET_PROCESS_CONTENT"; break; 1286 case CC_SET_DEFAULT_PATH: 1287 s = "CC_SET_DEFAULT_PATH"; break; 1288 case CC_GET_DEFAULT_PATH: 1289 s = "CC_GET_DEFAULT_PATH"; break; 1290 case CC_SET_DEFAULT_CONTENT: 1291 s = "CC_SET_DEFAULT_CONTENT"; break; 1292 case CC_GET_DEFAULT_CONTENT: 1293 s = "CC_GET_DEFAULT_CONTENT"; break; 1294 } 1295 } 1296 1297 if (s == NULL) 1298 prt_dec(pri, 0, val); 1299 else 1300 outstring(pri, s); 1301 } 1302 1303 void 1304 prt_cco(private_t *pri, int raw, long val) /* print corectl() options */ 1305 { 1306 char *s; 1307 1308 if (val == 0) 1309 prt_dec(pri, 0, val); 1310 else if (raw || (val & ~CC_OPTIONS)) 1311 prt_hhx(pri, 0, val); 1312 else { 1313 #define CBSIZE sizeof (pri->code_buf) 1314 s = pri->code_buf; 1315 *s = '\0'; 1316 if (val & CC_GLOBAL_PATH) 1317 (void) strlcat(s, "|CC_GLOBAL_PATH", CBSIZE); 1318 if (val & CC_PROCESS_PATH) 1319 (void) strlcat(s, "|CC_PROCESS_PATH", CBSIZE); 1320 if (val & CC_GLOBAL_SETID) 1321 (void) strlcat(s, "|CC_GLOBAL_SETID", CBSIZE); 1322 if (val & CC_PROCESS_SETID) 1323 (void) strlcat(s, "|CC_PROCESS_SETID", CBSIZE); 1324 if (val & CC_GLOBAL_LOG) 1325 (void) strlcat(s, "|CC_GLOBAL_LOG", CBSIZE); 1326 if (*s == '\0') 1327 prt_hhx(pri, 0, val); 1328 else 1329 outstring(pri, ++s); 1330 #undef CBSIZE 1331 } 1332 } 1333 1334 void 1335 prt_ccc(private_t *pri, int raw, long val) /* print corectl() content */ 1336 { 1337 core_content_t ccc; 1338 1339 if (Pread(Proc, &ccc, sizeof (ccc), val) != sizeof (ccc)) 1340 prt_hex(pri, 0, val); 1341 else if (!raw && proc_content2str(ccc, pri->code_buf, 1342 sizeof (pri->code_buf)) >= 0) 1343 outstring(pri, pri->code_buf); 1344 else 1345 prt_hhx(pri, 0, (long)ccc); 1346 } 1347 1348 void 1349 prt_rcc(private_t *pri, int raw, long val) /* print corectl() ret. cont. */ 1350 { 1351 core_content_t ccc; 1352 1353 if (pri->Errno || Pread(Proc, &ccc, sizeof (ccc), val) != sizeof (ccc)) 1354 prt_hex(pri, 0, val); 1355 else if (!raw && proc_content2str(ccc, pri->code_buf, 1356 sizeof (pri->code_buf)) >= 0) 1357 outstring(pri, pri->code_buf); 1358 else 1359 prt_hhx(pri, 0, (long)ccc); 1360 } 1361 1362 void 1363 prt_cpc(private_t *pri, int raw, long val) /* print cpc() subcode */ 1364 { 1365 const char *s = NULL; 1366 1367 if (!raw) { 1368 switch (val) { 1369 case CPC_BIND: s = "CPC_BIND"; break; 1370 case CPC_SAMPLE: s = "CPC_SAMPLE"; break; 1371 case CPC_INVALIDATE: s = "CPC_INVALIDATE"; break; 1372 case CPC_RELE: s = "CPC_RELE"; break; 1373 case CPC_EVLIST_SIZE: s = "CPC_EVLIST_SIZE"; break; 1374 case CPC_LIST_EVENTS: s = "CPC_LIST_EVENTS"; break; 1375 case CPC_ATTRLIST_SIZE: s = "CPC_ATTRLIST_SIZE"; break; 1376 case CPC_LIST_ATTRS: s = "CPC_LIST_ATTRS"; break; 1377 case CPC_IMPL_NAME: s = "CPC_IMPL_NAME"; break; 1378 case CPC_CPUREF: s = "CPC_CPUREF"; break; 1379 case CPC_USR_EVENTS: s = "CPC_USR_EVENTS"; break; 1380 case CPC_SYS_EVENTS: s = "CPC_SYS_EVENTS"; break; 1381 case CPC_NPIC: s = "CPC_NPIC"; break; 1382 case CPC_CAPS: s = "CPC_CAPS"; break; 1383 case CPC_ENABLE: s = "CPC_ENABLE"; break; 1384 case CPC_DISABLE: s = "CPC_DISABLE"; break; 1385 } 1386 } 1387 1388 if (s == NULL) 1389 prt_dec(pri, 0, val); 1390 else 1391 outstring(pri, s); 1392 } 1393 1394 void 1395 outstring(private_t *pri, const char *s) 1396 { 1397 int len = strlen(s); 1398 1399 GROW(len); 1400 (void) strcpy(pri->sys_string + pri->sys_leng, s); 1401 pri->sys_leng += len; 1402 } 1403 1404 void 1405 grow(private_t *pri, int nbyte) /* reallocate format buffer if necessary */ 1406 { 1407 while (pri->sys_leng + nbyte >= pri->sys_ssize) 1408 pri->sys_string = my_realloc(pri->sys_string, 1409 pri->sys_ssize *= 2, "format buffer"); 1410 } 1411 1412 void 1413 prt_clc(private_t *pri, int raw, long val) 1414 { 1415 const char *s = NULL; 1416 1417 if (!raw) { 1418 switch (val) { 1419 case CL_INITIALIZE: s = "CL_INITIALIZE"; break; 1420 case CL_CONFIG: s = "CL_CONFIG"; break; 1421 } 1422 } 1423 1424 if (s == NULL) 1425 prt_dec(pri, 0, val); 1426 else 1427 outstring(pri, s); 1428 } 1429 1430 void 1431 prt_clf(private_t *pri, int raw, long val) 1432 { 1433 const char *s = NULL; 1434 1435 if (!raw) { 1436 switch (pri->sys_args[0]) { 1437 case CL_CONFIG: 1438 switch (pri->sys_args[1]) { 1439 case CL_NODEID: 1440 s = "CL_NODEID"; break; 1441 case CL_HIGHEST_NODEID: 1442 s = "CL_HIGHEST_NODEID"; break; 1443 } 1444 break; 1445 case CL_INITIALIZE: 1446 switch (pri->sys_args[1]) { 1447 case CL_GET_BOOTFLAG: 1448 s = "CL_GET_BOOTFLAG"; break; 1449 } 1450 break; 1451 } 1452 } 1453 1454 if (s == NULL) 1455 prt_dec(pri, 0, val); 1456 else 1457 outstring(pri, s); 1458 } 1459 1460 void 1461 prt_sqc(private_t *pri, int raw, long val) /* print sigqueue() si_code */ 1462 { 1463 const char *s = NULL; 1464 1465 if (!raw) { 1466 switch ((int)val) { 1467 case SI_QUEUE: s = "SI_QUEUE"; break; 1468 case SI_TIMER: s = "SI_TIMER"; break; 1469 case SI_ASYNCIO: s = "SI_ASYNCIO"; break; 1470 case SI_MESGQ: s = "SI_MESGQ"; break; 1471 } 1472 } 1473 1474 if (s == NULL) 1475 prt_dec(pri, 0, val); 1476 else 1477 outstring(pri, s); 1478 } 1479 1480 /* 1481 * print priocntlsys() (key, value) pair key. 1482 */ 1483 void 1484 print_pck(private_t *pri, int raw, long val) 1485 { 1486 const char *s = NULL; 1487 char clname[PC_CLNMSZ]; 1488 1489 if ((pri->sys_args[2] != PC_GETXPARMS && 1490 pri->sys_args[2] != PC_SETXPARMS) || val == 0 || raw) { 1491 prt_dec(pri, 0, val); 1492 return; 1493 } 1494 1495 if (pri->sys_args[3] == 0) { 1496 if (val == PC_KY_CLNAME) { 1497 s = "PC_KY_CLNAME"; 1498 outstring(pri, s); 1499 } else 1500 prt_dec(pri, 0, val); 1501 return; 1502 } 1503 1504 if (Pread(Proc, &clname, PC_CLNMSZ, pri->sys_args[3]) != PC_CLNMSZ) { 1505 prt_dec(pri, 0, val); 1506 return; 1507 } 1508 1509 if (strcmp(clname, "TS") == 0) { 1510 switch (val) { 1511 case TS_KY_UPRILIM: s = "TS_KY_UPRILIM"; break; 1512 case TS_KY_UPRI: s = "TS_KY_UPRI"; break; 1513 default: break; 1514 } 1515 } else if (strcmp(clname, "IA") == 0) { 1516 switch (val) { 1517 case IA_KY_UPRILIM: s = "IA_KY_UPRILIM"; break; 1518 case IA_KY_UPRI: s = "IA_KY_UPRI"; break; 1519 case IA_KY_MODE: s = "IA_KY_MODE"; break; 1520 default: break; 1521 } 1522 } else if (strcmp(clname, "RT") == 0) { 1523 switch (val) { 1524 case RT_KY_PRI: s = "RT_KY_PRI"; break; 1525 case RT_KY_TQSECS: s = "RT_KY_TQSECS"; break; 1526 case RT_KY_TQNSECS: s = "RT_KY_TQNSECS"; break; 1527 case RT_KY_TQSIG: s = "RT_KY_TQSIG"; break; 1528 default: break; 1529 } 1530 } else if (strcmp(clname, "FSS") == 0) { 1531 switch (val) { 1532 case FSS_KY_UPRILIM: s = "FSS_KY_UPRILIM"; break; 1533 case FSS_KY_UPRI: s = "FSS_KY_UPRI"; break; 1534 default: break; 1535 } 1536 } else if (strcmp(clname, "FX") == 0) { 1537 switch (val) { 1538 case FX_KY_UPRILIM: s = "FX_KY_UPRILIM"; break; 1539 case FX_KY_UPRI: s = "FX_KY_UPRI"; break; 1540 case FX_KY_TQSECS: s = "FX_KY_TQSECS"; break; 1541 case FX_KY_TQNSECS: s = "FX_KY_TQNSECS"; break; 1542 default: break; 1543 } 1544 } 1545 1546 if (s == NULL) 1547 prt_dec(pri, 0, val); 1548 else 1549 outstring(pri, s); 1550 } 1551 1552 /* 1553 * print priocntlsys() fourth argument. 1554 */ 1555 /*ARGSUSED*/ 1556 void 1557 prt_pc4(private_t *pri, int raw, long val) 1558 { 1559 /* look at pricntlsys function */ 1560 if ((pri->sys_args[2] != PC_GETXPARMS && 1561 pri->sys_args[2] != PC_SETXPARMS)) 1562 prt_hex(pri, 0, val); 1563 else if (val) 1564 prt_stg(pri, 0, val); 1565 else 1566 prt_dec(pri, 0, val); 1567 } 1568 1569 /* 1570 * print priocntlsys() (key, value) pairs (5th argument). 1571 */ 1572 /*ARGSUSED*/ 1573 void 1574 prt_pc5(private_t *pri, int raw, long val) 1575 { 1576 pc_vaparms_t prms; 1577 pc_vaparm_t *vpp = &prms.pc_parms[0]; 1578 uint_t cnt; 1579 1580 1581 /* look at pricntlsys function */ 1582 if ((pri->sys_args[2] != PC_GETXPARMS && 1583 pri->sys_args[2] != PC_SETXPARMS) || val == 0) { 1584 prt_dec(pri, 0, 0); 1585 return; 1586 } 1587 1588 if (Pread(Proc, &prms, sizeof (prms), val) != sizeof (prms)) { 1589 prt_hex(pri, 0, val); 1590 return; 1591 } 1592 1593 if ((cnt = prms.pc_vaparmscnt) > PC_VAPARMCNT) 1594 return; 1595 1596 for (; cnt--; vpp++) { 1597 print_pck(pri, 0, vpp->pc_key); 1598 outstring(pri, ", "); 1599 prt_hex(pri, 0, (long)vpp->pc_parm); 1600 outstring(pri, ", "); 1601 } 1602 1603 prt_dec(pri, 0, PC_KY_NULL); 1604 } 1605 1606 1607 void 1608 prt_psflags(private_t *pri, secflagset_t val) 1609 { 1610 size_t len; 1611 char *ptr; 1612 char str[1024]; 1613 1614 if (val == 0) { 1615 outstring(pri, "0x0"); 1616 return; 1617 } 1618 1619 *str = '\0'; 1620 if (secflag_isset(val, PROC_SEC_ASLR)) { 1621 (void) strlcat(str, "|PROC_SEC_ASLR", sizeof (str)); 1622 secflag_clear(&val, PROC_SEC_ASLR); 1623 } 1624 if (secflag_isset(val, PROC_SEC_FORBIDNULLMAP)) { 1625 (void) strlcat(str, "|PROC_SEC_FORBIDNULLMAP", 1626 sizeof (str)); 1627 secflag_clear(&val, PROC_SEC_FORBIDNULLMAP); 1628 } 1629 if (secflag_isset(val, PROC_SEC_NOEXECSTACK)) { 1630 (void) strlcat(str, "|PROC_SEC_NOEXECSTACK", 1631 sizeof (str)); 1632 secflag_clear(&val, PROC_SEC_NOEXECSTACK); 1633 } 1634 1635 if (val != 0) { 1636 len = strlen(str); 1637 ptr = str + len; 1638 (void) snprintf(ptr, sizeof (str) - len, "|%#x", val); 1639 } 1640 1641 outstring(pri, str + 1); 1642 } 1643 1644 /* 1645 * Print a psecflags(2) delta 1646 */ 1647 void 1648 prt_psdelta(private_t *pri, int raw, long value) 1649 { 1650 secflagdelta_t psd; 1651 1652 if ((raw != 0) || 1653 (Pread(Proc, &psd, sizeof (psd), value) != sizeof (psd))) { 1654 prt_hex(pri, 0, value); 1655 return; 1656 } 1657 outstring(pri, "{ "); 1658 prt_psflags(pri, psd.psd_add); 1659 outstring(pri, ", "); 1660 prt_psflags(pri, psd.psd_rem); 1661 outstring(pri, ", "); 1662 prt_psflags(pri, psd.psd_assign); 1663 outstring(pri, ", "); 1664 outstring(pri, psd.psd_ass_active ? "B_TRUE" : "B_FALSE"); 1665 outstring(pri, " }"); 1666 } 1667 1668 /* 1669 * Print a psecflagswhich_t 1670 */ 1671 void 1672 prt_psfw(private_t *pri, int raw, long value) 1673 { 1674 psecflagwhich_t which = (psecflagwhich_t)value; 1675 char *s; 1676 1677 if (raw != 0) { 1678 prt_dec(pri, 0, value); 1679 return; 1680 } 1681 1682 switch (which) { 1683 case PSF_EFFECTIVE: 1684 s = "PSF_EFFECTIVE"; 1685 break; 1686 case PSF_INHERIT: 1687 s = "PSF_INHERIT"; 1688 break; 1689 case PSF_LOWER: 1690 s = "PSF_LOWER"; 1691 break; 1692 case PSF_UPPER: 1693 s = "PSF_UPPER"; 1694 break; 1695 } 1696 1697 if (s == NULL) 1698 prt_dec(pri, 0, value); 1699 else 1700 outstring(pri, s); 1701 } 1702 1703 /* 1704 * Print processor set id, including logical expansion of "special" ids. 1705 */ 1706 void 1707 prt_pst(private_t *pri, int raw, long val) 1708 { 1709 const char *s = NULL; 1710 1711 if (!raw) { 1712 switch ((psetid_t)val) { 1713 case PS_NONE: s = "PS_NONE"; break; 1714 case PS_QUERY: s = "PS_QUERY"; break; 1715 case PS_MYID: s = "PS_MYID"; break; 1716 } 1717 } 1718 1719 if (s == NULL) 1720 prt_dec(pri, 0, val); 1721 else 1722 outstring(pri, s); 1723 } 1724 1725 /* 1726 * Print meminfo() argument. 1727 */ 1728 /*ARGSUSED*/ 1729 void 1730 prt_mif(private_t *pri, int raw, long val) 1731 { 1732 struct meminfo minfo; 1733 1734 if (data_model == PR_MODEL_ILP32) { 1735 struct meminfo32 minfo32; 1736 1737 if (Pread(Proc, &minfo32, sizeof (struct meminfo32), val) != 1738 sizeof (struct meminfo32)) { 1739 prt_dec(pri, 0, pri->sys_args[1]); /* addr_count */ 1740 outstring(pri, ", "); 1741 prt_hex(pri, 0, val); 1742 return; 1743 } 1744 /* 1745 * arrange the arguments in the order that user calls with 1746 */ 1747 prt_hex(pri, 0, minfo32.mi_inaddr); 1748 outstring(pri, ", "); 1749 prt_dec(pri, 0, pri->sys_args[1]); /* addr_count */ 1750 outstring(pri, ", "); 1751 prt_hex(pri, 0, minfo32.mi_info_req); 1752 outstring(pri, ", "); 1753 prt_dec(pri, 0, minfo32.mi_info_count); 1754 outstring(pri, ", "); 1755 prt_hex(pri, 0, minfo32.mi_outdata); 1756 outstring(pri, ", "); 1757 prt_hex(pri, 0, minfo32.mi_validity); 1758 return; 1759 } 1760 if (Pread(Proc, &minfo, sizeof (struct meminfo), val) != 1761 sizeof (struct meminfo)) { 1762 prt_dec(pri, 0, pri->sys_args[1]); /* addr_count */ 1763 outstring(pri, ", "); 1764 prt_hex(pri, 0, val); 1765 return; 1766 } 1767 /* 1768 * arrange the arguments in the order that user calls with 1769 */ 1770 prt_hex(pri, 0, (long)minfo.mi_inaddr); 1771 outstring(pri, ", "); 1772 prt_dec(pri, 0, pri->sys_args[1]); /* addr_count */ 1773 outstring(pri, ", "); 1774 prt_hex(pri, 0, (long)minfo.mi_info_req); 1775 outstring(pri, ", "); 1776 prt_dec(pri, 0, minfo.mi_info_count); 1777 outstring(pri, ", "); 1778 prt_hex(pri, 0, (long)minfo.mi_outdata); 1779 outstring(pri, ", "); 1780 prt_hex(pri, 0, (long)minfo.mi_validity); 1781 } 1782 1783 1784 /* 1785 * Print so_socket() 1st argument. 1786 */ 1787 /*ARGSUSED*/ 1788 void 1789 prt_pfm(private_t *pri, int raw, long val) 1790 { 1791 /* Protocol Families have same names as Address Families */ 1792 if ((ulong_t)val < MAX_AFCODES) { 1793 outstring(pri, "PF_"); 1794 outstring(pri, afcodes[val]); 1795 } else { 1796 prt_dec(pri, 0, val); 1797 } 1798 } 1799 1800 /* 1801 * Print sockconfig() subcode. 1802 */ 1803 /*ARGSUSED*/ 1804 void 1805 prt_skc(private_t *pri, int raw, long val) 1806 { 1807 const char *s = NULL; 1808 1809 if (!raw) { 1810 switch (val) { 1811 case SOCKCONFIG_ADD_SOCK: 1812 s = "SOCKCONFIG_ADD_SOCK"; break; 1813 case SOCKCONFIG_REMOVE_SOCK: 1814 s = "SOCKCONFIG_REMOVE_SOCK"; break; 1815 case SOCKCONFIG_ADD_FILTER: 1816 s = "SOCKCONFIG_ADD_FILTER"; break; 1817 case SOCKCONFIG_REMOVE_FILTER: 1818 s = "SOCKCONFIG_REMOVE_FILTER"; break; 1819 } 1820 } 1821 if (s == NULL) 1822 prt_dec(pri, 0, val); 1823 else 1824 outstring(pri, s); 1825 } 1826 /* 1827 * Print so_socket() 2nd argument. 1828 */ 1829 /*ARGSUSED*/ 1830 void 1831 prt_skt(private_t *pri, int raw, long val) 1832 { 1833 const char *s; 1834 long type = val & SOCK_TYPE_MASK; 1835 1836 if ((ulong_t)type <= MAX_SOCKTYPES && 1837 (s = socktype_codes[type]) != NULL) { 1838 outstring(pri, s); 1839 if ((val & SOCK_CLOEXEC) != 0) { 1840 outstring(pri, "|SOCK_CLOEXEC"); 1841 } 1842 } else { 1843 prt_dec(pri, 0, val); 1844 } 1845 } 1846 1847 1848 /* 1849 * Print so_socket() 3rd argument. 1850 */ 1851 /*ARGSUSED*/ 1852 void 1853 prt_skp(private_t *pri, int raw, long val) 1854 { 1855 const char *s; 1856 1857 /* cheating -- look at the protocol-family */ 1858 switch (pri->sys_args[0]) { 1859 case PF_INET6: 1860 case PF_INET: 1861 if ((s = ipprotos((int)val)) != NULL) { 1862 outstring(pri, s); 1863 break; 1864 } 1865 /* FALLTHROUGH */ 1866 default: 1867 prt_dec(pri, 0, val); 1868 break; 1869 } 1870 } 1871 1872 1873 /* 1874 * Print so_socket() 5th argument. 1875 */ 1876 /*ARGSUSED*/ 1877 void 1878 prt_skv(private_t *pri, int raw, long val) 1879 { 1880 switch (val) { 1881 case SOV_STREAM: outstring(pri, "SOV_STREAM"); break; 1882 case SOV_DEFAULT: outstring(pri, "SOV_DEFAULT"); break; 1883 case SOV_SOCKSTREAM: outstring(pri, "SOV_SOCKSTREAM"); break; 1884 case SOV_SOCKBSD: outstring(pri, "SOV_SOCKBSD"); break; 1885 case SOV_XPG4_2: outstring(pri, "SOV_XPG4_2"); break; 1886 default: prt_dec(pri, 0, val); break; 1887 } 1888 } 1889 1890 /* 1891 * Print accept4() flags argument. 1892 */ 1893 void 1894 prt_acf(private_t *pri, int raw, long val) 1895 { 1896 int first = 1; 1897 if (raw || !val || 1898 (val & ~(SOCK_CLOEXEC|SOCK_NDELAY|SOCK_NONBLOCK))) { 1899 prt_dex(pri, 0, val); 1900 return; 1901 } 1902 1903 if (val & SOCK_CLOEXEC) { 1904 outstring(pri, "|SOCK_CLOEXEC" + first); 1905 first = 0; 1906 } 1907 if (val & SOCK_NDELAY) { 1908 outstring(pri, "|SOCK_NDELAY" + first); 1909 first = 0; 1910 } 1911 if (val & SOCK_NONBLOCK) { 1912 outstring(pri, "|SOCK_NONBLOCK" + first); 1913 } 1914 } 1915 1916 1917 /* 1918 * Print setsockopt()/getsockopt() 2nd argument. 1919 */ 1920 /*ARGSUSED*/ 1921 void 1922 prt_sol(private_t *pri, int raw, long val) 1923 { 1924 if (val == SOL_SOCKET) { 1925 outstring(pri, "SOL_SOCKET"); 1926 } else if (val == SOL_ROUTE) { 1927 outstring(pri, "SOL_ROUTE"); 1928 } else { 1929 const struct protoent *p; 1930 struct protoent res; 1931 char buf[NSS_BUFLEN_PROTOCOLS]; 1932 1933 if ((p = getprotobynumber_r(val, &res, 1934 (char *)buf, sizeof (buf))) != NULL) 1935 outstring(pri, p->p_name); 1936 else 1937 prt_dec(pri, 0, val); 1938 } 1939 } 1940 1941 1942 const char * 1943 sol_optname(private_t *pri, long val) 1944 { 1945 #define CBSIZE sizeof (pri->code_buf) 1946 if (val >= SO_SNDBUF) { 1947 switch (val) { 1948 case SO_SNDBUF: return ("SO_SNDBUF"); 1949 case SO_RCVBUF: return ("SO_RCVBUF"); 1950 case SO_SNDLOWAT: return ("SO_SNDLOWAT"); 1951 case SO_RCVLOWAT: return ("SO_RCVLOWAT"); 1952 case SO_SNDTIMEO: return ("SO_SNDTIMEO"); 1953 case SO_RCVTIMEO: return ("SO_RCVTIMEO"); 1954 case SO_ERROR: return ("SO_ERROR"); 1955 case SO_TYPE: return ("SO_TYPE"); 1956 case SO_PROTOTYPE: return ("SO_PROTOTYPE"); 1957 case SO_ANON_MLP: return ("SO_ANON_MLP"); 1958 case SO_MAC_EXEMPT: return ("SO_MAC_EXEMPT"); 1959 case SO_ALLZONES: return ("SO_ALLZONES"); 1960 case SO_MAC_IMPLICIT: return ("SO_MAC_IMPLICIT"); 1961 case SO_VRRP: return ("SO_VRRP"); 1962 case SO_EXCLBIND: return ("SO_EXCLBIND"); 1963 case SO_DOMAIN: return ("SO_DOMAIN"); 1964 1965 default: (void) snprintf(pri->code_buf, CBSIZE, 1966 "0x%lx", val); 1967 return (pri->code_buf); 1968 } 1969 } else { 1970 char *s = pri->code_buf; 1971 size_t used = 1; 1972 long val2; 1973 1974 *s = '\0'; 1975 val2 = val & ~(SO_DEBUG|SO_ACCEPTCONN|SO_REUSEADDR|SO_KEEPALIVE| 1976 SO_DONTROUTE|SO_BROADCAST|SO_USELOOPBACK|SO_LINGER| 1977 SO_OOBINLINE|SO_DGRAM_ERRIND|SO_RECVUCRED); 1978 if (val2) 1979 used = snprintf(s, CBSIZE, "|0x%lx", val2); 1980 if (val & SO_DEBUG) 1981 used = strlcat(s, "|SO_DEBUG", CBSIZE); 1982 if (val & SO_ACCEPTCONN) 1983 used = strlcat(s, "|SO_ACCEPTCONN", CBSIZE); 1984 if (val & SO_REUSEADDR) 1985 used = strlcat(s, "|SO_REUSEADDR", CBSIZE); 1986 if (val & SO_KEEPALIVE) 1987 used = strlcat(s, "|SO_KEEPALIVE", CBSIZE); 1988 if (val & SO_DONTROUTE) 1989 used = strlcat(s, "|SO_DONTROUTE", CBSIZE); 1990 if (val & SO_BROADCAST) 1991 used = strlcat(s, "|SO_BROADCAST", CBSIZE); 1992 if (val & SO_USELOOPBACK) 1993 used = strlcat(s, "|SO_USELOOPBACK", CBSIZE); 1994 if (val & SO_LINGER) 1995 used = strlcat(s, "|SO_LINGER", CBSIZE); 1996 if (val & SO_OOBINLINE) 1997 used = strlcat(s, "|SO_OOBINLINE", CBSIZE); 1998 if (val & SO_DGRAM_ERRIND) 1999 used = strlcat(s, "|SO_DGRAM_ERRIND", CBSIZE); 2000 if (val & SO_RECVUCRED) 2001 used = strlcat(s, "|SO_RECVUCRED", CBSIZE); 2002 if (used >= CBSIZE || val == 0) 2003 (void) snprintf(s + 1, CBSIZE-1, "0x%lx", val); 2004 return ((const char *)(s + 1)); 2005 } 2006 #undef CBSIZE 2007 } 2008 2009 const char * 2010 route_optname(private_t *pri, long val) 2011 { 2012 switch (val) { 2013 case RT_AWARE: 2014 return ("RT_AWARE"); 2015 default: 2016 (void) snprintf(pri->code_buf, sizeof (pri->code_buf), 2017 "0x%lx", val); 2018 return (pri->code_buf); 2019 } 2020 } 2021 2022 const char * 2023 tcp_optname(private_t *pri, long val) 2024 { 2025 switch (val) { 2026 case TCP_NODELAY: return ("TCP_NODELAY"); 2027 case TCP_MAXSEG: return ("TCP_MAXSEG"); 2028 case TCP_KEEPALIVE: return ("TCP_KEEPALIVE"); 2029 case TCP_NOTIFY_THRESHOLD: return ("TCP_NOTIFY_THRESHOLD"); 2030 case TCP_ABORT_THRESHOLD: return ("TCP_ABORT_THRESHOLD"); 2031 case TCP_CONN_NOTIFY_THRESHOLD: return ("TCP_CONN_NOTIFY_THRESHOLD"); 2032 case TCP_CONN_ABORT_THRESHOLD: return ("TCP_CONN_ABORT_THRESHOLD"); 2033 case TCP_RECVDSTADDR: return ("TCP_RECVDSTADDR"); 2034 case TCP_ANONPRIVBIND: return ("TCP_ANONPRIVBIND"); 2035 case TCP_EXCLBIND: return ("TCP_EXCLBIND"); 2036 case TCP_INIT_CWND: return ("TCP_INIT_CWND"); 2037 case TCP_KEEPALIVE_THRESHOLD: return ("TCP_KEEPALIVE_THRESHOLD"); 2038 case TCP_KEEPALIVE_ABORT_THRESHOLD: 2039 return ("TCP_KEEPALIVE_ABORT_THRESHOLD"); 2040 case TCP_CORK: return ("TCP_CORK"); 2041 case TCP_RTO_INITIAL: return ("TCP_RTO_INITIAL"); 2042 case TCP_RTO_MIN: return ("TCP_RTO_MIN"); 2043 case TCP_RTO_MAX: return ("TCP_RTO_MAX"); 2044 case TCP_LINGER2: return ("TCP_LINGER2"); 2045 case TCP_KEEPIDLE: return ("TCP_KEEPIDLE"); 2046 case TCP_KEEPCNT: return ("TCP_KEEPCNT"); 2047 case TCP_KEEPINTVL: return ("TCP_KEEPINTVL"); 2048 case TCP_CONGESTION: return ("TCP_CONGESTION"); 2049 2050 default: (void) snprintf(pri->code_buf, 2051 sizeof (pri->code_buf), 2052 "0x%lx", val); 2053 return (pri->code_buf); 2054 } 2055 } 2056 2057 2058 const char * 2059 sctp_optname(private_t *pri, long val) 2060 { 2061 switch (val) { 2062 case SCTP_RTOINFO: return ("SCTP_RTOINFO"); 2063 case SCTP_ASSOCINFO: return ("SCTP_ASSOCINFO"); 2064 case SCTP_INITMSG: return ("SCTP_INITMSG"); 2065 case SCTP_NODELAY: return ("SCTP_NODELAY"); 2066 case SCTP_AUTOCLOSE: return ("SCTP_AUTOCLOSE"); 2067 case SCTP_SET_PEER_PRIMARY_ADDR: 2068 return ("SCTP_SET_PEER_PRIMARY_ADDR"); 2069 case SCTP_PRIMARY_ADDR: return ("SCTP_PRIMARY_ADDR"); 2070 case SCTP_ADAPTATION_LAYER: return ("SCTP_ADAPTATION_LAYER"); 2071 case SCTP_DISABLE_FRAGMENTS: return ("SCTP_DISABLE_FRAGMENTS"); 2072 case SCTP_PEER_ADDR_PARAMS: return ("SCTP_PEER_ADDR_PARAMS"); 2073 case SCTP_DEFAULT_SEND_PARAM: return ("SCTP_DEFAULT_SEND_PARAM"); 2074 case SCTP_EVENTS: return ("SCTP_EVENTS"); 2075 case SCTP_I_WANT_MAPPED_V4_ADDR: 2076 return ("SCTP_I_WANT_MAPPED_V4_ADDR"); 2077 case SCTP_MAXSEG: return ("SCTP_MAXSEG"); 2078 case SCTP_STATUS: return ("SCTP_STATUS"); 2079 case SCTP_GET_PEER_ADDR_INFO: return ("SCTP_GET_PEER_ADDR_INFO"); 2080 2081 case SCTP_ADD_ADDR: return ("SCTP_ADD_ADDR"); 2082 case SCTP_REM_ADDR: return ("SCTP_REM_ADDR"); 2083 2084 default: (void) snprintf(pri->code_buf, 2085 sizeof (pri->code_buf), 2086 "0x%lx", val); 2087 return (pri->code_buf); 2088 } 2089 } 2090 2091 2092 const char * 2093 udp_optname(private_t *pri, long val) 2094 { 2095 switch (val) { 2096 case UDP_CHECKSUM: return ("UDP_CHECKSUM"); 2097 case UDP_ANONPRIVBIND: return ("UDP_ANONPRIVBIND"); 2098 case UDP_EXCLBIND: return ("UDP_EXCLBIND"); 2099 case UDP_RCVHDR: return ("UDP_RCVHDR"); 2100 case UDP_NAT_T_ENDPOINT: return ("UDP_NAT_T_ENDPOINT"); 2101 case UDP_SRCPORT_HASH: return ("UDP_SRCPORT_HASH"); 2102 2103 default: (void) snprintf(pri->code_buf, 2104 sizeof (pri->code_buf), "0x%lx", 2105 val); 2106 return (pri->code_buf); 2107 } 2108 } 2109 2110 2111 const char * 2112 ip_optname(private_t *pri, long val) 2113 { 2114 switch (val) { 2115 case IP_OPTIONS: return ("IP_OPTIONS"); 2116 case IP_HDRINCL: return ("IP_HDRINCL"); 2117 case IP_TOS: return ("IP_TOS"); 2118 case IP_TTL: return ("IP_TTL"); 2119 case IP_RECVOPTS: return ("IP_RECVOPTS"); 2120 case IP_RECVRETOPTS: return ("IP_RECVRETOPTS"); 2121 case IP_RECVDSTADDR: return ("IP_RECVDSTADDR"); 2122 case IP_RETOPTS: return ("IP_RETOPTS"); 2123 case IP_RECVIF: return ("IP_RECVIF"); 2124 case IP_RECVSLLA: return ("IP_RECVSLLA"); 2125 case IP_RECVTTL: return ("IP_RECVTTL"); 2126 case IP_RECVTOS: return ("IP_RECVTOS"); 2127 case IP_MULTICAST_IF: return ("IP_MULTICAST_IF"); 2128 case IP_MULTICAST_TTL: return ("IP_MULTICAST_TTL"); 2129 case IP_MULTICAST_LOOP: return ("IP_MULTICAST_LOOP"); 2130 case IP_ADD_MEMBERSHIP: return ("IP_ADD_MEMBERSHIP"); 2131 case IP_DROP_MEMBERSHIP: return ("IP_DROP_MEMBERSHIP"); 2132 case IP_BLOCK_SOURCE: return ("IP_BLOCK_SOURCE"); 2133 case IP_UNBLOCK_SOURCE: return ("IP_UNBLOCK_SOURCE"); 2134 case IP_ADD_SOURCE_MEMBERSHIP: return ("IP_ADD_SOURCE_MEMBERSHIP"); 2135 case IP_DROP_SOURCE_MEMBERSHIP: return ("IP_DROP_SOURCE_MEMBERSHIP"); 2136 case IP_NEXTHOP: return ("IP_NEXTHOP"); 2137 /* IP_PKTINFO and IP_RECVPKTINFO share the same code */ 2138 case IP_PKTINFO: return ("IP_PKTINFO/IP_RECVPKTINFO"); 2139 case IP_DONTFRAG: return ("IP_DONTFRAG"); 2140 case IP_SEC_OPT: return ("IP_SEC_OPT"); 2141 case MCAST_JOIN_GROUP: return ("MCAST_JOIN_GROUP"); 2142 case MCAST_LEAVE_GROUP: return ("MCAST_LEAVE_GROUP"); 2143 case MCAST_BLOCK_SOURCE: return ("MCAST_BLOCK_SOURCE"); 2144 case MCAST_UNBLOCK_SOURCE: return ("MCAST_UNBLOCK_SOURCE"); 2145 case MCAST_JOIN_SOURCE_GROUP: return ("MCAST_JOIN_SOURCE_GROUP"); 2146 case MCAST_LEAVE_SOURCE_GROUP: return ("MCAST_LEAVE_SOURCE_GROUP"); 2147 case MRT_INIT: return ("MRT_INIT"); 2148 case MRT_DONE: return ("MRT_DONE"); 2149 case MRT_ADD_VIF: return ("MRT_ADD_VIF"); 2150 case MRT_DEL_VIF: return ("MRT_DEL_VIF"); 2151 case MRT_ADD_MFC: return ("MRT_ADD_MFC"); 2152 case MRT_DEL_MFC: return ("MRT_DEL_MFC"); 2153 case MRT_VERSION: return ("MRT_VERSION"); 2154 case MRT_ASSERT: return ("MRT_ASSERT"); 2155 case IP_BOUND_IF: return ("IP_BOUND_IF"); 2156 case IP_UNSPEC_SRC: return ("IP_UNSPEC_SRC"); 2157 case IP_BROADCAST_TTL: return ("IP_BROADCAST_TTL"); 2158 case IP_DHCPINIT_IF: return ("IP_DHCPINIT_IF"); 2159 case IP_REUSEADDR: return ("IP_REUSEADDR"); 2160 case IP_DONTROUTE: return ("IP_DONTROUTE"); 2161 case IP_BROADCAST: return ("IP_BROADCAST"); 2162 2163 default: (void) snprintf(pri->code_buf, 2164 sizeof (pri->code_buf), "0x%lx", 2165 val); 2166 return (pri->code_buf); 2167 } 2168 } 2169 2170 const char * 2171 ipv6_optname(private_t *pri, long val) 2172 { 2173 switch (val) { 2174 case IPV6_UNICAST_HOPS: return ("IPV6_UNICAST_HOPS"); 2175 case IPV6_MULTICAST_IF: return ("IPV6_MULTICAST_IF"); 2176 case IPV6_MULTICAST_HOPS: return ("IPV6_MULTICAST_HOPS"); 2177 case IPV6_MULTICAST_LOOP: return ("IPV6_MULTICAST_LOOP"); 2178 case IPV6_JOIN_GROUP: return ("IPV6_JOIN_GROUP"); 2179 case IPV6_LEAVE_GROUP: return ("IPV6_LEAVE_GROUP"); 2180 case IPV6_PKTINFO: return ("IPV6_PKTINFO"); 2181 case IPV6_HOPLIMIT: return ("IPV6_HOPLIMIT"); 2182 case IPV6_NEXTHOP: return ("IPV6_NEXTHOP"); 2183 case IPV6_HOPOPTS: return ("IPV6_HOPOPTS"); 2184 case IPV6_DSTOPTS: return ("IPV6_DSTOPTS"); 2185 case IPV6_RTHDR: return ("IPV6_RTHDR"); 2186 case IPV6_RTHDRDSTOPTS: return ("IPV6_RTHDRDSTOPTS"); 2187 case IPV6_RECVPKTINFO: return ("IPV6_RECVPKTINFO"); 2188 case IPV6_RECVHOPLIMIT: return ("IPV6_RECVHOPLIMIT"); 2189 case IPV6_RECVHOPOPTS: return ("IPV6_RECVHOPOPTS"); 2190 case _OLD_IPV6_RECVDSTOPTS: return ("_OLD_IPV6_RECVDSTOPTS"); 2191 case IPV6_RECVRTHDR: return ("IPV6_RECVRTHDR"); 2192 case IPV6_RECVRTHDRDSTOPTS: return ("IPV6_RECVRTHDRDSTOPTS"); 2193 case IPV6_CHECKSUM: return ("IPV6_CHECKSUM"); 2194 case IPV6_RECVTCLASS: return ("IPV6_RECVTCLASS"); 2195 case IPV6_USE_MIN_MTU: return ("IPV6_USE_MIN_MTU"); 2196 case IPV6_DONTFRAG: return ("IPV6_DONTFRAG"); 2197 case IPV6_SEC_OPT: return ("IPV6_SEC_OPT"); 2198 case IPV6_SRC_PREFERENCES: return ("IPV6_SRC_PREFERENCES"); 2199 case IPV6_RECVPATHMTU: return ("IPV6_RECVPATHMTU"); 2200 case IPV6_PATHMTU: return ("IPV6_PATHMTU"); 2201 case IPV6_TCLASS: return ("IPV6_TCLASS"); 2202 case IPV6_V6ONLY: return ("IPV6_V6ONLY"); 2203 case IPV6_RECVDSTOPTS: return ("IPV6_RECVDSTOPTS"); 2204 case MCAST_JOIN_GROUP: return ("MCAST_JOIN_GROUP"); 2205 case MCAST_LEAVE_GROUP: return ("MCAST_LEAVE_GROUP"); 2206 case MCAST_BLOCK_SOURCE: return ("MCAST_BLOCK_SOURCE"); 2207 case MCAST_UNBLOCK_SOURCE: return ("MCAST_UNBLOCK_SOURCE"); 2208 case MCAST_JOIN_SOURCE_GROUP: return ("MCAST_JOIN_SOURCE_GROUP"); 2209 case MCAST_LEAVE_SOURCE_GROUP: return ("MCAST_LEAVE_SOURCE_GROUP"); 2210 2211 default: (void) snprintf(pri->code_buf, 2212 sizeof (pri->code_buf), "0x%lx", 2213 val); 2214 return (pri->code_buf); 2215 } 2216 } 2217 2218 2219 const char * 2220 icmpv6_optname(private_t *pri, long val) 2221 { 2222 switch (val) { 2223 case ICMP6_FILTER: return ("ICMP6_FILTER"); 2224 default: (void) snprintf(pri->code_buf, 2225 sizeof (pri->code_buf), "0x%lx", 2226 val); 2227 return (pri->code_buf); 2228 } 2229 } 2230 2231 2232 /* 2233 * Print setsockopt()/getsockopt() 3rd argument. 2234 */ 2235 /*ARGSUSED*/ 2236 void 2237 prt_son(private_t *pri, int raw, long val) 2238 { 2239 /* cheating -- look at the level */ 2240 switch (pri->sys_args[1]) { 2241 case SOL_SOCKET: outstring(pri, sol_optname(pri, val)); 2242 break; 2243 case SOL_ROUTE: outstring(pri, route_optname(pri, val)); 2244 break; 2245 case IPPROTO_IP: outstring(pri, ip_optname(pri, val)); 2246 break; 2247 case IPPROTO_IPV6: outstring(pri, ipv6_optname(pri, val)); 2248 break; 2249 case IPPROTO_ICMPV6: outstring(pri, icmpv6_optname(pri, val)); 2250 break; 2251 case IPPROTO_TCP: outstring(pri, tcp_optname(pri, val)); 2252 break; 2253 case IPPROTO_UDP: outstring(pri, udp_optname(pri, val)); 2254 break; 2255 case IPPROTO_SCTP: outstring(pri, sctp_optname(pri, val)); 2256 break; 2257 default: prt_dec(pri, 0, val); 2258 break; 2259 } 2260 } 2261 2262 2263 /* 2264 * Print utrap type 2265 */ 2266 /*ARGSUSED*/ 2267 void 2268 prt_utt(private_t *pri, int raw, long val) 2269 { 2270 const char *s = NULL; 2271 2272 #ifdef __sparc 2273 if (!raw) { 2274 switch (val) { 2275 case UT_INSTRUCTION_DISABLED: 2276 s = "UT_INSTRUCTION_DISABLED"; break; 2277 case UT_INSTRUCTION_ERROR: 2278 s = "UT_INSTRUCTION_ERROR"; break; 2279 case UT_INSTRUCTION_PROTECTION: 2280 s = "UT_INSTRUCTION_PROTECTION"; break; 2281 case UT_ILLTRAP_INSTRUCTION: 2282 s = "UT_ILLTRAP_INSTRUCTION"; break; 2283 case UT_ILLEGAL_INSTRUCTION: 2284 s = "UT_ILLEGAL_INSTRUCTION"; break; 2285 case UT_PRIVILEGED_OPCODE: 2286 s = "UT_PRIVILEGED_OPCODE"; break; 2287 case UT_FP_DISABLED: 2288 s = "UT_FP_DISABLED"; break; 2289 case UT_FP_EXCEPTION_IEEE_754: 2290 s = "UT_FP_EXCEPTION_IEEE_754"; break; 2291 case UT_FP_EXCEPTION_OTHER: 2292 s = "UT_FP_EXCEPTION_OTHER"; break; 2293 case UT_TAG_OVERFLOW: 2294 s = "UT_TAG_OVERFLOW"; break; 2295 case UT_DIVISION_BY_ZERO: 2296 s = "UT_DIVISION_BY_ZERO"; break; 2297 case UT_DATA_EXCEPTION: 2298 s = "UT_DATA_EXCEPTION"; break; 2299 case UT_DATA_ERROR: 2300 s = "UT_DATA_ERROR"; break; 2301 case UT_DATA_PROTECTION: 2302 s = "UT_DATA_PROTECTION"; break; 2303 case UT_MEM_ADDRESS_NOT_ALIGNED: 2304 s = "UT_MEM_ADDRESS_NOT_ALIGNED"; break; 2305 case UT_PRIVILEGED_ACTION: 2306 s = "UT_PRIVILEGED_ACTION"; break; 2307 case UT_ASYNC_DATA_ERROR: 2308 s = "UT_ASYNC_DATA_ERROR"; break; 2309 case UT_TRAP_INSTRUCTION_16: 2310 s = "UT_TRAP_INSTRUCTION_16"; break; 2311 case UT_TRAP_INSTRUCTION_17: 2312 s = "UT_TRAP_INSTRUCTION_17"; break; 2313 case UT_TRAP_INSTRUCTION_18: 2314 s = "UT_TRAP_INSTRUCTION_18"; break; 2315 case UT_TRAP_INSTRUCTION_19: 2316 s = "UT_TRAP_INSTRUCTION_19"; break; 2317 case UT_TRAP_INSTRUCTION_20: 2318 s = "UT_TRAP_INSTRUCTION_20"; break; 2319 case UT_TRAP_INSTRUCTION_21: 2320 s = "UT_TRAP_INSTRUCTION_21"; break; 2321 case UT_TRAP_INSTRUCTION_22: 2322 s = "UT_TRAP_INSTRUCTION_22"; break; 2323 case UT_TRAP_INSTRUCTION_23: 2324 s = "UT_TRAP_INSTRUCTION_23"; break; 2325 case UT_TRAP_INSTRUCTION_24: 2326 s = "UT_TRAP_INSTRUCTION_24"; break; 2327 case UT_TRAP_INSTRUCTION_25: 2328 s = "UT_TRAP_INSTRUCTION_25"; break; 2329 case UT_TRAP_INSTRUCTION_26: 2330 s = "UT_TRAP_INSTRUCTION_26"; break; 2331 case UT_TRAP_INSTRUCTION_27: 2332 s = "UT_TRAP_INSTRUCTION_27"; break; 2333 case UT_TRAP_INSTRUCTION_28: 2334 s = "UT_TRAP_INSTRUCTION_28"; break; 2335 case UT_TRAP_INSTRUCTION_29: 2336 s = "UT_TRAP_INSTRUCTION_29"; break; 2337 case UT_TRAP_INSTRUCTION_30: 2338 s = "UT_TRAP_INSTRUCTION_30"; break; 2339 case UT_TRAP_INSTRUCTION_31: 2340 s = "UT_TRAP_INSTRUCTION_31"; break; 2341 } 2342 } 2343 #endif /* __sparc */ 2344 2345 if (s == NULL) 2346 prt_dec(pri, 0, val); 2347 else 2348 outstring(pri, s); 2349 } 2350 2351 2352 /* 2353 * Print utrap handler 2354 */ 2355 void 2356 prt_uth(private_t *pri, int raw, long val) 2357 { 2358 const char *s = NULL; 2359 2360 if (!raw) { 2361 switch (val) { 2362 case (long)UTH_NOCHANGE: s = "UTH_NOCHANGE"; break; 2363 } 2364 } 2365 2366 if (s == NULL) 2367 prt_hex(pri, 0, val); 2368 else 2369 outstring(pri, s); 2370 } 2371 2372 const char * 2373 access_flags(private_t *pri, long arg) 2374 { 2375 #define E_OK 010 2376 char *str = pri->code_buf; 2377 2378 if (arg & ~(R_OK|W_OK|X_OK|E_OK)) 2379 return (NULL); 2380 2381 /* NB: F_OK == 0 */ 2382 if (arg == F_OK) 2383 return ("F_OK"); 2384 if (arg == E_OK) 2385 return ("F_OK|E_OK"); 2386 2387 *str = '\0'; 2388 if (arg & R_OK) 2389 (void) strlcat(str, "|R_OK", sizeof (pri->code_buf)); 2390 if (arg & W_OK) 2391 (void) strlcat(str, "|W_OK", sizeof (pri->code_buf)); 2392 if (arg & X_OK) 2393 (void) strlcat(str, "|X_OK", sizeof (pri->code_buf)); 2394 if (arg & E_OK) 2395 (void) strlcat(str, "|E_OK", sizeof (pri->code_buf)); 2396 return ((const char *)(str + 1)); 2397 #undef E_OK 2398 } 2399 2400 /* 2401 * Print access() flags. 2402 */ 2403 void 2404 prt_acc(private_t *pri, int raw, long val) 2405 { 2406 const char *s = raw? NULL : access_flags(pri, val); 2407 2408 if (s == NULL) 2409 prt_dex(pri, 0, val); 2410 else 2411 outstring(pri, s); 2412 } 2413 2414 /* 2415 * Print shutdown() "how" (2nd) argument 2416 */ 2417 void 2418 prt_sht(private_t *pri, int raw, long val) 2419 { 2420 if (raw) { 2421 prt_dex(pri, 0, val); 2422 return; 2423 } 2424 switch (val) { 2425 case SHUT_RD: outstring(pri, "SHUT_RD"); break; 2426 case SHUT_WR: outstring(pri, "SHUT_WR"); break; 2427 case SHUT_RDWR: outstring(pri, "SHUT_RDWR"); break; 2428 default: prt_dec(pri, 0, val); break; 2429 } 2430 } 2431 2432 /* 2433 * Print fcntl() F_SETFL flags (3rd) argument or fdsync flag (2nd arg) 2434 */ 2435 static struct fcntl_flags { 2436 long val; 2437 const char *name; 2438 } fcntl_flags[] = { 2439 #define FC_FL(flag) { (long)flag, "|" # flag } 2440 FC_FL(FREVOKED), 2441 FC_FL(FREAD), 2442 FC_FL(FWRITE), 2443 FC_FL(FNDELAY), 2444 FC_FL(FAPPEND), 2445 FC_FL(FSYNC), 2446 FC_FL(FDSYNC), 2447 FC_FL(FRSYNC), 2448 FC_FL(FOFFMAX), 2449 FC_FL(FNONBLOCK), 2450 FC_FL(FCREAT), 2451 FC_FL(FTRUNC), 2452 FC_FL(FEXCL), 2453 FC_FL(FNOCTTY), 2454 FC_FL(FXATTR), 2455 FC_FL(FASYNC), 2456 FC_FL(FNODSYNC) 2457 #undef FC_FL 2458 }; 2459 2460 void 2461 prt_ffg(private_t *pri, int raw, long val) 2462 { 2463 #define CBSIZE sizeof (pri->code_buf) 2464 char *s = pri->code_buf; 2465 size_t used = 1; 2466 struct fcntl_flags *fp; 2467 2468 if (raw) { 2469 (void) snprintf(s, CBSIZE, "0x%lx", val); 2470 outstring(pri, s); 2471 return; 2472 } 2473 if (val == 0) { 2474 outstring(pri, "(no flags)"); 2475 return; 2476 } 2477 2478 *s = '\0'; 2479 for (fp = fcntl_flags; 2480 fp < &fcntl_flags[sizeof (fcntl_flags) / sizeof (*fp)]; fp++) { 2481 if (val & fp->val) { 2482 used = strlcat(s, fp->name, CBSIZE); 2483 val &= ~fp->val; 2484 } 2485 } 2486 2487 if (val != 0 && used <= CBSIZE) 2488 used += snprintf(s + used, CBSIZE - used, "|0x%lx", val); 2489 2490 if (used >= CBSIZE) 2491 (void) snprintf(s + 1, CBSIZE-1, "0x%lx", val); 2492 outstring(pri, s + 1); 2493 #undef CBSIZE 2494 } 2495 2496 void 2497 prt_prs(private_t *pri, int raw, long val) 2498 { 2499 static size_t setsize; 2500 priv_set_t *set = priv_allocset(); 2501 2502 if (setsize == 0) { 2503 const priv_impl_info_t *info = getprivimplinfo(); 2504 if (info != NULL) 2505 setsize = info->priv_setsize * sizeof (priv_chunk_t); 2506 } 2507 2508 if (setsize != 0 && !raw && set != NULL && 2509 Pread(Proc, set, setsize, val) == setsize) { 2510 int i; 2511 2512 outstring(pri, "{"); 2513 for (i = 0; i < setsize / sizeof (priv_chunk_t); i++) { 2514 char buf[9]; /* 8 hex digits + '\0' */ 2515 (void) snprintf(buf, sizeof (buf), "%08x", 2516 ((priv_chunk_t *)set)[i]); 2517 outstring(pri, buf); 2518 } 2519 2520 outstring(pri, "}"); 2521 } else { 2522 prt_hex(pri, 0, val); 2523 } 2524 2525 if (set != NULL) 2526 priv_freeset(set); 2527 } 2528 2529 /* 2530 * Print privilege set operation. 2531 */ 2532 void 2533 prt_pro(private_t *pri, int raw, long val) 2534 { 2535 const char *s = NULL; 2536 2537 if (!raw) { 2538 switch ((priv_op_t)val) { 2539 case PRIV_ON: s = "PRIV_ON"; break; 2540 case PRIV_OFF: s = "PRIV_OFF"; break; 2541 case PRIV_SET: s = "PRIV_SET"; break; 2542 } 2543 } 2544 2545 if (s == NULL) 2546 prt_dec(pri, 0, val); 2547 else 2548 outstring(pri, s); 2549 } 2550 2551 /* 2552 * Print privilege set name 2553 */ 2554 void 2555 prt_prn(private_t *pri, int raw, long val) 2556 { 2557 const char *s = NULL; 2558 2559 if (!raw) 2560 s = priv_getsetbynum((int)val); 2561 2562 if (s == NULL) 2563 prt_dec(pri, 0, val); 2564 else { 2565 char *dup = strdup(s); 2566 char *q; 2567 2568 /* Do the best we can in this case */ 2569 if (dup == NULL) { 2570 outstring(pri, s); 2571 return; 2572 } 2573 2574 outstring(pri, "PRIV_"); 2575 2576 q = dup; 2577 2578 while (*q != '\0') { 2579 *q = toupper(*q); 2580 q++; 2581 } 2582 outstring(pri, dup); 2583 free(dup); 2584 } 2585 } 2586 2587 /* 2588 * Print process flag names. 2589 */ 2590 void 2591 prt_pfl(private_t *pri, int raw, long val) 2592 { 2593 const char *s = NULL; 2594 2595 if (!raw) { 2596 switch ((int)val) { 2597 case PRIV_DEBUG: s = "PRIV_DEBUG"; break; 2598 case PRIV_AWARE: s = "PRIV_AWARE"; break; 2599 case PRIV_XPOLICY: s = "PRIV_XPOLICY"; break; 2600 case PRIV_AWARE_RESET: s = "PRIV_AWARE_RESET"; break; 2601 case PRIV_PFEXEC: s = "PRIV_PFEXEC"; break; 2602 case NET_MAC_AWARE: s = "NET_MAC_AWARE"; break; 2603 case NET_MAC_AWARE_INHERIT: 2604 s = "NET_MAC_AWARE_INHERIT"; 2605 break; 2606 } 2607 } 2608 2609 if (s == NULL) 2610 prt_dec(pri, 0, val); 2611 else 2612 outstring(pri, s); 2613 } 2614 2615 /* 2616 * Print lgrp_affinity_{get,set}() arguments. 2617 */ 2618 /*ARGSUSED*/ 2619 void 2620 prt_laf(private_t *pri, int raw, long val) 2621 { 2622 lgrp_affinity_args_t laff; 2623 2624 if (Pread(Proc, &laff, sizeof (lgrp_affinity_args_t), val) != 2625 sizeof (lgrp_affinity_args_t)) { 2626 prt_hex(pri, 0, val); 2627 return; 2628 } 2629 /* 2630 * arrange the arguments in the order that user calls with 2631 */ 2632 prt_dec(pri, 0, laff.idtype); 2633 outstring(pri, ", "); 2634 prt_dec(pri, 0, laff.id); 2635 outstring(pri, ", "); 2636 prt_dec(pri, 0, laff.lgrp); 2637 outstring(pri, ", "); 2638 if (pri->sys_args[0] == LGRP_SYS_AFFINITY_SET) 2639 prt_dec(pri, 0, laff.aff); 2640 } 2641 2642 /* 2643 * Print a key_t as IPC_PRIVATE if it is 0. 2644 */ 2645 void 2646 prt_key(private_t *pri, int raw, long val) 2647 { 2648 if (!raw && val == 0) 2649 outstring(pri, "IPC_PRIVATE"); 2650 else 2651 prt_dec(pri, 0, val); 2652 } 2653 2654 2655 /* 2656 * Print zone_getattr() attribute types. 2657 */ 2658 void 2659 prt_zga(private_t *pri, int raw, long val) 2660 { 2661 const char *s = NULL; 2662 2663 if (!raw) { 2664 switch ((int)val) { 2665 case ZONE_ATTR_NAME: s = "ZONE_ATTR_NAME"; break; 2666 case ZONE_ATTR_ROOT: s = "ZONE_ATTR_ROOT"; break; 2667 case ZONE_ATTR_STATUS: s = "ZONE_ATTR_STATUS"; break; 2668 case ZONE_ATTR_PRIVSET: s = "ZONE_ATTR_PRIVSET"; break; 2669 case ZONE_ATTR_UNIQID: s = "ZONE_ATTR_UNIQID"; break; 2670 case ZONE_ATTR_POOLID: s = "ZONE_ATTR_POOLID"; break; 2671 case ZONE_ATTR_INITPID: s = "ZONE_ATTR_INITPID"; break; 2672 case ZONE_ATTR_SLBL: s = "ZONE_ATTR_SLBL"; break; 2673 case ZONE_ATTR_INITNAME: s = "ZONE_ATTR_INITNAME"; break; 2674 case ZONE_ATTR_BOOTARGS: s = "ZONE_ATTR_BOOTARGS"; break; 2675 case ZONE_ATTR_BRAND: s = "ZONE_ATTR_BRAND"; break; 2676 case ZONE_ATTR_FLAGS: s = "ZONE_ATTR_FLAGS"; break; 2677 case ZONE_ATTR_PHYS_MCAP: s = "ZONE_ATTR_PHYS_MCAP"; break; 2678 } 2679 } 2680 2681 if (s == NULL) 2682 prt_dec(pri, 0, val); 2683 else 2684 outstring(pri, s); 2685 } 2686 2687 /* 2688 * Print a file descriptor as AT_FDCWD if necessary 2689 */ 2690 void 2691 prt_atc(private_t *pri, int raw, long val) 2692 { 2693 if ((int)val == AT_FDCWD) { 2694 if (raw) 2695 prt_hex(pri, 0, (uint_t)AT_FDCWD); 2696 else 2697 outstring(pri, "AT_FDCWD"); 2698 } else { 2699 prt_dec(pri, 0, val); 2700 } 2701 } 2702 2703 /* 2704 * Print Trusted Networking database operation codes (labelsys; tn*) 2705 */ 2706 static void 2707 prt_tnd(private_t *pri, int raw, long val) 2708 { 2709 const char *s = NULL; 2710 2711 if (!raw) { 2712 switch ((tsol_dbops_t)val) { 2713 case TNDB_NOOP: s = "TNDB_NOOP"; break; 2714 case TNDB_LOAD: s = "TNDB_LOAD"; break; 2715 case TNDB_DELETE: s = "TNDB_DELETE"; break; 2716 case TNDB_FLUSH: s = "TNDB_FLUSH"; break; 2717 case TNDB_GET: s = "TNDB_GET"; break; 2718 } 2719 } 2720 2721 if (s == NULL) 2722 prt_dec(pri, 0, val); 2723 else 2724 outstring(pri, s); 2725 } 2726 2727 /* 2728 * Print LIO_XX flags 2729 */ 2730 void 2731 prt_lio(private_t *pri, int raw, long val) 2732 { 2733 if (raw) 2734 prt_dec(pri, 0, val); 2735 else if (val == LIO_WAIT) 2736 outstring(pri, "LIO_WAIT"); 2737 else if (val == LIO_NOWAIT) 2738 outstring(pri, "LIO_NOWAIT"); 2739 else 2740 prt_dec(pri, 0, val); 2741 } 2742 2743 const char * 2744 door_flags(private_t *pri, long val) 2745 { 2746 door_attr_t attr = (door_attr_t)val; 2747 char *str = pri->code_buf; 2748 2749 *str = '\0'; 2750 #define PROCESS_FLAG(flg) \ 2751 if (attr & flg) { \ 2752 (void) strlcat(str, "|" #flg, sizeof (pri->code_buf)); \ 2753 attr &= ~flg; \ 2754 } 2755 2756 PROCESS_FLAG(DOOR_UNREF); 2757 PROCESS_FLAG(DOOR_UNREF_MULTI); 2758 PROCESS_FLAG(DOOR_PRIVATE); 2759 PROCESS_FLAG(DOOR_REFUSE_DESC); 2760 PROCESS_FLAG(DOOR_NO_CANCEL); 2761 PROCESS_FLAG(DOOR_LOCAL); 2762 PROCESS_FLAG(DOOR_REVOKED); 2763 PROCESS_FLAG(DOOR_IS_UNREF); 2764 #undef PROCESS_FLAG 2765 2766 if (attr != 0 || *str == '\0') { 2767 size_t len = strlen(str); 2768 (void) snprintf(str + len, sizeof (pri->code_buf) - len, 2769 "|0x%X", attr); 2770 } 2771 2772 return (str + 1); 2773 } 2774 2775 /* 2776 * Print door_create() flags 2777 */ 2778 void 2779 prt_dfl(private_t *pri, int raw, long val) 2780 { 2781 if (raw) 2782 prt_hex(pri, 0, val); 2783 else 2784 outstring(pri, door_flags(pri, val)); 2785 } 2786 2787 /* 2788 * Print door_*param() param argument 2789 */ 2790 void 2791 prt_dpm(private_t *pri, int raw, long val) 2792 { 2793 if (raw) 2794 prt_hex(pri, 0, val); 2795 else if (val == DOOR_PARAM_DESC_MAX) 2796 outstring(pri, "DOOR_PARAM_DESC_MAX"); 2797 else if (val == DOOR_PARAM_DATA_MIN) 2798 outstring(pri, "DOOR_PARAM_DATA_MIN"); 2799 else if (val == DOOR_PARAM_DATA_MAX) 2800 outstring(pri, "DOOR_PARAM_DATA_MAX"); 2801 else 2802 prt_hex(pri, 0, val); 2803 } 2804 2805 /* 2806 * Print rctlsys subcodes 2807 */ 2808 void 2809 prt_rsc(private_t *pri, int raw, long val) /* print utssys code */ 2810 { 2811 const char *s = raw? NULL : rctlsyscode(val); 2812 2813 if (s == NULL) 2814 prt_dec(pri, 0, val); 2815 else 2816 outstring(pri, s); 2817 } 2818 2819 /* 2820 * Print getrctl flags 2821 */ 2822 void 2823 prt_rgf(private_t *pri, int raw, long val) 2824 { 2825 long action = val & (~RCTLSYS_ACTION_MASK); 2826 2827 if (raw) 2828 prt_hex(pri, 0, val); 2829 else if (action == RCTL_FIRST) 2830 outstring(pri, "RCTL_FIRST"); 2831 else if (action == RCTL_NEXT) 2832 outstring(pri, "RCTL_NEXT"); 2833 else if (action == RCTL_USAGE) 2834 outstring(pri, "RCTL_USAGE"); 2835 else 2836 prt_hex(pri, 0, val); 2837 } 2838 2839 /* 2840 * Print setrctl flags 2841 */ 2842 void 2843 prt_rsf(private_t *pri, int raw, long val) 2844 { 2845 long action = val & (~RCTLSYS_ACTION_MASK); 2846 long pval = val & RCTL_LOCAL_ACTION_MASK; 2847 char *s = pri->code_buf; 2848 2849 if (raw) { 2850 prt_hex(pri, 0, val); 2851 return; 2852 } else if (action == RCTL_INSERT) 2853 (void) strcpy(s, "RCTL_INSERT"); 2854 else if (action == RCTL_DELETE) 2855 (void) strcpy(s, "RCTL_DELETE"); 2856 else if (action == RCTL_REPLACE) 2857 (void) strcpy(s, "RCTL_REPLACE"); 2858 else { 2859 prt_hex(pri, 0, val); 2860 return; 2861 } 2862 2863 if (pval & RCTL_USE_RECIPIENT_PID) { 2864 pval ^= RCTL_USE_RECIPIENT_PID; 2865 (void) strlcat(s, "|RCTL_USE_RECIPIENT_PID", 2866 sizeof (pri->code_buf)); 2867 } 2868 2869 if ((pval & RCTLSYS_ACTION_MASK) != 0) 2870 prt_hex(pri, 0, val); 2871 else if (*s != '\0') 2872 outstring(pri, s); 2873 else 2874 prt_hex(pri, 0, val); 2875 } 2876 2877 /* 2878 * Print rctlctl flags 2879 */ 2880 void 2881 prt_rcf(private_t *pri, int raw, long val) 2882 { 2883 long action = val & (~RCTLSYS_ACTION_MASK); 2884 2885 if (raw) 2886 prt_hex(pri, 0, val); 2887 else if (action == RCTLCTL_GET) 2888 outstring(pri, "RCTLCTL_GET"); 2889 else if (action == RCTLCTL_SET) 2890 outstring(pri, "RCTLCTL_SET"); 2891 else 2892 prt_hex(pri, 0, val); 2893 } 2894 2895 /* 2896 * Print setprojrctl flags 2897 */ 2898 void 2899 prt_spf(private_t *pri, int raw, long val) 2900 { 2901 long action = val & TASK_PROJ_MASK; 2902 2903 if (!raw && (action == TASK_PROJ_PURGE)) 2904 outstring(pri, "TASK_PROJ_PURGE"); 2905 else 2906 prt_hex(pri, 0, val); 2907 } 2908 2909 /* 2910 * Print forkx() flags 2911 */ 2912 void 2913 prt_fxf(private_t *pri, int raw, long val) 2914 { 2915 char *str; 2916 2917 if (val == 0) 2918 outstring(pri, "0"); 2919 else if (raw || (val & ~(FORK_NOSIGCHLD | FORK_WAITPID))) 2920 prt_hhx(pri, 0, val); 2921 else { 2922 str = pri->code_buf; 2923 *str = '\0'; 2924 if (val & FORK_NOSIGCHLD) 2925 (void) strlcat(str, "|FORK_NOSIGCHLD", 2926 sizeof (pri->code_buf)); 2927 if (val & FORK_WAITPID) 2928 (void) strlcat(str, "|FORK_WAITPID", 2929 sizeof (pri->code_buf)); 2930 outstring(pri, str + 1); 2931 } 2932 } 2933 2934 /* 2935 * Print faccessat() flag 2936 */ 2937 void 2938 prt_fat(private_t *pri, int raw, long val) 2939 { 2940 if (val == 0) 2941 outstring(pri, "0"); 2942 else if (!raw && val == AT_EACCESS) 2943 outstring(pri, "AT_EACCESS"); 2944 else 2945 prt_hex(pri, 0, val); 2946 } 2947 2948 /* 2949 * Print unlinkat() flag 2950 */ 2951 void 2952 prt_uat(private_t *pri, int raw, long val) 2953 { 2954 if (val == 0) 2955 outstring(pri, "0"); 2956 else if (!raw && val == AT_REMOVEDIR) 2957 outstring(pri, "AT_REMOVEDIR"); 2958 else 2959 prt_hex(pri, 0, val); 2960 } 2961 2962 /* 2963 * Print AT_SYMLINK_NOFOLLOW / AT_SYMLINK_FOLLOW flag 2964 */ 2965 void 2966 prt_snf(private_t *pri, int raw, long val) 2967 { 2968 if (val == 0) 2969 outstring(pri, "0"); 2970 else if (!raw && val == AT_SYMLINK_NOFOLLOW) 2971 outstring(pri, "AT_SYMLINK_NOFOLLOW"); 2972 else if (!raw && val == AT_SYMLINK_FOLLOW) 2973 outstring(pri, "AT_SYMLINK_FOLLOW"); 2974 else 2975 prt_hex(pri, 0, val); 2976 } 2977 2978 void 2979 prt_grf(private_t *pri, int raw, long val) 2980 { 2981 int first = 1; 2982 2983 if (raw != 0 || val == 0 || 2984 (val & ~(GRND_NONBLOCK | GRND_RANDOM)) != 0) { 2985 outstring(pri, "0"); 2986 return; 2987 } 2988 2989 if (val & GRND_NONBLOCK) { 2990 outstring(pri, "|GRND_NONBLOCK" + first); 2991 first = 0; 2992 } 2993 if (val & GRND_RANDOM) { 2994 outstring(pri, "|GRND_RANDOM" + first); 2995 first = 0; 2996 } 2997 } 2998 2999 /* 3000 * Array of pointers to print functions, one for each format. 3001 */ 3002 void (* const Print[])() = { 3003 prt_nov, /* NOV -- no value */ 3004 prt_dec, /* DEC -- print value in decimal */ 3005 prt_oct, /* OCT -- print value in octal */ 3006 prt_hex, /* HEX -- print value in hexadecimal */ 3007 prt_dex, /* DEX -- print value in hexadecimal if big enough */ 3008 prt_stg, /* STG -- print value as string */ 3009 prt_ioc, /* IOC -- print ioctl code */ 3010 prt_fcn, /* FCN -- print fcntl code */ 3011 prt_s86, /* S86 -- print sysi86 code */ 3012 prt_uts, /* UTS -- print utssys code */ 3013 prt_opn, /* OPN -- print open code */ 3014 prt_sig, /* SIG -- print signal name plus flags */ 3015 prt_uat, /* UAT -- print unlinkat() flag */ 3016 prt_msc, /* MSC -- print msgsys command */ 3017 prt_msf, /* MSF -- print msgsys flags */ 3018 prt_smc, /* SMC -- print semsys command */ 3019 prt_sef, /* SEF -- print semsys flags */ 3020 prt_shc, /* SHC -- print shmsys command */ 3021 prt_shf, /* SHF -- print shmsys flags */ 3022 prt_fat, /* FAT -- print faccessat( flag */ 3023 prt_sfs, /* SFS -- print sysfs code */ 3024 prt_rst, /* RST -- print string returned by syscall */ 3025 prt_smf, /* SMF -- print streams message flags */ 3026 prt_ioa, /* IOA -- print ioctl argument */ 3027 prt_pip, /* PIP -- print pipe flags */ 3028 prt_mtf, /* MTF -- print mount flags */ 3029 prt_mft, /* MFT -- print mount file system type */ 3030 prt_iob, /* IOB -- print contents of I/O buffer */ 3031 prt_hhx, /* HHX -- print value in hexadecimal (half size) */ 3032 prt_wop, /* WOP -- print waitsys() options */ 3033 prt_spm, /* SPM -- print sigprocmask argument */ 3034 prt_rlk, /* RLK -- print readlink buffer */ 3035 prt_mpr, /* MPR -- print mmap()/mprotect() flags */ 3036 prt_mty, /* MTY -- print mmap() mapping type flags */ 3037 prt_mcf, /* MCF -- print memcntl() function */ 3038 prt_mc4, /* MC4 -- print memcntl() (fourth) argument */ 3039 prt_mc5, /* MC5 -- print memcntl() (fifth) argument */ 3040 prt_mad, /* MAD -- print madvise() argument */ 3041 prt_ulm, /* ULM -- print ulimit() argument */ 3042 prt_rlm, /* RLM -- print get/setrlimit() argument */ 3043 prt_cnf, /* CNF -- print sysconfig() argument */ 3044 prt_inf, /* INF -- print sysinfo() argument */ 3045 prt_ptc, /* PTC -- print pathconf/fpathconf() argument */ 3046 prt_fui, /* FUI -- print fusers() input argument */ 3047 prt_idt, /* IDT -- print idtype_t, waitid() argument */ 3048 prt_lwf, /* LWF -- print lwp_create() flags */ 3049 prt_itm, /* ITM -- print [get|set]itimer() arg */ 3050 prt_llo, /* LLO -- print long long offset arg */ 3051 prt_mod, /* MOD -- print modctl() subcode */ 3052 prt_whn, /* WHN -- print lseek() whence arguiment */ 3053 prt_acl, /* ACL -- print acl() code */ 3054 prt_aio, /* AIO -- print kaio() code */ 3055 prt_aud, /* AUD -- print auditsys() code */ 3056 prt_uns, /* DEC -- print value in unsigned decimal */ 3057 prt_clc, /* CLC -- print cladm command argument */ 3058 prt_clf, /* CLF -- print cladm flag argument */ 3059 prt_cor, /* COR -- print corectl() subcode */ 3060 prt_cco, /* CCO -- print corectl() options */ 3061 prt_ccc, /* CCC -- print corectl() content */ 3062 prt_rcc, /* RCC -- print corectl() returned content */ 3063 prt_cpc, /* CPC -- print cpc() subcode */ 3064 prt_sqc, /* SQC -- print sigqueue() si_code argument */ 3065 prt_pc4, /* PC4 -- print priocntlsys() (fourth) argument */ 3066 prt_pc5, /* PC5 -- print priocntlsys() (key, value) pairs */ 3067 prt_pst, /* PST -- print processor set id */ 3068 prt_mif, /* MIF -- print meminfo() arguments */ 3069 prt_pfm, /* PFM -- print so_socket() proto-family (1st) arg */ 3070 prt_skt, /* SKT -- print so_socket() socket-type (2nd) arg */ 3071 prt_skp, /* SKP -- print so_socket() protocol (3rd) arg */ 3072 prt_skv, /* SKV -- print socket version arg */ 3073 prt_sol, /* SOL -- print [sg]etsockopt() level (2nd) arg */ 3074 prt_son, /* SON -- print [sg]etsockopt() opt-name (3rd) arg */ 3075 prt_utt, /* UTT -- print utrap type */ 3076 prt_uth, /* UTH -- print utrap handler */ 3077 prt_acc, /* ACC -- print access() flags */ 3078 prt_sht, /* SHT -- print shutdown() how (2nd) argument */ 3079 prt_ffg, /* FFG -- print fcntl() flags (3rd) argument */ 3080 prt_prs, /* PRS -- print privilege set */ 3081 prt_pro, /* PRO -- print privilege set operation */ 3082 prt_prn, /* PRN -- print privilege set name */ 3083 prt_pfl, /* PFL -- print privilege/process flag name */ 3084 prt_laf, /* LAF -- print lgrp_affinity arguments */ 3085 prt_key, /* KEY -- print key_t 0 as IPC_PRIVATE */ 3086 prt_zga, /* ZGA -- print zone_getattr attribute types */ 3087 prt_atc, /* ATC -- print AT_FDCWD or file descriptor */ 3088 prt_lio, /* LIO -- print LIO_XX flags */ 3089 prt_dfl, /* DFL -- print door_create() flags */ 3090 prt_dpm, /* DPM -- print DOOR_PARAM_XX flags */ 3091 prt_tnd, /* TND -- print trusted network data base opcode */ 3092 prt_rsc, /* RSC -- print rctlsys() subcodes */ 3093 prt_rgf, /* RGF -- print getrctl() flags */ 3094 prt_rsf, /* RSF -- print setrctl() flags */ 3095 prt_rcf, /* RCF -- print rctlsys_ctl() flags */ 3096 prt_fxf, /* FXF -- print forkx() flags */ 3097 prt_spf, /* SPF -- print rctlsys_projset() flags */ 3098 prt_un1, /* UN1 -- as prt_uns except for -1 */ 3099 prt_mob, /* MOB -- print mmapobj() flags */ 3100 prt_snf, /* SNF -- print AT_SYMLINK_[NO]FOLLOW flag */ 3101 prt_skc, /* SKC -- print sockconfig() subcode */ 3102 prt_acf, /* ACF -- print accept4 flags */ 3103 prt_pfd, /* PFD -- print pipe fds */ 3104 prt_grf, /* GRF -- print getrandom flags */ 3105 prt_psdelta, /* PSDLT -- print psecflags(2) delta */ 3106 prt_psfw, /* PSFW -- print psecflags(2) set */ 3107 prt_dec, /* HID -- hidden argument, make this the last one */ 3108 }; 3109