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