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