File: | src/usr.bin/kdump/kdump.c |
Warning: | line 1120, column 2 Assigned value is garbage or undefined |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* $OpenBSD: kdump.c,v 1.145 2021/12/23 18:50:32 guenther Exp $ */ | |||
2 | ||||
3 | /*- | |||
4 | * Copyright (c) 1988, 1993 | |||
5 | * The Regents of the University of California. All rights reserved. | |||
6 | * | |||
7 | * Redistribution and use in source and binary forms, with or without | |||
8 | * modification, are permitted provided that the following conditions | |||
9 | * are met: | |||
10 | * 1. Redistributions of source code must retain the above copyright | |||
11 | * notice, this list of conditions and the following disclaimer. | |||
12 | * 2. Redistributions in binary form must reproduce the above copyright | |||
13 | * notice, this list of conditions and the following disclaimer in the | |||
14 | * documentation and/or other materials provided with the distribution. | |||
15 | * 3. Neither the name of the University nor the names of its contributors | |||
16 | * may be used to endorse or promote products derived from this software | |||
17 | * without specific prior written permission. | |||
18 | * | |||
19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |||
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |||
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |||
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |||
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |||
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |||
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |||
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||
29 | * SUCH DAMAGE. | |||
30 | */ | |||
31 | ||||
32 | #include <sys/param.h> /* MAXCOMLEN nitems */ | |||
33 | #include <sys/time.h> | |||
34 | #include <sys/signal.h> | |||
35 | #include <sys/uio.h> | |||
36 | #include <sys/ktrace.h> | |||
37 | #include <sys/ioctl.h> | |||
38 | #include <sys/malloc.h> | |||
39 | #include <sys/namei.h> | |||
40 | #include <sys/ptrace.h> | |||
41 | #include <sys/sem.h> | |||
42 | #include <sys/shm.h> | |||
43 | #include <sys/socket.h> | |||
44 | #include <sys/sysctl.h> | |||
45 | #include <sys/siginfo.h> | |||
46 | #include <sys/vmmeter.h> | |||
47 | #include <sys/tty.h> | |||
48 | #include <sys/wait.h> | |||
49 | #define PLEDGENAMES | |||
50 | #include <sys/pledge.h> | |||
51 | #undef PLEDGENAMES | |||
52 | #define _KERNEL | |||
53 | #include <errno(*__errno()).h> | |||
54 | #undef _KERNEL | |||
55 | #include <ddb/db_var.h> | |||
56 | #include <machine/cpu.h> | |||
57 | ||||
58 | #include <ctype.h> | |||
59 | #include <err.h> | |||
60 | #include <fcntl.h> | |||
61 | #include <limits.h> | |||
62 | #include <netdb.h> | |||
63 | #include <poll.h> | |||
64 | #include <signal.h> | |||
65 | #include <stddef.h> | |||
66 | #include <stdint.h> | |||
67 | #include <stdio.h> | |||
68 | #include <stdlib.h> | |||
69 | #include <string.h> | |||
70 | #include <unistd.h> | |||
71 | #include <vis.h> | |||
72 | ||||
73 | #include "ktrace.h" | |||
74 | #include "kdump.h" | |||
75 | #include "kdump_subr.h" | |||
76 | #include "extern.h" | |||
77 | ||||
78 | enum { | |||
79 | TIMESTAMP_NONE, | |||
80 | TIMESTAMP_ABSOLUTE, | |||
81 | TIMESTAMP_RELATIVE, | |||
82 | TIMESTAMP_ELAPSED | |||
83 | } timestamp = TIMESTAMP_NONE; | |||
84 | ||||
85 | int decimal, iohex, fancy = 1, maxdata = INT_MAX2147483647; | |||
86 | int needtid, tail, basecol; | |||
87 | char *tracefile = DEF_TRACEFILE"ktrace.out"; | |||
88 | struct ktr_header ktr_header; | |||
89 | pid_t pid_opt = -1; | |||
90 | ||||
91 | #define eqs(s1, s2)(strcmp((s1), (s2)) == 0) (strcmp((s1), (s2)) == 0) | |||
92 | ||||
93 | #include <sys/syscall.h> | |||
94 | ||||
95 | #define KTRACE | |||
96 | #define PTRACE | |||
97 | #define NFSCLIENT | |||
98 | #define NFSSERVER | |||
99 | #define SYSVSEM | |||
100 | #define SYSVMSG | |||
101 | #define SYSVSHM | |||
102 | #define ACCOUNTING | |||
103 | #include <kern/syscalls.c> | |||
104 | #undef KTRACE | |||
105 | #undef PTRACE | |||
106 | #undef NFSCLIENT | |||
107 | #undef NFSSERVER | |||
108 | #undef SYSVSEM | |||
109 | #undef SYSVMSG | |||
110 | #undef SYSVSHM | |||
111 | #undef ACCOUNTING | |||
112 | ||||
113 | ||||
114 | static char *ptrace_ops[] = { | |||
115 | "PT_TRACE_ME", "PT_READ_I", "PT_READ_D", "PT_READ_U", | |||
116 | "PT_WRITE_I", "PT_WRITE_D", "PT_WRITE_U", "PT_CONTINUE", | |||
117 | "PT_KILL", "PT_ATTACH", "PT_DETACH", "PT_IO", | |||
118 | "PT_SET_EVENT_MASK", "PT_GET_EVENT_MASK", "PT_GET_PROCESS_STATE", | |||
119 | "PT_GET_THREAD_FIRST", "PT_GET_THREAD_NEXT", | |||
120 | }; | |||
121 | ||||
122 | static int fread_tail(void *, size_t, size_t); | |||
123 | static void dumpheader(struct ktr_header *); | |||
124 | static void ktrgenio(struct ktr_genio *, size_t); | |||
125 | static void ktrnamei(const char *, size_t); | |||
126 | static void ktrpsig(struct ktr_psig *); | |||
127 | static void ktrsyscall(struct ktr_syscall *, size_t); | |||
128 | static const char *kresolvsysctl(int, const int *); | |||
129 | static void ktrsysret(struct ktr_sysret *, size_t); | |||
130 | static void ktruser(struct ktr_user *, size_t); | |||
131 | static void ktrexec(const char*, size_t); | |||
132 | static void ktrpledge(struct ktr_pledge *, size_t); | |||
133 | static void usage(void); | |||
134 | static void ioctldecode(int); | |||
135 | static void ptracedecode(int); | |||
136 | static void atfd(int); | |||
137 | static void polltimeout(int); | |||
138 | static void wait4pid(int); | |||
139 | static void signame(int); | |||
140 | static void semctlname(int); | |||
141 | static void shmctlname(int); | |||
142 | static void semgetname(int); | |||
143 | static void flagsandmodename(int); | |||
144 | static void clockname(int); | |||
145 | static void sockoptlevelname(int); | |||
146 | static void ktraceopname(int); | |||
147 | ||||
148 | static int screenwidth; | |||
149 | ||||
150 | int | |||
151 | main(int argc, char *argv[]) | |||
152 | { | |||
153 | int ch, silent; | |||
154 | size_t ktrlen, size; | |||
155 | int trpoints = ALL_POINTS(((1<<1) | (1<<2) | (1<<3) | (1<<4) | (1<<5) | (1<<8) | (1<<9) | (1<<10) | (1<<12)) | (1<<11)); | |||
156 | const char *errstr; | |||
157 | void *m; | |||
158 | ||||
159 | if (screenwidth == 0) { | |||
| ||||
160 | struct winsize ws; | |||
161 | ||||
162 | if (fancy && ioctl(fileno(stderr)(!__isthreaded ? (((&__sF[2]))->_file) : (fileno)((& __sF[2]))), TIOCGWINSZ((unsigned long)0x40000000 | ((sizeof(struct winsize) & 0x1fff ) << 16) | ((('t')) << 8) | ((104))), &ws) != -1 && | |||
163 | ws.ws_col > 8) | |||
164 | screenwidth = ws.ws_col; | |||
165 | else | |||
166 | screenwidth = 80; | |||
167 | } | |||
168 | ||||
169 | while ((ch = getopt(argc, argv, "f:dHlm:np:RTt:xX")) != -1) | |||
170 | switch (ch) { | |||
171 | case 'f': | |||
172 | tracefile = optarg; | |||
173 | break; | |||
174 | case 'd': | |||
175 | decimal = 1; | |||
176 | break; | |||
177 | case 'H': | |||
178 | needtid = 1; | |||
179 | break; | |||
180 | case 'l': | |||
181 | tail = 1; | |||
182 | break; | |||
183 | case 'm': | |||
184 | maxdata = strtonum(optarg, 0, INT_MAX2147483647, &errstr); | |||
185 | if (errstr) | |||
186 | errx(1, "-m %s: %s", optarg, errstr); | |||
187 | break; | |||
188 | case 'n': | |||
189 | fancy = 0; | |||
190 | break; | |||
191 | case 'p': | |||
192 | pid_opt = strtonum(optarg, 1, INT_MAX2147483647, &errstr); | |||
193 | if (errstr) | |||
194 | errx(1, "-p %s: %s", optarg, errstr); | |||
195 | break; | |||
196 | case 'R': /* relative timestamp */ | |||
197 | if (timestamp == TIMESTAMP_ABSOLUTE) | |||
198 | timestamp = TIMESTAMP_ELAPSED; | |||
199 | else | |||
200 | timestamp = TIMESTAMP_RELATIVE; | |||
201 | break; | |||
202 | case 'T': | |||
203 | if (timestamp == TIMESTAMP_RELATIVE) | |||
204 | timestamp = TIMESTAMP_ELAPSED; | |||
205 | else | |||
206 | timestamp = TIMESTAMP_ABSOLUTE; | |||
207 | break; | |||
208 | case 't': | |||
209 | trpoints = getpoints(optarg, DEF_POINTS((1<<1) | (1<<2) | (1<<3) | (1<<4) | ( 1<<5) | (1<<8) | (1<<9) | (1<<10) | ( 1<<12))); | |||
210 | if (trpoints < 0) | |||
211 | errx(1, "unknown trace point in %s", optarg); | |||
212 | break; | |||
213 | case 'x': | |||
214 | iohex = 1; | |||
215 | break; | |||
216 | case 'X': | |||
217 | iohex = 2; | |||
218 | break; | |||
219 | default: | |||
220 | usage(); | |||
221 | } | |||
222 | if (argc > optind) | |||
223 | usage(); | |||
224 | ||||
225 | if (strcmp(tracefile, "-") != 0) | |||
226 | if (unveil(tracefile, "r") == -1) | |||
227 | err(1, "unveil %s", tracefile); | |||
228 | if (unveil(_PATH_PROTOCOLS"/etc/protocols", "r") == -1) | |||
229 | err(1, "unveil %s", _PATH_PROTOCOLS"/etc/protocols"); | |||
230 | if (pledge("stdio rpath getpw", NULL((void*)0)) == -1) | |||
231 | err(1, "pledge"); | |||
232 | ||||
233 | m = malloc(size = 1025); | |||
234 | if (m == NULL((void*)0)) | |||
235 | err(1, NULL((void*)0)); | |||
236 | if (strcmp(tracefile, "-") != 0) | |||
237 | if (!freopen(tracefile, "r", stdin(&__sF[0]))) | |||
238 | err(1, "%s", tracefile); | |||
239 | ||||
240 | if (fread_tail(&ktr_header, sizeof(struct ktr_header), 1) == 0 || | |||
241 | ktr_header.ktr_type != htobe32(KTR_START)(__uint32_t)(__builtin_constant_p(0x4b545200) ? (__uint32_t)( ((__uint32_t)(0x4b545200) & 0xff) << 24 | ((__uint32_t )(0x4b545200) & 0xff00) << 8 | ((__uint32_t)(0x4b545200 ) & 0xff0000) >> 8 | ((__uint32_t)(0x4b545200) & 0xff000000) >> 24) : __swap32md(0x4b545200))) | |||
242 | errx(1, "%s: not a dump", tracefile); | |||
243 | while (fread_tail(&ktr_header, sizeof(struct ktr_header), 1)) { | |||
244 | silent = 0; | |||
245 | if (pid_opt != -1 && pid_opt != ktr_header.ktr_pid) | |||
246 | silent = 1; | |||
247 | if (silent
| |||
248 | dumpheader(&ktr_header); | |||
249 | ktrlen = ktr_header.ktr_len; | |||
250 | if (ktrlen > size) { | |||
251 | void *newm; | |||
252 | ||||
253 | if (ktrlen == SIZE_MAX0xffffffffffffffffUL) | |||
254 | errx(1, "data too long"); | |||
255 | newm = realloc(m, ktrlen+1); | |||
256 | if (newm == NULL((void*)0)) | |||
257 | err(1, "realloc"); | |||
258 | m = newm; | |||
259 | size = ktrlen; | |||
260 | } | |||
261 | if (ktrlen && fread_tail(m, ktrlen, 1) == 0) | |||
262 | errx(1, "data too short"); | |||
263 | if (silent
| |||
264 | continue; | |||
265 | if ((trpoints & (1<<ktr_header.ktr_type)) == 0) | |||
266 | continue; | |||
267 | switch (ktr_header.ktr_type) { | |||
268 | case KTR_SYSCALL1: | |||
269 | ktrsyscall(m, ktrlen); | |||
270 | break; | |||
271 | case KTR_SYSRET2: | |||
272 | ktrsysret(m, ktrlen); | |||
273 | break; | |||
274 | case KTR_NAMEI3: | |||
275 | ktrnamei(m, ktrlen); | |||
276 | break; | |||
277 | case KTR_GENIO4: | |||
278 | ktrgenio(m, ktrlen); | |||
279 | break; | |||
280 | case KTR_PSIG5: | |||
281 | ktrpsig(m); | |||
282 | break; | |||
283 | case KTR_STRUCT8: | |||
284 | ktrstruct(m, ktrlen); | |||
285 | break; | |||
286 | case KTR_USER9: | |||
287 | ktruser(m, ktrlen); | |||
288 | break; | |||
289 | case KTR_EXECARGS10: | |||
290 | case KTR_EXECENV11: | |||
291 | ktrexec(m, ktrlen); | |||
292 | break; | |||
293 | case KTR_PLEDGE12: | |||
294 | ktrpledge(m, ktrlen); | |||
295 | break; | |||
296 | default: | |||
297 | printf("\n"); | |||
298 | break; | |||
299 | } | |||
300 | if (tail) | |||
301 | (void)fflush(stdout(&__sF[1])); | |||
302 | } | |||
303 | exit(0); | |||
304 | } | |||
305 | ||||
306 | static int | |||
307 | fread_tail(void *buf, size_t size, size_t num) | |||
308 | { | |||
309 | int i; | |||
310 | ||||
311 | while ((i = fread(buf, size, num, stdin(&__sF[0]))) == 0 && tail) { | |||
312 | (void)sleep(1); | |||
313 | clearerr(stdin)(!__isthreaded ? ((void)(((&__sF[0]))->_flags &= ~ (0x0040|0x0020))) : (clearerr)((&__sF[0]))); | |||
314 | } | |||
315 | return (i); | |||
316 | } | |||
317 | ||||
318 | static void | |||
319 | dumpheader(struct ktr_header *kth) | |||
320 | { | |||
321 | static struct timespec prevtime; | |||
322 | char unknown[64], *type; | |||
323 | struct timespec temp; | |||
324 | ||||
325 | switch (kth->ktr_type) { | |||
326 | case KTR_SYSCALL1: | |||
327 | type = "CALL"; | |||
328 | break; | |||
329 | case KTR_SYSRET2: | |||
330 | type = "RET "; | |||
331 | break; | |||
332 | case KTR_NAMEI3: | |||
333 | type = "NAMI"; | |||
334 | break; | |||
335 | case KTR_GENIO4: | |||
336 | type = "GIO "; | |||
337 | break; | |||
338 | case KTR_PSIG5: | |||
339 | type = "PSIG"; | |||
340 | break; | |||
341 | case KTR_STRUCT8: | |||
342 | type = "STRU"; | |||
343 | break; | |||
344 | case KTR_USER9: | |||
345 | type = "USER"; | |||
346 | break; | |||
347 | case KTR_EXECARGS10: | |||
348 | type = "ARGS"; | |||
349 | break; | |||
350 | case KTR_EXECENV11: | |||
351 | type = "ENV "; | |||
352 | break; | |||
353 | case KTR_PLEDGE12: | |||
354 | type = "PLDG"; | |||
355 | break; | |||
356 | default: | |||
357 | /* htobe32() not guaranteed to work as case label */ | |||
358 | if (kth->ktr_type == htobe32(KTR_START)(__uint32_t)(__builtin_constant_p(0x4b545200) ? (__uint32_t)( ((__uint32_t)(0x4b545200) & 0xff) << 24 | ((__uint32_t )(0x4b545200) & 0xff00) << 8 | ((__uint32_t)(0x4b545200 ) & 0xff0000) >> 8 | ((__uint32_t)(0x4b545200) & 0xff000000) >> 24) : __swap32md(0x4b545200))) { | |||
359 | type = "STRT"; | |||
360 | break; | |||
361 | } | |||
362 | (void)snprintf(unknown, sizeof unknown, "UNKNOWN(%u)", | |||
363 | kth->ktr_type); | |||
364 | type = unknown; | |||
365 | } | |||
366 | ||||
367 | basecol = printf("%6ld", (long)kth->ktr_pid); | |||
368 | if (needtid) | |||
369 | basecol += printf("/%-7ld", (long)kth->ktr_tid); | |||
370 | basecol += printf(" %-8.*s ", MAXCOMLEN16, kth->ktr_comm); | |||
371 | if (timestamp != TIMESTAMP_NONE) { | |||
372 | if (timestamp == TIMESTAMP_ELAPSED) { | |||
373 | if (prevtime.tv_sec == 0) | |||
374 | prevtime = kth->ktr_time; | |||
375 | timespecsub(&kth->ktr_time, &prevtime, &temp)do { (&temp)->tv_sec = (&kth->ktr_time)->tv_sec - (&prevtime)->tv_sec; (&temp)->tv_nsec = (& kth->ktr_time)->tv_nsec - (&prevtime)->tv_nsec; if ((&temp)->tv_nsec < 0) { (&temp)->tv_sec--; (&temp)->tv_nsec += 1000000000L; } } while (0); | |||
376 | } else if (timestamp == TIMESTAMP_RELATIVE) { | |||
377 | timespecsub(&kth->ktr_time, &prevtime, &temp)do { (&temp)->tv_sec = (&kth->ktr_time)->tv_sec - (&prevtime)->tv_sec; (&temp)->tv_nsec = (& kth->ktr_time)->tv_nsec - (&prevtime)->tv_nsec; if ((&temp)->tv_nsec < 0) { (&temp)->tv_sec--; (&temp)->tv_nsec += 1000000000L; } } while (0); | |||
378 | prevtime = kth->ktr_time; | |||
379 | } else | |||
380 | temp = kth->ktr_time; | |||
381 | basecol += printf("%lld.%06ld ", (long long)temp.tv_sec, | |||
382 | temp.tv_nsec / 1000); | |||
383 | } | |||
384 | basecol += printf("%s ", type); | |||
385 | } | |||
386 | ||||
387 | /* | |||
388 | * Base Formatters | |||
389 | */ | |||
390 | ||||
391 | /* some syscalls have padding that shouldn't be shown */ | |||
392 | static int | |||
393 | pad(long arg) | |||
394 | { | |||
395 | /* nothing printed */ | |||
396 | return (1); | |||
397 | } | |||
398 | ||||
399 | /* a formatter that just saves the argument for the next formatter */ | |||
400 | int arg1; | |||
401 | static int | |||
402 | pass_two(long arg) | |||
403 | { | |||
404 | arg1 = (int)arg; | |||
405 | ||||
406 | /* nothing printed */ | |||
407 | return (1); | |||
408 | } | |||
409 | ||||
410 | static int | |||
411 | pdeclong(long arg) | |||
412 | { | |||
413 | (void)printf("%ld", arg); | |||
414 | return (0); | |||
415 | } | |||
416 | ||||
417 | static int | |||
418 | pdeculong(long arg) | |||
419 | { | |||
420 | (void)printf("%lu", arg); | |||
421 | return (0); | |||
422 | } | |||
423 | ||||
424 | static int | |||
425 | phexlong(long arg) | |||
426 | { | |||
427 | (void)printf("%#lx", arg); | |||
428 | return (0); | |||
429 | } | |||
430 | ||||
431 | static int | |||
432 | pnonfancy(long arg) | |||
433 | { | |||
434 | if (decimal) | |||
435 | (void)printf("%ld", arg); | |||
436 | else | |||
437 | (void)printf("%#lx", arg); | |||
438 | return (0); | |||
439 | } | |||
440 | ||||
441 | static void | |||
442 | pdecint(int arg) | |||
443 | { | |||
444 | (void)printf("%d", arg); | |||
445 | } | |||
446 | ||||
447 | static void | |||
448 | pdecuint(int arg) | |||
449 | { | |||
450 | (void)printf("%u", arg); | |||
451 | } | |||
452 | ||||
453 | static void | |||
454 | phexint(int arg) | |||
455 | { | |||
456 | (void)printf("%#x", arg); | |||
457 | } | |||
458 | ||||
459 | static void | |||
460 | poctint(int arg) | |||
461 | { | |||
462 | (void)printf("%#o", arg); | |||
463 | } | |||
464 | ||||
465 | ||||
466 | #ifdef __LP64__1 | |||
467 | ||||
468 | /* on LP64, long long arguments are the same as long arguments */ | |||
469 | #define PhexlonglongPhexlong Phexlong | |||
470 | #define phexll((void*)0) NULL((void*)0) /* not actually used on LP64 */ | |||
471 | ||||
472 | /* no padding before long long arguments, nor at end */ | |||
473 | #define PAD640 0 | |||
474 | #define END64end_of_args end_of_args | |||
475 | ||||
476 | #else /* __LP64__ */ | |||
477 | ||||
478 | /* on ILP32, long long arguments are passed as two 32bit args */ | |||
479 | #define PhexlonglongPhexlong PASS_LONGLONG, Phexll | |||
480 | ||||
481 | static int | |||
482 | phexll((void*)0)(long arg2) | |||
483 | { | |||
484 | long long val; | |||
485 | ||||
486 | #if _BYTE_ORDER1234 == _LITTLE_ENDIAN1234 | |||
487 | val = ((long long)arg2 << 32) | ((long long)arg1 & 0xffffffff); | |||
488 | #else | |||
489 | val = ((long long)arg1 << 32) | ((long long)arg2 & 0xffffffff); | |||
490 | #endif | |||
491 | ||||
492 | if (fancy || !decimal) | |||
493 | (void)printf("%#llx", val); | |||
494 | else | |||
495 | (void)printf("%lld", val); | |||
496 | return (0); | |||
497 | } | |||
498 | ||||
499 | /* | |||
500 | * Some ILP32 archs naturally align off_t arguments to 8byte boundaries | |||
501 | * Get the compiler to tell if this arch is one of them. | |||
502 | */ | |||
503 | struct padding_test { | |||
504 | int padtest_one; | |||
505 | off_t padtest_two; | |||
506 | }; | |||
507 | #define PAD640 (offsetof(struct padding_test,padtest_two)__builtin_offsetof(struct padding_test, padtest_two) == 8) | |||
508 | #define END64end_of_args (PAD640 ? PASS_LONGLONG : end_of_args) | |||
509 | ||||
510 | #endif /* __LP64__ */ | |||
511 | ||||
512 | static int (*long_formatters[])(long) = { | |||
513 | NULL((void*)0), | |||
514 | pdeclong, | |||
515 | pdeculong, | |||
516 | phexlong, | |||
517 | pass_two, | |||
518 | pass_two, | |||
519 | phexll((void*)0), | |||
520 | pad, | |||
521 | pnonfancy, | |||
522 | }; | |||
523 | ||||
524 | static void (*formatters[])(int) = { | |||
525 | NULL((void*)0), | |||
526 | pdecint, | |||
527 | phexint, | |||
528 | poctint, | |||
529 | pdecuint, | |||
530 | ioctldecode, | |||
531 | ptracedecode, | |||
532 | atfd, | |||
533 | polltimeout, | |||
534 | wait4pid, | |||
535 | signame, | |||
536 | semctlname, | |||
537 | shmctlname, | |||
538 | semgetname, | |||
539 | flagsandmodename, | |||
540 | clockname, | |||
541 | sockoptlevelname, | |||
542 | ktraceopname, | |||
543 | fcntlcmdname, | |||
544 | modename, | |||
545 | flagsname, | |||
546 | openflagsname, | |||
547 | atflagsname, | |||
548 | accessmodename, | |||
549 | mmapprotname, | |||
550 | mmapflagsname, | |||
551 | wait4optname, | |||
552 | sendrecvflagsname, | |||
553 | mountflagsname, | |||
554 | rebootoptname, | |||
555 | flockname, | |||
556 | sockoptname, | |||
557 | sockipprotoname, | |||
558 | socktypename, | |||
559 | sockflagsname, | |||
560 | sockfamilyname, | |||
561 | mlockallname, | |||
562 | shmatname, | |||
563 | whencename, | |||
564 | pathconfname, | |||
565 | rlimitname, | |||
566 | shutdownhowname, | |||
567 | prioname, | |||
568 | madvisebehavname, | |||
569 | msyncflagsname, | |||
570 | clocktypename, | |||
571 | rusagewho, | |||
572 | sigactionflagname, | |||
573 | sigprocmaskhowname, | |||
574 | minheritname, | |||
575 | quotactlname, | |||
576 | sigill_name, | |||
577 | sigtrap_name, | |||
578 | sigemt_name, | |||
579 | sigfpe_name, | |||
580 | sigbus_name, | |||
581 | sigsegv_name, | |||
582 | sigchld_name, | |||
583 | ktracefacname, | |||
584 | itimername, | |||
585 | sigset, | |||
586 | uidname, | |||
587 | gidname, | |||
588 | syslogflagname, | |||
589 | futexflagname, | |||
590 | }; | |||
591 | ||||
592 | enum { | |||
593 | /* the end of the (known) arguments is recognized by the zero fill */ | |||
594 | end_of_args = 0, | |||
595 | ||||
596 | /* negative are the negative of the index into long_formatters[] */ | |||
597 | Pdeclong = -1, | |||
598 | Pdeculong = -2, | |||
599 | Phexlong = -3, | |||
600 | PASS_TWO = -4, | |||
601 | ||||
602 | /* the remaining long formatters still get called when non-fancy (-n option) */ | |||
603 | #define FMT_IS_NONFANCY(x)((x) <= PASS_LONGLONG) ((x) <= PASS_LONGLONG) | |||
604 | PASS_LONGLONG = -5, | |||
605 | Phexll = -6, | |||
606 | PAD = -7, | |||
607 | Pnonfancy = -8, | |||
608 | ||||
609 | /* positive values are the index into formatters[] */ | |||
610 | Pdecint = 1, | |||
611 | Phexint, | |||
612 | Poctint, | |||
613 | Pdecuint, | |||
614 | Ioctldecode, | |||
615 | Ptracedecode, | |||
616 | Atfd, | |||
617 | Polltimeout, | |||
618 | Wait4pid, | |||
619 | Signame, | |||
620 | Semctlname, | |||
621 | Shmctlname, | |||
622 | Semgetname, | |||
623 | Flagsandmodename, | |||
624 | Clockname, | |||
625 | Sockoptlevelname, | |||
626 | Ktraceopname, | |||
627 | Fcntlcmdname, | |||
628 | Modename, | |||
629 | Flagsname, | |||
630 | Openflagsname, | |||
631 | Atflagsname, | |||
632 | Accessmodename, | |||
633 | Mmapprotname, | |||
634 | Mmapflagsname, | |||
635 | Wait4optname, | |||
636 | Sendrecvflagsname, | |||
637 | Mountflagsname, | |||
638 | Rebootoptname, | |||
639 | Flockname, | |||
640 | Sockoptname, | |||
641 | Sockipprotoname, | |||
642 | Socktypename, | |||
643 | Sockflagsname, | |||
644 | Sockfamilyname, | |||
645 | Mlockallname, | |||
646 | Shmatname, | |||
647 | Whencename, | |||
648 | Pathconfname, | |||
649 | Rlimitname, | |||
650 | Shutdownhowname, | |||
651 | Prioname, | |||
652 | Madvisebehavname, | |||
653 | Msyncflagsname, | |||
654 | Clocktypename, | |||
655 | Rusagewho, | |||
656 | Sigactionflagname, | |||
657 | Sigprocmaskhowname, | |||
658 | Minheritname, | |||
659 | Quotactlname, | |||
660 | Sigill_name, | |||
661 | Sigtrap_name, | |||
662 | Sigemt_name, | |||
663 | Sigfpe_name, | |||
664 | Sigbus_name, | |||
665 | Sigsegv_name, | |||
666 | Sigchld_name, | |||
667 | Ktracefacname, | |||
668 | Itimername, | |||
669 | Sigset, | |||
670 | Uidname, | |||
671 | Gidname, | |||
672 | Syslogflagname, | |||
673 | Futexflagname, | |||
674 | }; | |||
675 | ||||
676 | #define PptrPhexlong Phexlong | |||
677 | #define PsizePdeculong Pdeculong /* size_t for small buffers */ | |||
678 | #define PbigsizePhexlong Phexlong /* size_t for I/O buffers */ | |||
679 | #define PcountPdecint Pdecint /* int for a count of something */ | |||
680 | #define PfdPdecint Pdecint | |||
681 | #define PpathPhexlong Phexlong | |||
682 | #define Pdev_tPdecint Pdecint | |||
683 | #define Ppid_tPdecint Pdecint | |||
684 | #define PpgidPdecint Pdecint /* pid or negative pgid */ | |||
685 | #define Poff_tPhexlong PhexlonglongPhexlong | |||
686 | #define PmsqidPdecint Pdecint | |||
687 | #define PshmidPdecint Pdecint | |||
688 | #define PsemidPdecint Pdecint | |||
689 | #define Pkey_tPdecint Pdecint | |||
690 | #define PucountPdecuint Pdecuint | |||
691 | #define ChflagsnamePhexlong Phexlong /* to be added */ | |||
692 | #define SockprotonamePhexlong Phexlong /* to be added */ | |||
693 | #define SwapctlnamePhexlong Phexlong /* to be added */ | |||
694 | #define MsgflgnamePhexlong Phexlong /* to be added */ | |||
695 | ||||
696 | ||||
697 | typedef signed char formatter; | |||
698 | static const formatter scargs[][8] = { | |||
699 | [SYS_exit1] = { Pdecint }, | |||
700 | [SYS_read3] = { PfdPdecint, PptrPhexlong, PbigsizePhexlong }, | |||
701 | [SYS_write4] = { PfdPdecint, PptrPhexlong, PbigsizePhexlong }, | |||
702 | [SYS_open5] = { PpathPhexlong, PASS_TWO, Flagsandmodename }, | |||
703 | [SYS_close6] = { PfdPdecint }, | |||
704 | [SYS_getentropy7] = { PptrPhexlong, PsizePdeculong }, | |||
705 | [SYS___tfork8] = { PptrPhexlong, PsizePdeculong }, | |||
706 | [SYS_link9] = { PpathPhexlong, PpathPhexlong }, | |||
707 | [SYS_unlink10] = { PpathPhexlong }, | |||
708 | [SYS_wait411] = { Wait4pid, PptrPhexlong, Wait4optname }, | |||
709 | [SYS_chdir12] = { PpathPhexlong }, | |||
710 | [SYS_fchdir13] = { PfdPdecint }, | |||
711 | [SYS_mknod14] = { PpathPhexlong, Modename, Pdev_tPdecint }, | |||
712 | [SYS_chmod15] = { PpathPhexlong, Modename }, | |||
713 | [SYS_chown16] = { PpathPhexlong, Uidname, Gidname }, | |||
714 | [SYS_break17] = { PptrPhexlong }, | |||
715 | [SYS_getrusage19] = { Rusagewho, PptrPhexlong }, | |||
716 | [SYS_mount21] = { PptrPhexlong, PpathPhexlong, Mountflagsname, PptrPhexlong }, | |||
717 | [SYS_unmount22] = { PpathPhexlong, Mountflagsname }, | |||
718 | [SYS_setuid23] = { Uidname }, | |||
719 | [SYS_ptrace26] = { Ptracedecode, Ppid_tPdecint, PptrPhexlong, Pdecint }, | |||
720 | [SYS_recvmsg27] = { PfdPdecint, PptrPhexlong, Sendrecvflagsname }, | |||
721 | [SYS_sendmsg28] = { PfdPdecint, PptrPhexlong, Sendrecvflagsname }, | |||
722 | [SYS_recvfrom29] = { PfdPdecint, PptrPhexlong, PbigsizePhexlong, Sendrecvflagsname }, | |||
723 | [SYS_accept30] = { PfdPdecint, PptrPhexlong, PptrPhexlong }, | |||
724 | [SYS_getpeername31] = { PfdPdecint, PptrPhexlong, PptrPhexlong }, | |||
725 | [SYS_getsockname32] = { PfdPdecint, PptrPhexlong, PptrPhexlong }, | |||
726 | [SYS_access33] = { PpathPhexlong, Accessmodename }, | |||
727 | [SYS_chflags34] = { PpathPhexlong, ChflagsnamePhexlong }, | |||
728 | [SYS_fchflags35] = { PfdPdecint, ChflagsnamePhexlong }, | |||
729 | [SYS_kill122] = { PpgidPdecint, Signame }, | |||
730 | [SYS_stat38] = { PpathPhexlong, PptrPhexlong }, | |||
731 | [SYS_lstat40] = { PpathPhexlong, PptrPhexlong }, | |||
732 | [SYS_dup41] = { PfdPdecint }, | |||
733 | [SYS_fstatat42] = { Atfd, PpathPhexlong, PptrPhexlong, Atflagsname }, | |||
734 | [SYS_profil44] = { PptrPhexlong, PbigsizePhexlong, PbigsizePhexlong, Pdecuint }, | |||
735 | [SYS_ktrace45] = { PpathPhexlong, Ktraceopname, Ktracefacname, PpgidPdecint }, | |||
736 | [SYS_sigaction46] = { Signame, PptrPhexlong, PptrPhexlong }, | |||
737 | [SYS_sigprocmask48] = { Sigprocmaskhowname, Sigset }, | |||
738 | [SYS_getlogin_r141] = { PptrPhexlong, PsizePdeculong }, | |||
739 | [SYS_setlogin50] = { PptrPhexlong }, | |||
740 | [SYS_acct51] = { PpathPhexlong }, | |||
741 | [SYS_fstat53] = { PfdPdecint, PptrPhexlong }, | |||
742 | [SYS_ioctl54] = { PfdPdecint, Ioctldecode, PptrPhexlong }, | |||
743 | [SYS_reboot55] = { Rebootoptname }, | |||
744 | [SYS_revoke56] = { PpathPhexlong }, | |||
745 | [SYS_symlink57] = { PpathPhexlong, PpathPhexlong }, | |||
746 | [SYS_readlink58] = { PpathPhexlong, PptrPhexlong, PsizePdeculong }, | |||
747 | [SYS_execve59] = { PpathPhexlong, PptrPhexlong, PptrPhexlong }, | |||
748 | [SYS_umask60] = { Modename }, | |||
749 | [SYS_chroot61] = { PpathPhexlong }, | |||
750 | [SYS_getfsstat62] = { PptrPhexlong, PbigsizePhexlong, Mountflagsname }, | |||
751 | [SYS_statfs63] = { PpathPhexlong, PptrPhexlong }, | |||
752 | [SYS_fstatfs64] = { PfdPdecint, PptrPhexlong }, | |||
753 | [SYS_fhstatfs65] = { PptrPhexlong, PptrPhexlong }, | |||
754 | [SYS_gettimeofday67] = { PptrPhexlong, PptrPhexlong }, | |||
755 | [SYS_settimeofday68] = { PptrPhexlong, PptrPhexlong }, | |||
756 | [SYS_setitimer69] = { Itimername, PptrPhexlong, PptrPhexlong }, | |||
757 | [SYS_getitimer70] = { Itimername, PptrPhexlong }, | |||
758 | [SYS_select71] = { PcountPdecint, PptrPhexlong, PptrPhexlong, PptrPhexlong, PptrPhexlong }, | |||
759 | [SYS_kevent72] = { PfdPdecint, PptrPhexlong, PcountPdecint, PptrPhexlong, PcountPdecint, PptrPhexlong }, | |||
760 | [SYS_munmap73] = { PptrPhexlong, PbigsizePhexlong }, | |||
761 | [SYS_mprotect74] = { PptrPhexlong, PbigsizePhexlong, Mmapprotname }, | |||
762 | [SYS_madvise75] = { PptrPhexlong, PbigsizePhexlong, Madvisebehavname }, | |||
763 | [SYS_utimes76] = { PpathPhexlong, PptrPhexlong }, | |||
764 | [SYS_futimes77] = { PfdPdecint, PptrPhexlong }, | |||
765 | [SYS_kbind86] = { PptrPhexlong, PsizePdeculong, PhexlonglongPhexlong }, | |||
766 | [SYS_getgroups79] = { PcountPdecint, PptrPhexlong }, | |||
767 | [SYS_setgroups80] = { PcountPdecint, PptrPhexlong }, | |||
768 | [SYS_setpgid82] = { Ppid_tPdecint, Ppid_tPdecint }, | |||
769 | [SYS_futex83] = { PptrPhexlong, Futexflagname, PcountPdecint, PptrPhexlong, PptrPhexlong }, | |||
770 | [SYS_sendsyslog112] = { PptrPhexlong, PsizePdeculong, Syslogflagname }, | |||
771 | [SYS_utimensat84] = { Atfd, PpathPhexlong, PptrPhexlong, Atflagsname }, | |||
772 | [SYS_futimens85] = { PfdPdecint, PptrPhexlong }, | |||
773 | [SYS_clock_gettime87] = { Clockname, PptrPhexlong }, | |||
774 | [SYS_clock_settime88] = { Clockname, PptrPhexlong }, | |||
775 | [SYS_clock_getres89] = { Clockname, PptrPhexlong }, | |||
776 | [SYS_dup290] = { PfdPdecint, PfdPdecint }, | |||
777 | [SYS_nanosleep91] = { PptrPhexlong, PptrPhexlong }, | |||
778 | [SYS_fcntl92] = { PfdPdecint, PASS_TWO, Fcntlcmdname }, | |||
779 | [SYS_accept493] = { PfdPdecint, PptrPhexlong, PptrPhexlong, Sockflagsname }, | |||
780 | [SYS___thrsleep94] = { PptrPhexlong, Clockname, PptrPhexlong, PptrPhexlong, PptrPhexlong }, | |||
781 | [SYS_fsync95] = { PfdPdecint }, | |||
782 | [SYS_setpriority96] = { Prioname, Ppid_tPdecint, Pdecint }, | |||
783 | [SYS_socket97] = { Sockfamilyname, Socktypename, SockprotonamePhexlong }, | |||
784 | [SYS_connect98] = { PfdPdecint, PptrPhexlong, PucountPdecuint }, | |||
785 | [SYS_getdents99] = { PfdPdecint, PptrPhexlong, PbigsizePhexlong }, | |||
786 | [SYS_getpriority100] = { Prioname, Ppid_tPdecint }, | |||
787 | [SYS_pipe2101] = { PptrPhexlong, Flagsname }, | |||
788 | [SYS_dup3102] = { PfdPdecint, PfdPdecint, Flagsname }, | |||
789 | [SYS_sigreturn103] = { PptrPhexlong }, | |||
790 | [SYS_bind104] = { PfdPdecint, PptrPhexlong, PucountPdecuint }, | |||
791 | [SYS_setsockopt105] = { PfdPdecint, PASS_TWO, Sockoptlevelname, PptrPhexlong, Pdecint }, | |||
792 | [SYS_listen106] = { PfdPdecint, Pdecint }, | |||
793 | [SYS_chflagsat107] = { Atfd, PpathPhexlong, ChflagsnamePhexlong, Atflagsname }, | |||
794 | [SYS_ppoll109] = { PptrPhexlong, PucountPdecuint, PptrPhexlong, PptrPhexlong }, | |||
795 | [SYS_pselect110] = { PcountPdecint, PptrPhexlong, PptrPhexlong, PptrPhexlong, PptrPhexlong, PptrPhexlong }, | |||
796 | [SYS_sigsuspend111] = { Sigset }, | |||
797 | [SYS_getsockopt118] = { PfdPdecint, PASS_TWO, Sockoptlevelname, PptrPhexlong, PptrPhexlong }, | |||
798 | [SYS_thrkill119] = { Ppid_tPdecint, Signame, PptrPhexlong }, | |||
799 | [SYS_readv120] = { PfdPdecint, PptrPhexlong, PcountPdecint }, | |||
800 | [SYS_writev121] = { PfdPdecint, PptrPhexlong, PcountPdecint }, | |||
801 | [SYS_fchown123] = { PfdPdecint, Uidname, Gidname }, | |||
802 | [SYS_fchmod124] = { PfdPdecint, Modename }, | |||
803 | [SYS_setreuid126] = { Uidname, Uidname }, | |||
804 | [SYS_setregid127] = { Gidname, Gidname }, | |||
805 | [SYS_rename128] = { PpathPhexlong, PpathPhexlong }, | |||
806 | [SYS_flock131] = { PfdPdecint, Flockname }, | |||
807 | [SYS_mkfifo132] = { PpathPhexlong, Modename }, | |||
808 | [SYS_sendto133] = { PfdPdecint, PptrPhexlong, PbigsizePhexlong, Sendrecvflagsname }, | |||
809 | [SYS_shutdown134] = { PfdPdecint, Shutdownhowname }, | |||
810 | [SYS_socketpair135] = { Sockfamilyname, Socktypename, SockprotonamePhexlong, PptrPhexlong }, | |||
811 | [SYS_mkdir136] = { PpathPhexlong, Modename }, | |||
812 | [SYS_rmdir137] = { PpathPhexlong }, | |||
813 | [SYS_adjtime140] = { PptrPhexlong, PptrPhexlong }, | |||
814 | [SYS_quotactl148] = { PpathPhexlong, Quotactlname, Uidname, PptrPhexlong }, | |||
815 | [SYS_nfssvc155] = { Phexint, PptrPhexlong }, | |||
816 | [SYS_getfh161] = { PpathPhexlong, PptrPhexlong }, | |||
817 | [SYS_sysarch165] = { Pdecint, PptrPhexlong }, | |||
818 | [SYS_pread169] = { PfdPdecint, PptrPhexlong, PbigsizePhexlong, Poff_tPhexlong, END64end_of_args }, | |||
819 | [SYS_pwrite170] = { PfdPdecint, PptrPhexlong, PbigsizePhexlong, Poff_tPhexlong, END64end_of_args }, | |||
820 | #ifdef SYS_pad_pread173 | |||
821 | [SYS_pad_pread173] = { PfdPdecint, PptrPhexlong, PbigsizePhexlong, PAD, Poff_tPhexlong }, | |||
822 | [SYS_pad_pwrite174] = { PfdPdecint, PptrPhexlong, PbigsizePhexlong, PAD, Poff_tPhexlong }, | |||
823 | #endif | |||
824 | [SYS_setgid181] = { Gidname }, | |||
825 | [SYS_setegid182] = { Gidname }, | |||
826 | [SYS_seteuid183] = { Uidname }, | |||
827 | [SYS_pathconf191] = { PpathPhexlong, Pathconfname }, | |||
828 | [SYS_fpathconf192] = { PfdPdecint, Pathconfname }, | |||
829 | [SYS_swapctl193] = { SwapctlnamePhexlong, PptrPhexlong, Pdecint }, | |||
830 | [SYS_getrlimit194] = { Rlimitname, PptrPhexlong }, | |||
831 | [SYS_setrlimit195] = { Rlimitname, PptrPhexlong }, | |||
832 | [SYS_mmap49] = { PptrPhexlong, PbigsizePhexlong, Mmapprotname, Mmapflagsname, PfdPdecint, Poff_tPhexlong, END64end_of_args }, | |||
833 | [SYS_lseek166] = { PfdPdecint, Poff_tPhexlong, Whencename, END64end_of_args }, | |||
834 | [SYS_truncate167] = { PpathPhexlong, Poff_tPhexlong, END64end_of_args }, | |||
835 | [SYS_ftruncate168] = { PfdPdecint, Poff_tPhexlong, END64end_of_args }, | |||
836 | #ifdef SYS_pad_mmap197 | |||
837 | [SYS_pad_mmap197] = { PptrPhexlong, PbigsizePhexlong, Mmapprotname, Mmapflagsname, PfdPdecint, PAD, Poff_tPhexlong }, | |||
838 | [SYS_pad_lseek199] = { PfdPdecint, PAD, Poff_tPhexlong, Whencename }, | |||
839 | [SYS_pad_truncate200] = { PpathPhexlong, PAD, Poff_tPhexlong }, | |||
840 | [SYS_pad_ftruncate201] = { PfdPdecint, PAD, Poff_tPhexlong }, | |||
841 | #endif | |||
842 | [SYS_sysctl202] = { PptrPhexlong, PcountPdecint, PptrPhexlong, PptrPhexlong, PptrPhexlong, PsizePdeculong }, | |||
843 | [SYS_mlock203] = { PptrPhexlong, PbigsizePhexlong }, | |||
844 | [SYS_munlock204] = { PptrPhexlong, PbigsizePhexlong }, | |||
845 | [SYS_getpgid207] = { Ppid_tPdecint }, | |||
846 | [SYS_utrace209] = { PptrPhexlong, PptrPhexlong, PsizePdeculong }, | |||
847 | [SYS_semget221] = { Pkey_tPdecint, PcountPdecint, Semgetname }, | |||
848 | [SYS_msgget225] = { Pkey_tPdecint, MsgflgnamePhexlong }, | |||
849 | [SYS_msgsnd226] = { PmsqidPdecint, PptrPhexlong, PsizePdeculong, MsgflgnamePhexlong }, | |||
850 | [SYS_msgrcv227] = { PmsqidPdecint, PptrPhexlong, PsizePdeculong, Pdeclong, MsgflgnamePhexlong }, | |||
851 | [SYS_shmat228] = { PshmidPdecint, PptrPhexlong, Shmatname }, | |||
852 | [SYS_shmdt230] = { PptrPhexlong }, | |||
853 | [SYS_minherit250] = { PptrPhexlong, PbigsizePhexlong, Minheritname }, | |||
854 | [SYS_poll252] = { PptrPhexlong, PucountPdecuint, Polltimeout }, | |||
855 | [SYS_lchown254] = { PpathPhexlong, Uidname, Gidname }, | |||
856 | [SYS_getsid255] = { Ppid_tPdecint }, | |||
857 | [SYS_msync256] = { PptrPhexlong, PbigsizePhexlong, Msyncflagsname }, | |||
858 | [SYS_pipe263] = { PptrPhexlong }, | |||
859 | [SYS_fhopen264] = { PptrPhexlong, Openflagsname }, | |||
860 | [SYS_preadv171] = { PfdPdecint, PptrPhexlong, PcountPdecint, Poff_tPhexlong, END64end_of_args }, | |||
861 | [SYS_pwritev172] = { PfdPdecint, PptrPhexlong, PcountPdecint, Poff_tPhexlong, END64end_of_args }, | |||
862 | #ifdef SYS_pad_preadv267 | |||
863 | [SYS_pad_preadv267] = { PfdPdecint, PptrPhexlong, PcountPdecint, PAD, Poff_tPhexlong }, | |||
864 | [SYS_pad_pwritev268] = { PfdPdecint, PptrPhexlong, PcountPdecint, PAD, Poff_tPhexlong }, | |||
865 | #endif | |||
866 | [SYS_mlockall271] = { Mlockallname }, | |||
867 | [SYS_getresuid281] = { PptrPhexlong, PptrPhexlong, PptrPhexlong }, | |||
868 | [SYS_setresuid282] = { Uidname, Uidname, Uidname }, | |||
869 | [SYS_getresgid283] = { PptrPhexlong, PptrPhexlong, PptrPhexlong }, | |||
870 | [SYS_setresgid284] = { Gidname, Gidname, Gidname }, | |||
871 | [SYS_mquery78] = { PptrPhexlong, PbigsizePhexlong, Mmapprotname, Mmapflagsname, PfdPdecint, Poff_tPhexlong, END64end_of_args }, | |||
872 | #ifdef SYS_pad_mquery286 | |||
873 | [SYS_pad_mquery286] = { PptrPhexlong, PbigsizePhexlong, Mmapprotname, Mmapflagsname, PfdPdecint, PAD, Poff_tPhexlong }, | |||
874 | #endif | |||
875 | [SYS_closefrom287] = { PfdPdecint }, | |||
876 | [SYS_sigaltstack288] = { PptrPhexlong, PptrPhexlong }, | |||
877 | [SYS_shmget289] = { Pkey_tPdecint, PbigsizePhexlong, Semgetname }, | |||
878 | [SYS_semop290] = { PsemidPdecint, PptrPhexlong, PsizePdeculong }, | |||
879 | [SYS_fhstat294] = { PptrPhexlong, PptrPhexlong }, | |||
880 | [SYS___semctl295] = { PsemidPdecint, PcountPdecint, Semctlname, PptrPhexlong }, | |||
881 | [SYS_shmctl296] = { PshmidPdecint, Shmctlname, PptrPhexlong }, | |||
882 | [SYS_msgctl297] = { PmsqidPdecint, Shmctlname, PptrPhexlong }, | |||
883 | [SYS___thrwakeup301] = { PptrPhexlong, PcountPdecint }, | |||
884 | [SYS___threxit302] = { PptrPhexlong }, | |||
885 | [SYS___thrsigdivert303] = { Sigset, PptrPhexlong, PptrPhexlong }, | |||
886 | [SYS___getcwd304] = { PptrPhexlong, PsizePdeculong }, | |||
887 | [SYS_adjfreq305] = { PptrPhexlong, PptrPhexlong }, | |||
888 | [SYS_setrtable310] = { Pdecint }, | |||
889 | [SYS_faccessat313] = { Atfd, PpathPhexlong, Accessmodename, Atflagsname }, | |||
890 | [SYS_fchmodat314] = { Atfd, PpathPhexlong, Modename, Atflagsname }, | |||
891 | [SYS_fchownat315] = { Atfd, PpathPhexlong, Uidname, Gidname, Atflagsname }, | |||
892 | [SYS_linkat317] = { Atfd, PpathPhexlong, Atfd, PpathPhexlong, Atflagsname }, | |||
893 | [SYS_mkdirat318] = { Atfd, PpathPhexlong, Modename }, | |||
894 | [SYS_mkfifoat319] = { Atfd, PpathPhexlong, Modename }, | |||
895 | [SYS_mknodat320] = { Atfd, PpathPhexlong, Modename, Pdev_tPdecint }, | |||
896 | [SYS_openat321] = { Atfd, PpathPhexlong, PASS_TWO, Flagsandmodename }, | |||
897 | [SYS_readlinkat322] = { Atfd, PpathPhexlong, PptrPhexlong, PsizePdeculong }, | |||
898 | [SYS_renameat323] = { Atfd, PpathPhexlong, Atfd, PpathPhexlong }, | |||
899 | [SYS_symlinkat324] = { PpathPhexlong, Atfd, PpathPhexlong }, | |||
900 | [SYS_unlinkat325] = { Atfd, PpathPhexlong, Atflagsname }, | |||
901 | [SYS___set_tcb329] = { PptrPhexlong }, | |||
902 | }; | |||
903 | ||||
904 | ||||
905 | static void | |||
906 | ktrsyscall(struct ktr_syscall *ktr, size_t ktrlen) | |||
907 | { | |||
908 | register_t *ap; | |||
909 | int narg; | |||
910 | char sep; | |||
911 | ||||
912 | if (ktr->ktr_argsize > ktrlen) | |||
913 | errx(1, "syscall argument length %d > ktr header length %zu", | |||
914 | ktr->ktr_argsize, ktrlen); | |||
915 | ||||
916 | narg = ktr->ktr_argsize / sizeof(register_t); | |||
917 | sep = '\0'; | |||
918 | ||||
919 | if (ktr->ktr_code >= SYS_MAXSYSCALL331 || ktr->ktr_code < 0) | |||
920 | (void)printf("[%d]", ktr->ktr_code); | |||
921 | else | |||
922 | (void)printf("%s", syscallnames[ktr->ktr_code]); | |||
923 | ap = (register_t *)((char *)ktr + sizeof(struct ktr_syscall)); | |||
924 | (void)putchar('(')(!__isthreaded ? __sputc('(', (&__sF[1])) : (putc)('(', ( &__sF[1]))); | |||
925 | ||||
926 | if (ktr->ktr_code == SYS_sysctl202 && fancy) { | |||
927 | const char *s; | |||
928 | int n, i, *top; | |||
929 | ||||
930 | n = ap[1]; | |||
931 | if (n > CTL_MAXNAME12) | |||
932 | n = CTL_MAXNAME12; | |||
933 | if (n < 0) | |||
934 | errx(1, "invalid sysctl length %d", n); | |||
935 | if (n > 0) { | |||
936 | top = (int *)(ap + 6); | |||
937 | printf("%d", top[0]); | |||
938 | for (i = 1; i < n; i++) | |||
939 | printf(".%d", top[i]); | |||
940 | if ((s = kresolvsysctl(0, top)) != NULL((void*)0)) { | |||
941 | printf("<%s", s); | |||
942 | for (i = 1; i < n; i++) { | |||
943 | if ((s = kresolvsysctl(i, top)) != NULL((void*)0)) | |||
944 | printf(".%s", s); | |||
945 | else | |||
946 | printf(".%d", top[i]); | |||
947 | } | |||
948 | putchar('>')(!__isthreaded ? __sputc('>', (&__sF[1])) : (putc)('>' , (&__sF[1]))); | |||
949 | } | |||
950 | } | |||
951 | ||||
952 | sep = ','; | |||
953 | ap += 2; | |||
954 | narg -= 2; | |||
955 | } else if (ktr->ktr_code < nitems(scargs)(sizeof((scargs)) / sizeof((scargs)[0]))) { | |||
956 | const formatter *fmts = scargs[ktr->ktr_code]; | |||
957 | int fmt; | |||
958 | int arg = 0; | |||
959 | ||||
960 | while (arg < narg && (fmt = *fmts) != 0) { | |||
961 | if (PAD640 && fmt == PASS_LONGLONG && (arg & 1)) | |||
962 | goto skip; | |||
963 | if (sep) | |||
964 | putchar(sep)(!__isthreaded ? __sputc(sep, (&__sF[1])) : (putc)(sep, ( &__sF[1]))); | |||
965 | sep = ','; | |||
966 | if (!fancy && !FMT_IS_NONFANCY(fmt)((fmt) <= PASS_LONGLONG)) | |||
967 | fmt = Pnonfancy; | |||
968 | if (fmt > 0) | |||
969 | formatters[fmt]((int)*ap); | |||
970 | else if (long_formatters[-fmt](*ap)) | |||
971 | sep = '\0'; | |||
972 | fmts++; | |||
973 | skip: | |||
974 | ap++; | |||
975 | arg++; | |||
976 | } | |||
977 | narg -= arg; | |||
978 | } | |||
979 | ||||
980 | while (narg > 0) { | |||
981 | if (sep) | |||
982 | putchar(sep)(!__isthreaded ? __sputc(sep, (&__sF[1])) : (putc)(sep, ( &__sF[1]))); | |||
983 | if (decimal) | |||
984 | (void)printf("%ld", (long)*ap); | |||
985 | else | |||
986 | (void)printf("%#lx", (long)*ap); | |||
987 | sep = ','; | |||
988 | ap++; | |||
989 | narg--; | |||
990 | } | |||
991 | (void)printf(")\n"); | |||
992 | } | |||
993 | ||||
994 | static struct ctlname topname[] = CTL_NAMES{ { 0, 0 }, { "kern", 1 }, { "vm", 1 }, { "fs", 1 }, { "net", 1 }, { "debug", 1 }, { "hw", 1 }, { "machdep", 1 }, { "gap", 0 }, { "ddb", 1 }, { "vfs", 1 }, }; | |||
995 | static struct ctlname kernname[] = CTL_KERN_NAMES{ { 0, 0 }, { "ostype", 3 }, { "osrelease", 3 }, { "osrevision" , 2 }, { "version", 3 }, { "maxvnodes", 2 }, { "maxproc", 2 } , { "maxfiles", 2 }, { "argmax", 2 }, { "securelevel", 2 }, { "hostname", 3 }, { "hostid", 2 }, { "clockrate", 5 }, { "gap" , 0 }, { "gap", 0 }, { "gap", 0 }, { "profiling", 1 }, { "posix1version" , 2 }, { "ngroups", 2 }, { "job_control", 2 }, { "saved_ids", 2 }, { "boottime", 5 }, { "domainname", 3 }, { "maxpartitions" , 2 }, { "rawpartition", 2 }, { "maxthread", 2 }, { "nthreads" , 2 }, { "osversion", 3 }, { "somaxconn", 2 }, { "sominconn", 2 }, { "gap", 0 }, { "gap", 0 }, { "nosuidcoredump", 2 }, { "fsync" , 2 }, { "sysvmsg", 2 }, { "sysvsem", 2 }, { "sysvshm", 2 }, { "gap", 0 }, { "msgbufsize", 2 }, { "malloc", 1 }, { "cp_time" , 5 }, { "nchstats", 5 }, { "forkstat", 5 }, { "nselcoll", 2 } , { "tty", 1 }, { "ccpu", 2 }, { "fscale", 2 }, { "nprocs", 2 }, { "msgbuf", 5 }, { "pool", 1 }, { "stackgap_random", 2 }, { "sysvipc_info", 2 }, { "allowkmem", 2 }, { "witnesswatch", 2 }, { "splassert", 2 }, { "procargs", 1 }, { "nfiles", 2 }, { "ttycount", 2 }, { "numvnodes", 2 }, { "mbstat", 5 }, { "witness" , 1 }, { "seminfo", 5 }, { "shminfo", 5 }, { "intrcnt", 1 }, { "watchdog", 1 }, { "allowdt", 2 }, { "proc", 5 }, { "maxclusters" , 2 }, { "evcount", 1 }, { "timecounter", 1 }, { "maxlocksperuid" , 2 }, { "cp_time2", 5 }, { "bufcachepercent", 2 }, { "file", 5 }, { "wxabort", 2 }, { "consdev", 5 }, { "netlivelocks", 2 }, { "pool_debug", 2 }, { "proc_cwd", 1 }, { "proc_nobroadcastkill" , 1 }, { "proc_vmmap", 1 }, { "global_ptrace", 2 }, { "consbufsize" , 2 }, { "consbuf", 5 }, { "audio", 5 }, { "cpustats", 5 }, { "pfstatus", 5 }, { "timeout_stats", 5 }, { "utc_offset", 2 } , { "video", 5 }, }; | |||
996 | static struct ctlname vmname[] = CTL_VM_NAMES{ { 0, 0 }, { "vmmeter", 5 }, { "loadavg", 5 }, { "psstrings" , 5 }, { "uvmexp", 5 }, { "swapencrypt", 1 }, { "nkmempages", 2 }, { "anonmin", 2 }, { "vtextmin", 2 }, { "vnodemin", 2 }, { "maxslp", 2 }, { "uspace", 2 }, { "malloc_conf", 3 }, }; | |||
997 | static struct ctlname fsname[] = CTL_FS_NAMES{ { 0, 0 }, { "posix", 1 }, }; | |||
998 | static struct ctlname netname[] = CTL_NET_NAMES{ { 0, 0 }, { "unix", 1 }, { "inet", 1 }, { "implink", 1 }, { "pup", 1 }, { "chaos", 1 }, { "xerox_ns", 1 }, { "iso", 1 }, { "ecma", 1 }, { "datakit", 1 }, { "ccitt", 1 }, { "ibm_sna" , 1 }, { "decnet", 1 }, { "dec_dli", 1 }, { "lat", 1 }, { "hylink" , 1 }, { "appletalk", 1 }, { "route", 1 }, { "link", 1 }, { "xtp" , 1 }, { "coip", 1 }, { "cnt", 1 }, { "rtip", 1 }, { "ipx", 1 }, { "inet6", 1 }, { "pip", 1 }, { "isdn", 1 }, { "natm", 1 } , { "encap", 1 }, { "sip", 1 }, { "key", 1 }, { "bpf", 1 }, { "bluetooth", 1 }, { "mpls", 1 }, { "pflow", 1 }, { "pipex", 1 }, }; | |||
999 | static struct ctlname hwname[] = CTL_HW_NAMES{ { 0, 0 }, { "machine", 3 }, { "model", 3 }, { "ncpu", 2 }, { "byteorder", 2 }, { "gap", 0 }, { "gap", 0 }, { "pagesize", 2 }, { "disknames", 3 }, { "diskstats", 5 }, { "diskcount", 2 } , { "sensors", 1}, { "cpuspeed", 2 }, { "setperf", 2 }, { "vendor" , 3 }, { "product", 3 }, { "version", 3 }, { "serialno", 3 }, { "uuid", 3 }, { "physmem", 4 }, { "usermem", 4 }, { "ncpufound" , 2 }, { "allowpowerdown", 2 }, { "perfpolicy", 3 }, { "smt", 2 }, { "ncpuonline", 2 }, { "power", 2 }, }; | |||
1000 | static struct ctlname debugname[CTL_DEBUG_MAXID20]; | |||
1001 | static struct ctlname kernmallocname[] = CTL_KERN_MALLOC_NAMES{ { 0, 0 }, { "buckets", 3 }, { "bucket", 1 }, { "kmemnames", 3 }, { "kmemstat", 1 }, }; | |||
1002 | static struct ctlname forkstatname[] = CTL_KERN_FORKSTAT_NAMES{ { 0, 0 }, { "forks", 2 }, { "vforks", 2 }, { "tforks", 2 }, { "kthreads", 2 }, { "fork_pages", 2 }, { "vfork_pages", 2 } , { "tfork_pages", 2 }, { "kthread_pages", 2 }, }; | |||
1003 | static struct ctlname nchstatsname[] = CTL_KERN_NCHSTATS_NAMES{ { 0, 0 }, { "good_hits", 4 }, { "negative_hits", 4 }, { "bad_hits" , 4 }, { "false_hits", 4 }, { "misses", 4 }, { "long_names", 4 }, { "pass2", 4 }, { "2passes", 4 }, { "ncs_revhits", 4 }, { "ncs_revmiss", 4 }, { "ncs_dothits", 4 }, { "nch_dotdothits" , 4 }, }; | |||
1004 | static struct ctlname kernprocname[] = { | |||
1005 | { NULL((void*)0) }, | |||
1006 | { "all" }, | |||
1007 | { "pid" }, | |||
1008 | { "pgrp" }, | |||
1009 | { "session" }, | |||
1010 | { "tty" }, | |||
1011 | { "uid" }, | |||
1012 | { "ruid" }, | |||
1013 | { "kthread" }, | |||
1014 | }; | |||
1015 | static struct ctlname ttysname[] = CTL_KERN_TTY_NAMES{ { 0, 0 }, { "tk_nin", 4 }, { "tk_nout", 4 }, { "tk_rawcc", 4 }, { "tk_cancc", 4 }, { "ttyinfo", 5 }, { "gap", 0 }, { "gap" , 0 }, }; | |||
1016 | static struct ctlname semname[] = CTL_KERN_SEMINFO_NAMES{ { 0, 0 }, { "semmni", 2 }, { "semmns", 2 }, { "semmnu", 2 } , { "semmsl", 2 }, { "semopm", 2 }, { "semume", 2 }, { "semusz" , 2 }, { "semvmx", 2 }, { "semaem", 2 }, }; | |||
1017 | static struct ctlname shmname[] = CTL_KERN_SHMINFO_NAMES{ { 0, 0 }, { "shmmax", 2 }, { "shmmin", 2 }, { "shmmni", 2 } , { "shmseg", 2 }, { "shmall", 2 }, }; | |||
1018 | static struct ctlname watchdogname[] = CTL_KERN_WATCHDOG_NAMES{ { 0, 0 }, { "period", 2 }, { "auto", 2 }, }; | |||
1019 | static struct ctlname tcname[] = CTL_KERN_TIMECOUNTER_NAMES{ { 0, 0 }, { "tick", 2 }, { "timestepwarnings", 2 }, { "hardware" , 3 }, { "choice", 3 }, }; | |||
1020 | #ifdef CTL_MACHDEP_NAMES{ { 0, 0 }, { "console_device", 5 }, { "bios", 2 }, { "blk2chr" , 5 }, { "chr2blk", 5 }, { "allowaperture", 2 }, { "cpuvendor" , 3 }, { "cpuid", 2 }, { "cpufeature", 2 }, { 0, 0 }, { "kbdreset" , 2 }, { 0, 0 }, { "xcrypt", 2 }, { 0, 0 }, { "lidaction", 2 } , { "forceukbd", 2 }, { "tscfreq", 4 }, { "invarianttsc", 2 } , { "pwraction", 2 }, } | |||
1021 | static struct ctlname machdepname[] = CTL_MACHDEP_NAMES{ { 0, 0 }, { "console_device", 5 }, { "bios", 2 }, { "blk2chr" , 5 }, { "chr2blk", 5 }, { "allowaperture", 2 }, { "cpuvendor" , 3 }, { "cpuid", 2 }, { "cpufeature", 2 }, { 0, 0 }, { "kbdreset" , 2 }, { 0, 0 }, { "xcrypt", 2 }, { 0, 0 }, { "lidaction", 2 } , { "forceukbd", 2 }, { "tscfreq", 4 }, { "invarianttsc", 2 } , { "pwraction", 2 }, }; | |||
1022 | #endif | |||
1023 | static struct ctlname ddbname[] = CTL_DDB_NAMES{ { ((void*)0), 0 }, { "radix", 2 }, { "max_width", 2 }, { "max_line" , 2 }, { "tab_stop_width", 2 }, { "panic", 2 }, { "console", 2 }, { "log", 2 }, { "trigger", 2 }, { "profile", 2 }, }; | |||
1024 | ||||
1025 | #ifndef nitems | |||
1026 | #define nitems(_a)(sizeof((_a)) / sizeof((_a)[0])) (sizeof((_a)) / sizeof((_a)[0])) | |||
1027 | #endif | |||
1028 | ||||
1029 | #define SETNAME(name)do { names = (name); limit = (sizeof((name)) / sizeof((name)[ 0])); } while (0) do { names = (name); limit = nitems(name)(sizeof((name)) / sizeof((name)[0])); } while (0) | |||
1030 | ||||
1031 | static const char * | |||
1032 | kresolvsysctl(int depth, const int *top) | |||
1033 | { | |||
1034 | struct ctlname *names; | |||
1035 | size_t limit; | |||
1036 | int idx = top[depth]; | |||
1037 | ||||
1038 | names = NULL((void*)0); | |||
1039 | ||||
1040 | switch (depth) { | |||
1041 | case 0: | |||
1042 | SETNAME(topname)do { names = (topname); limit = (sizeof((topname)) / sizeof(( topname)[0])); } while (0); | |||
1043 | break; | |||
1044 | case 1: | |||
1045 | switch (top[0]) { | |||
1046 | case CTL_KERN1: | |||
1047 | SETNAME(kernname)do { names = (kernname); limit = (sizeof((kernname)) / sizeof ((kernname)[0])); } while (0); | |||
1048 | break; | |||
1049 | case CTL_VM2: | |||
1050 | SETNAME(vmname)do { names = (vmname); limit = (sizeof((vmname)) / sizeof((vmname )[0])); } while (0); | |||
1051 | break; | |||
1052 | case CTL_FS3: | |||
1053 | SETNAME(fsname)do { names = (fsname); limit = (sizeof((fsname)) / sizeof((fsname )[0])); } while (0); | |||
1054 | break; | |||
1055 | case CTL_NET4: | |||
1056 | SETNAME(netname)do { names = (netname); limit = (sizeof((netname)) / sizeof(( netname)[0])); } while (0); | |||
1057 | break; | |||
1058 | case CTL_DEBUG5: | |||
1059 | SETNAME(debugname)do { names = (debugname); limit = (sizeof((debugname)) / sizeof ((debugname)[0])); } while (0); | |||
1060 | break; | |||
1061 | case CTL_HW6: | |||
1062 | SETNAME(hwname)do { names = (hwname); limit = (sizeof((hwname)) / sizeof((hwname )[0])); } while (0); | |||
1063 | break; | |||
1064 | #ifdef CTL_MACHDEP_NAMES{ { 0, 0 }, { "console_device", 5 }, { "bios", 2 }, { "blk2chr" , 5 }, { "chr2blk", 5 }, { "allowaperture", 2 }, { "cpuvendor" , 3 }, { "cpuid", 2 }, { "cpufeature", 2 }, { 0, 0 }, { "kbdreset" , 2 }, { 0, 0 }, { "xcrypt", 2 }, { 0, 0 }, { "lidaction", 2 } , { "forceukbd", 2 }, { "tscfreq", 4 }, { "invarianttsc", 2 } , { "pwraction", 2 }, } | |||
1065 | case CTL_MACHDEP7: | |||
1066 | SETNAME(machdepname)do { names = (machdepname); limit = (sizeof((machdepname)) / sizeof ((machdepname)[0])); } while (0); | |||
1067 | break; | |||
1068 | #endif | |||
1069 | case CTL_DDB9: | |||
1070 | SETNAME(ddbname)do { names = (ddbname); limit = (sizeof((ddbname)) / sizeof(( ddbname)[0])); } while (0); | |||
1071 | break; | |||
1072 | } | |||
1073 | break; | |||
1074 | case 2: | |||
1075 | switch (top[0]) { | |||
1076 | case CTL_KERN1: | |||
1077 | switch (top[1]) { | |||
1078 | case KERN_MALLOCSTATS39: | |||
1079 | SETNAME(kernmallocname)do { names = (kernmallocname); limit = (sizeof((kernmallocname )) / sizeof((kernmallocname)[0])); } while (0); | |||
1080 | break; | |||
1081 | case KERN_FORKSTAT42: | |||
1082 | SETNAME(forkstatname)do { names = (forkstatname); limit = (sizeof((forkstatname)) / sizeof((forkstatname)[0])); } while (0); | |||
1083 | break; | |||
1084 | case KERN_NCHSTATS41: | |||
1085 | SETNAME(nchstatsname)do { names = (nchstatsname); limit = (sizeof((nchstatsname)) / sizeof((nchstatsname)[0])); } while (0); | |||
1086 | break; | |||
1087 | case KERN_TTY44: | |||
1088 | SETNAME(ttysname)do { names = (ttysname); limit = (sizeof((ttysname)) / sizeof ((ttysname)[0])); } while (0); | |||
1089 | break; | |||
1090 | case KERN_SEMINFO61: | |||
1091 | SETNAME(semname)do { names = (semname); limit = (sizeof((semname)) / sizeof(( semname)[0])); } while (0); | |||
1092 | break; | |||
1093 | case KERN_SHMINFO62: | |||
1094 | SETNAME(shmname)do { names = (shmname); limit = (sizeof((shmname)) / sizeof(( shmname)[0])); } while (0); | |||
1095 | break; | |||
1096 | case KERN_WATCHDOG64: | |||
1097 | SETNAME(watchdogname)do { names = (watchdogname); limit = (sizeof((watchdogname)) / sizeof((watchdogname)[0])); } while (0); | |||
1098 | break; | |||
1099 | case KERN_PROC66: | |||
1100 | idx++; /* zero is valid at this level */ | |||
1101 | SETNAME(kernprocname)do { names = (kernprocname); limit = (sizeof((kernprocname)) / sizeof((kernprocname)[0])); } while (0); | |||
1102 | break; | |||
1103 | case KERN_TIMECOUNTER69: | |||
1104 | SETNAME(tcname)do { names = (tcname); limit = (sizeof((tcname)) / sizeof((tcname )[0])); } while (0); | |||
1105 | break; | |||
1106 | } | |||
1107 | } | |||
1108 | break; | |||
1109 | } | |||
1110 | if (names != NULL((void*)0) && idx > 0 && idx < limit) | |||
1111 | return (names[idx].ctl_name); | |||
1112 | return (NULL((void*)0)); | |||
1113 | } | |||
1114 | ||||
1115 | static void | |||
1116 | ktrsysret(struct ktr_sysret *ktr, size_t ktrlen) | |||
1117 | { | |||
1118 | register_t ret = 0; | |||
1119 | long long retll; | |||
1120 | int error = ktr->ktr_error; | |||
| ||||
1121 | int code = ktr->ktr_code; | |||
1122 | ||||
1123 | if (ktrlen < sizeof(*ktr)) | |||
1124 | errx(1, "sysret length %zu < ktr header length %zu", | |||
1125 | ktrlen, sizeof(*ktr)); | |||
1126 | ktrlen -= sizeof(*ktr); | |||
1127 | if (error == 0) { | |||
1128 | if (ktrlen == sizeof(ret)) { | |||
1129 | memcpy(&ret, ktr+1, sizeof(ret)); | |||
1130 | retll = ret; | |||
1131 | } else if (ktrlen == sizeof(retll)) | |||
1132 | memcpy(&retll, ktr+1, sizeof(retll)); | |||
1133 | else | |||
1134 | errx(1, "sysret bogus length %zu", ktrlen); | |||
1135 | } | |||
1136 | ||||
1137 | if (code >= SYS_MAXSYSCALL331 || code < 0) | |||
1138 | (void)printf("[%d] ", code); | |||
1139 | else | |||
1140 | (void)printf("%s ", syscallnames[code]); | |||
1141 | ||||
1142 | doerr: | |||
1143 | if (error == 0) { | |||
1144 | if (fancy) { | |||
1145 | switch (code) { | |||
1146 | case SYS_lseek166: | |||
1147 | #ifdef SYS_pad_lseek199 | |||
1148 | case SYS_pad_lseek199: | |||
1149 | #endif | |||
1150 | (void)printf("%lld", retll); | |||
1151 | if (retll < 0 || retll > 9) | |||
1152 | (void)printf("/%#llx", retll); | |||
1153 | break; | |||
1154 | case SYS_sigprocmask48: | |||
1155 | case SYS_sigpending52: | |||
1156 | sigset(ret); | |||
1157 | break; | |||
1158 | case SYS___thrsigdivert303: | |||
1159 | signame(ret); | |||
1160 | break; | |||
1161 | case SYS_getuid24: | |||
1162 | case SYS_geteuid25: | |||
1163 | uidname(ret); | |||
1164 | break; | |||
1165 | case SYS_getgid47: | |||
1166 | case SYS_getegid43: | |||
1167 | gidname(ret); | |||
1168 | break; | |||
1169 | /* syscalls that return errno values */ | |||
1170 | case SYS_getlogin_r141: | |||
1171 | case SYS___thrsleep94: | |||
1172 | if ((error = ret) != 0) | |||
1173 | goto doerr; | |||
1174 | /* FALLTHROUGH */ | |||
1175 | default: | |||
1176 | (void)printf("%ld", (long)ret); | |||
1177 | if (ret < 0 || ret > 9) | |||
1178 | (void)printf("/%#lx", (long)ret); | |||
1179 | } | |||
1180 | } else { | |||
1181 | if (decimal) | |||
1182 | (void)printf("%lld", retll); | |||
1183 | else | |||
1184 | (void)printf("%#llx", retll); | |||
1185 | } | |||
1186 | } else if (error == ERESTART-1) | |||
1187 | (void)printf("RESTART"); | |||
1188 | else if (error == EJUSTRETURN-2) | |||
1189 | (void)printf("JUSTRETURN"); | |||
1190 | else { | |||
1191 | (void)printf("-1 errno %d", error); | |||
1192 | if (fancy) | |||
1193 | (void)printf(" %s", strerror(error)); | |||
1194 | } | |||
1195 | (void)putchar('\n')(!__isthreaded ? __sputc('\n', (&__sF[1])) : (putc)('\n', (&__sF[1]))); | |||
1196 | } | |||
1197 | ||||
1198 | static void | |||
1199 | ktrnamei(const char *cp, size_t len) | |||
1200 | { | |||
1201 | showbufc(basecol, (unsigned char *)cp, len, VIS_DQ0x200 | VIS_TAB0x08 | VIS_NL0x10); | |||
1202 | } | |||
1203 | ||||
1204 | void | |||
1205 | showbufc(int col, unsigned char *dp, size_t datalen, int flags) | |||
1206 | { | |||
1207 | int width; | |||
1208 | unsigned char visbuf[5], *cp; | |||
1209 | ||||
1210 | flags |= VIS_CSTYLE0x02; | |||
1211 | putchar('"')(!__isthreaded ? __sputc('"', (&__sF[1])) : (putc)('"', ( &__sF[1]))); | |||
1212 | col++; | |||
1213 | for (; datalen > 0; datalen--, dp++) { | |||
1214 | (void)vis(visbuf, *dp, flags, *(dp+1)); | |||
1215 | cp = visbuf; | |||
1216 | ||||
1217 | /* | |||
1218 | * Keep track of printables and | |||
1219 | * space chars (like fold(1)). | |||
1220 | */ | |||
1221 | if (col == 0) { | |||
1222 | (void)putchar('\t')(!__isthreaded ? __sputc('\t', (&__sF[1])) : (putc)('\t', (&__sF[1]))); | |||
1223 | col = 8; | |||
1224 | } | |||
1225 | switch (*cp) { | |||
1226 | case '\n': | |||
1227 | col = 0; | |||
1228 | (void)putchar('\n')(!__isthreaded ? __sputc('\n', (&__sF[1])) : (putc)('\n', (&__sF[1]))); | |||
1229 | continue; | |||
1230 | case '\t': | |||
1231 | width = 8 - (col&07); | |||
1232 | break; | |||
1233 | default: | |||
1234 | width = strlen(cp); | |||
1235 | } | |||
1236 | if (col + width > (screenwidth-2)) { | |||
1237 | (void)printf("\\\n\t"); | |||
1238 | col = 8; | |||
1239 | } | |||
1240 | col += width; | |||
1241 | do { | |||
1242 | (void)putchar(*cp++)(!__isthreaded ? __sputc(*cp++, (&__sF[1])) : (putc)(*cp++ , (&__sF[1]))); | |||
1243 | } while (*cp); | |||
1244 | } | |||
1245 | if (col == 0) | |||
1246 | (void)printf(" "); | |||
1247 | (void)printf("\"\n"); | |||
1248 | } | |||
1249 | ||||
1250 | static void | |||
1251 | showbuf(unsigned char *dp, size_t datalen) | |||
1252 | { | |||
1253 | int i, j; | |||
1254 | int col = 0, bpl; | |||
1255 | unsigned char c; | |||
1256 | ||||
1257 | if (iohex == 1) { | |||
1258 | putchar('\t')(!__isthreaded ? __sputc('\t', (&__sF[1])) : (putc)('\t', (&__sF[1]))); | |||
1259 | col = 8; | |||
1260 | for (i = 0; i < datalen; i++) { | |||
1261 | printf("%02x", dp[i]); | |||
1262 | col += 3; | |||
1263 | if (i < datalen - 1) { | |||
1264 | if (col + 3 > screenwidth) { | |||
1265 | printf("\n\t"); | |||
1266 | col = 8; | |||
1267 | } else | |||
1268 | putchar(' ')(!__isthreaded ? __sputc(' ', (&__sF[1])) : (putc)(' ', ( &__sF[1]))); | |||
1269 | } | |||
1270 | } | |||
1271 | putchar('\n')(!__isthreaded ? __sputc('\n', (&__sF[1])) : (putc)('\n', (&__sF[1]))); | |||
1272 | return; | |||
1273 | } | |||
1274 | if (iohex == 2) { | |||
1275 | bpl = (screenwidth - 13)/4; | |||
1276 | if (bpl <= 0) | |||
1277 | bpl = 1; | |||
1278 | for (i = 0; i < datalen; i += bpl) { | |||
1279 | printf(" %04x: ", i); | |||
1280 | for (j = 0; j < bpl; j++) { | |||
1281 | if (i+j >= datalen) | |||
1282 | printf(" "); | |||
1283 | else | |||
1284 | printf("%02x ", dp[i+j]); | |||
1285 | } | |||
1286 | putchar(' ')(!__isthreaded ? __sputc(' ', (&__sF[1])) : (putc)(' ', ( &__sF[1]))); | |||
1287 | for (j = 0; j < bpl; j++) { | |||
1288 | if (i+j >= datalen) | |||
1289 | break; | |||
1290 | c = dp[i+j]; | |||
1291 | if (!isprint(c)) | |||
1292 | c = '.'; | |||
1293 | putchar(c)(!__isthreaded ? __sputc(c, (&__sF[1])) : (putc)(c, (& __sF[1]))); | |||
1294 | } | |||
1295 | putchar('\n')(!__isthreaded ? __sputc('\n', (&__sF[1])) : (putc)('\n', (&__sF[1]))); | |||
1296 | } | |||
1297 | return; | |||
1298 | } | |||
1299 | ||||
1300 | (void)printf(" "); | |||
1301 | showbufc(7, dp, datalen, 0); | |||
1302 | } | |||
1303 | ||||
1304 | static void | |||
1305 | ktrgenio(struct ktr_genio *ktr, size_t len) | |||
1306 | { | |||
1307 | unsigned char *dp = (unsigned char *)ktr + sizeof(struct ktr_genio); | |||
1308 | size_t datalen; | |||
1309 | ||||
1310 | if (len < sizeof(struct ktr_genio)) | |||
1311 | errx(1, "invalid ktr genio length %zu", len); | |||
1312 | ||||
1313 | datalen = len - sizeof(struct ktr_genio); | |||
1314 | ||||
1315 | printf("fd %d %s %zu bytes\n", ktr->ktr_fd, | |||
1316 | ktr->ktr_rw == UIO_READ ? "read" : "wrote", datalen); | |||
1317 | if (maxdata == 0) | |||
1318 | return; | |||
1319 | if (datalen > maxdata) | |||
1320 | datalen = maxdata; | |||
1321 | if (iohex && !datalen) | |||
1322 | return; | |||
1323 | showbuf(dp, datalen); | |||
1324 | } | |||
1325 | ||||
1326 | static void | |||
1327 | ktrpsig(struct ktr_psig *psig) | |||
1328 | { | |||
1329 | signame(psig->signo); | |||
1330 | printf(" "); | |||
1331 | if (psig->action == SIG_DFL(void (*)(int))0) | |||
1332 | (void)printf("SIG_DFL"); | |||
1333 | else { | |||
1334 | (void)printf("caught handler=0x%lx mask=", | |||
1335 | (u_long)psig->action); | |||
1336 | sigset(psig->mask); | |||
1337 | } | |||
1338 | if (psig->code) { | |||
1339 | printf(" code "); | |||
1340 | if (fancy) { | |||
1341 | switch (psig->signo) { | |||
1342 | case SIGILL4: | |||
1343 | sigill_name(psig->code); | |||
1344 | break; | |||
1345 | case SIGTRAP5: | |||
1346 | sigtrap_name(psig->code); | |||
1347 | break; | |||
1348 | case SIGEMT7: | |||
1349 | sigemt_name(psig->code); | |||
1350 | break; | |||
1351 | case SIGFPE8: | |||
1352 | sigfpe_name(psig->code); | |||
1353 | break; | |||
1354 | case SIGBUS10: | |||
1355 | sigbus_name(psig->code); | |||
1356 | break; | |||
1357 | case SIGSEGV11: | |||
1358 | sigsegv_name(psig->code); | |||
1359 | break; | |||
1360 | case SIGCHLD20: | |||
1361 | sigchld_name(psig->code); | |||
1362 | break; | |||
1363 | } | |||
1364 | } | |||
1365 | printf("<%d>", psig->code); | |||
1366 | } | |||
1367 | ||||
1368 | switch (psig->signo) { | |||
1369 | case SIGSEGV11: | |||
1370 | case SIGILL4: | |||
1371 | case SIGBUS10: | |||
1372 | case SIGFPE8: | |||
1373 | printf(" addr=%p trapno=%d", psig->si.si_addr_data._fault._addr, | |||
1374 | psig->si.si_trapno_data._fault._trapno); | |||
1375 | break; | |||
1376 | default: | |||
1377 | break; | |||
1378 | } | |||
1379 | printf("\n"); | |||
1380 | } | |||
1381 | ||||
1382 | static void | |||
1383 | ktruser(struct ktr_user *usr, size_t len) | |||
1384 | { | |||
1385 | if (len < sizeof(struct ktr_user)) | |||
1386 | errx(1, "invalid ktr user length %zu", len); | |||
1387 | len -= sizeof(struct ktr_user); | |||
1388 | printf("%.*s:", KTR_USER_MAXIDLEN20, usr->ktr_id); | |||
1389 | printf(" %zu bytes\n", len); | |||
1390 | showbuf((unsigned char *)(usr + 1), len); | |||
1391 | } | |||
1392 | ||||
1393 | static void | |||
1394 | ktrexec(const char *ptr, size_t len) | |||
1395 | { | |||
1396 | int i, col; | |||
1397 | size_t l; | |||
1398 | ||||
1399 | putchar('\n')(!__isthreaded ? __sputc('\n', (&__sF[1])) : (putc)('\n', (&__sF[1]))); | |||
1400 | i = 0; | |||
1401 | while (len > 0) { | |||
1402 | l = strnlen(ptr, len); | |||
1403 | col = printf("\t[%d] = ", i++); | |||
1404 | col += 7; /* tab expands from 1 to 8 columns */ | |||
1405 | showbufc(col, (unsigned char *)ptr, l, VIS_DQ0x200|VIS_TAB0x08|VIS_NL0x10); | |||
1406 | if (l == len) { | |||
1407 | printf("\tunterminated argument\n"); | |||
1408 | break; | |||
1409 | } | |||
1410 | len -= l + 1; | |||
1411 | ptr += l + 1; | |||
1412 | } | |||
1413 | } | |||
1414 | ||||
1415 | static void | |||
1416 | ktrpledge(struct ktr_pledge *pledge, size_t len) | |||
1417 | { | |||
1418 | const char *name = ""; | |||
1419 | int i; | |||
1420 | ||||
1421 | if (len < sizeof(struct ktr_pledge)) | |||
1422 | errx(1, "invalid ktr pledge length %zu", len); | |||
1423 | ||||
1424 | if (pledge->syscall >= SYS_MAXSYSCALL331 || pledge->syscall < 0) | |||
1425 | (void)printf("[%d]", pledge->syscall); | |||
1426 | else | |||
1427 | (void)printf("%s", syscallnames[pledge->syscall]); | |||
1428 | printf(", "); | |||
1429 | for (i = 0; pledge->code && pledgenames[i].bits != 0; i++) { | |||
1430 | if (pledgenames[i].bits & pledge->code) { | |||
1431 | name = pledgenames[i].name; | |||
1432 | break; | |||
1433 | } | |||
1434 | } | |||
1435 | printf("\"%s\"", name); | |||
1436 | (void)printf(", errno %d", pledge->error); | |||
1437 | if (fancy) | |||
1438 | (void)printf(" %s", strerror(pledge->error)); | |||
1439 | printf("\n"); | |||
1440 | } | |||
1441 | ||||
1442 | static void | |||
1443 | usage(void) | |||
1444 | { | |||
1445 | ||||
1446 | extern char *__progname; | |||
1447 | fprintf(stderr(&__sF[2]), "usage: %s " | |||
1448 | "[-dHlnRTXx] [-f file] [-m maxdata] [-p pid] [-t trstr]\n", | |||
1449 | __progname); | |||
1450 | exit(1); | |||
1451 | } | |||
1452 | ||||
1453 | ||||
1454 | /* | |||
1455 | * FORMATTERS | |||
1456 | */ | |||
1457 | ||||
1458 | static void | |||
1459 | ioctldecode(int cmd) | |||
1460 | { | |||
1461 | char dirbuf[4], *dir = dirbuf; | |||
1462 | const char *cp; | |||
1463 | ||||
1464 | if ((cp = ioctlname((unsigned)cmd)) != NULL((void*)0)) { | |||
1465 | (void)printf("%s", cp); | |||
1466 | return; | |||
1467 | } | |||
1468 | ||||
1469 | if (cmd & IOC_IN(unsigned long)0x80000000) | |||
1470 | *dir++ = 'W'; | |||
1471 | if (cmd & IOC_OUT(unsigned long)0x40000000) | |||
1472 | *dir++ = 'R'; | |||
1473 | *dir = '\0'; | |||
1474 | ||||
1475 | printf("_IO%s('%c',%d", | |||
1476 | dirbuf, (int)((cmd >> 8) & 0xff), cmd & 0xff); | |||
1477 | if ((cmd & IOC_VOID(unsigned long)0x20000000) == 0) | |||
1478 | printf(decimal ? ",%u)" : ",%#x)", (cmd >> 16) & 0xff); | |||
1479 | else | |||
1480 | printf(")"); | |||
1481 | } | |||
1482 | ||||
1483 | static void | |||
1484 | ptracedecode(int request) | |||
1485 | { | |||
1486 | if (request >= 0 && request < nitems(ptrace_ops)(sizeof((ptrace_ops)) / sizeof((ptrace_ops)[0]))) | |||
1487 | (void)printf("%s", ptrace_ops[request]); | |||
1488 | else switch(request) { | |||
1489 | #ifdef PT_GETFPREGS(32 + 3) | |||
1490 | case PT_GETFPREGS(32 + 3): | |||
1491 | (void)printf("PT_GETFPREGS"); | |||
1492 | break; | |||
1493 | #endif | |||
1494 | case PT_GETREGS(32 + 1): | |||
1495 | (void)printf("PT_GETREGS"); | |||
1496 | break; | |||
1497 | #ifdef PT_GETXMMREGS | |||
1498 | case PT_GETXMMREGS: | |||
1499 | (void)printf("PT_GETXMMREGS"); | |||
1500 | break; | |||
1501 | #endif | |||
1502 | #ifdef PT_SETFPREGS(32 + 4) | |||
1503 | case PT_SETFPREGS(32 + 4): | |||
1504 | (void)printf("PT_SETFPREGS"); | |||
1505 | break; | |||
1506 | #endif | |||
1507 | case PT_SETREGS(32 + 2): | |||
1508 | (void)printf("PT_SETREGS"); | |||
1509 | break; | |||
1510 | #ifdef PT_SETXMMREGS | |||
1511 | case PT_SETXMMREGS: | |||
1512 | (void)printf("PT_SETXMMREGS"); | |||
1513 | break; | |||
1514 | #endif | |||
1515 | #ifdef PT_STEP(32 + 0) | |||
1516 | case PT_STEP(32 + 0): | |||
1517 | (void)printf("PT_STEP"); | |||
1518 | break; | |||
1519 | #endif | |||
1520 | #ifdef PT_WCOOKIE | |||
1521 | case PT_WCOOKIE: | |||
1522 | (void)printf("PT_WCOOKIE"); | |||
1523 | break; | |||
1524 | #endif | |||
1525 | default: | |||
1526 | pdecint(request); | |||
1527 | } | |||
1528 | } | |||
1529 | ||||
1530 | ||||
1531 | static void | |||
1532 | atfd(int fd) | |||
1533 | { | |||
1534 | if (fd == AT_FDCWD-100) | |||
1535 | (void)printf("AT_FDCWD"); | |||
1536 | else | |||
1537 | pdecint(fd); | |||
1538 | } | |||
1539 | ||||
1540 | static void | |||
1541 | polltimeout(int timeout) | |||
1542 | { | |||
1543 | if (timeout == INFTIM(-1)) | |||
1544 | (void)printf("INFTIM"); | |||
1545 | else | |||
1546 | pdecint(timeout); | |||
1547 | } | |||
1548 | ||||
1549 | static void | |||
1550 | wait4pid(int pid) | |||
1551 | { | |||
1552 | if (pid == WAIT_ANY(-1)) | |||
1553 | (void)printf("WAIT_ANY"); | |||
1554 | else if (pid == WAIT_MYPGRP0) | |||
1555 | (void)printf("WAIT_MYPGRP"); | |||
1556 | else | |||
1557 | pdecint(pid); /* ppgid */ | |||
1558 | } | |||
1559 | ||||
1560 | static void | |||
1561 | signame(int sig) | |||
1562 | { | |||
1563 | if (sig > 0 && sig < NSIG33) | |||
1564 | (void)printf("SIG%s", sys_signame[sig]); | |||
1565 | else | |||
1566 | (void)printf("SIG %d", sig); | |||
1567 | } | |||
1568 | ||||
1569 | void | |||
1570 | sigset(int ss) | |||
1571 | { | |||
1572 | int or = 0; | |||
1573 | int cnt = 0; | |||
1574 | int i; | |||
1575 | ||||
1576 | for (i = 1; i < NSIG33; i++) | |||
1577 | if (sigismember(&ss, i)) | |||
1578 | cnt++; | |||
1579 | if (cnt > (NSIG33-1)/2) { | |||
1580 | ss = ~ss; | |||
1581 | putchar('~')(!__isthreaded ? __sputc('~', (&__sF[1])) : (putc)('~', ( &__sF[1]))); | |||
1582 | } | |||
1583 | ||||
1584 | if (ss == 0) { | |||
1585 | (void)printf("0<>"); | |||
1586 | return; | |||
1587 | } | |||
1588 | ||||
1589 | printf("%#x<", ss); | |||
1590 | for (i = 1; i < NSIG33; i++) | |||
1591 | if (sigismember(&ss, i)) { | |||
1592 | if (or) putchar('|')(!__isthreaded ? __sputc('|', (&__sF[1])) : (putc)('|', ( &__sF[1]))); else or=1; | |||
1593 | signame(i); | |||
1594 | } | |||
1595 | printf(">"); | |||
1596 | } | |||
1597 | ||||
1598 | static void | |||
1599 | semctlname(int cmd) | |||
1600 | { | |||
1601 | switch (cmd) { | |||
1602 | case GETNCNT3: | |||
1603 | (void)printf("GETNCNT"); | |||
1604 | break; | |||
1605 | case GETPID4: | |||
1606 | (void)printf("GETPID"); | |||
1607 | break; | |||
1608 | case GETVAL5: | |||
1609 | (void)printf("GETVAL"); | |||
1610 | break; | |||
1611 | case GETALL6: | |||
1612 | (void)printf("GETALL"); | |||
1613 | break; | |||
1614 | case GETZCNT7: | |||
1615 | (void)printf("GETZCNT"); | |||
1616 | break; | |||
1617 | case SETVAL8: | |||
1618 | (void)printf("SETVAL"); | |||
1619 | break; | |||
1620 | case SETALL9: | |||
1621 | (void)printf("SETALL"); | |||
1622 | break; | |||
1623 | case IPC_RMID0: | |||
1624 | (void)printf("IPC_RMID"); | |||
1625 | break; | |||
1626 | case IPC_SET1: | |||
1627 | (void)printf("IPC_SET"); | |||
1628 | break; | |||
1629 | case IPC_STAT2: | |||
1630 | (void)printf("IPC_STAT"); | |||
1631 | break; | |||
1632 | default: /* Should not reach */ | |||
1633 | (void)printf("<invalid=%d>", cmd); | |||
1634 | } | |||
1635 | } | |||
1636 | ||||
1637 | static void | |||
1638 | shmctlname(int cmd) | |||
1639 | { | |||
1640 | switch (cmd) { | |||
1641 | case IPC_RMID0: | |||
1642 | (void)printf("IPC_RMID"); | |||
1643 | break; | |||
1644 | case IPC_SET1: | |||
1645 | (void)printf("IPC_SET"); | |||
1646 | break; | |||
1647 | case IPC_STAT2: | |||
1648 | (void)printf("IPC_STAT"); | |||
1649 | break; | |||
1650 | default: /* Should not reach */ | |||
1651 | (void)printf("<invalid=%d>", cmd); | |||
1652 | } | |||
1653 | } | |||
1654 | ||||
1655 | ||||
1656 | static void | |||
1657 | semgetname(int flag) | |||
1658 | { | |||
1659 | int or = 0; | |||
1660 | if_print_or(flag, IPC_CREAT, or)do { if ((flag & 001000) == 001000) do { if (or) (!__isthreaded ? __sputc('|', (&__sF[1])) : (putc)('|', (&__sF[1])) ); else or = 1; printf ("%s", "IPC_CREAT"); } while (0); } while (0); | |||
1661 | if_print_or(flag, IPC_EXCL, or)do { if ((flag & 002000) == 002000) do { if (or) (!__isthreaded ? __sputc('|', (&__sF[1])) : (putc)('|', (&__sF[1])) ); else or = 1; printf ("%s", "IPC_EXCL"); } while (0); } while (0); | |||
1662 | if_print_or(flag, SEM_R, or)do { if ((flag & 0400) == 0400) do { if (or) (!__isthreaded ? __sputc('|', (&__sF[1])) : (putc)('|', (&__sF[1])) ); else or = 1; printf ("%s", "SEM_R"); } while (0); } while ( 0); | |||
1663 | if_print_or(flag, SEM_A, or)do { if ((flag & 0200) == 0200) do { if (or) (!__isthreaded ? __sputc('|', (&__sF[1])) : (putc)('|', (&__sF[1])) ); else or = 1; printf ("%s", "SEM_A"); } while (0); } while ( 0); | |||
1664 | if_print_or(flag, (SEM_R>>3), or)do { if ((flag & (0400>>3)) == (0400>>3)) do { if (or) (!__isthreaded ? __sputc('|', (&__sF[1])) : (putc )('|', (&__sF[1]))); else or = 1; printf ("%s", "(SEM_R>>3)" ); } while (0); } while (0); | |||
1665 | if_print_or(flag, (SEM_A>>3), or)do { if ((flag & (0200>>3)) == (0200>>3)) do { if (or) (!__isthreaded ? __sputc('|', (&__sF[1])) : (putc )('|', (&__sF[1]))); else or = 1; printf ("%s", "(SEM_A>>3)" ); } while (0); } while (0); | |||
1666 | if_print_or(flag, (SEM_R>>6), or)do { if ((flag & (0400>>6)) == (0400>>6)) do { if (or) (!__isthreaded ? __sputc('|', (&__sF[1])) : (putc )('|', (&__sF[1]))); else or = 1; printf ("%s", "(SEM_R>>6)" ); } while (0); } while (0); | |||
1667 | if_print_or(flag, (SEM_A>>6), or)do { if ((flag & (0200>>6)) == (0200>>6)) do { if (or) (!__isthreaded ? __sputc('|', (&__sF[1])) : (putc )('|', (&__sF[1]))); else or = 1; printf ("%s", "(SEM_A>>6)" ); } while (0); } while (0); | |||
1668 | ||||
1669 | if (flag & ~(IPC_CREAT001000|IPC_EXCL002000|SEM_R0400|SEM_A0200|((SEM_R0400|SEM_A0200)>>3)| | |||
1670 | ((SEM_R0400|SEM_A0200)>>6))) | |||
1671 | printf("<invalid=%#x>", flag); | |||
1672 | } | |||
1673 | ||||
1674 | ||||
1675 | /* | |||
1676 | * Only used by SYS_open and SYS_openat. Unless O_CREAT is set in flags, the | |||
1677 | * mode argument is unused (and often bogus and misleading). | |||
1678 | */ | |||
1679 | static void | |||
1680 | flagsandmodename(int mode) | |||
1681 | { | |||
1682 | openflagsname(arg1); | |||
1683 | if ((arg1 & O_CREAT0x0200) == O_CREAT0x0200) { | |||
1684 | (void)putchar(',')(!__isthreaded ? __sputc(',', (&__sF[1])) : (putc)(',', ( &__sF[1]))); | |||
1685 | modename(mode); | |||
1686 | } else if (!fancy) | |||
1687 | (void)printf(",<unused>%#o", mode); | |||
1688 | } | |||
1689 | ||||
1690 | static void | |||
1691 | clockname(int clockid) | |||
1692 | { | |||
1693 | clocktypename(__CLOCK_TYPE(clockid)((clockid) & 0xfff)); | |||
1694 | if (__CLOCK_PTID(clockid)(((clockid) >> 12) & 0xfffff) != 0) | |||
1695 | printf("(%d)", __CLOCK_PTID(clockid)(((clockid) >> 12) & 0xfffff)); | |||
1696 | } | |||
1697 | ||||
1698 | /* | |||
1699 | * [g|s]etsockopt's level argument can either be SOL_SOCKET or a value | |||
1700 | * referring to a line in /etc/protocols. | |||
1701 | */ | |||
1702 | static void | |||
1703 | sockoptlevelname(int optname) | |||
1704 | { | |||
1705 | struct protoent *pe; | |||
1706 | ||||
1707 | if (arg1 == SOL_SOCKET0xffff) { | |||
1708 | (void)printf("SOL_SOCKET,"); | |||
1709 | sockoptname(optname); | |||
1710 | } else { | |||
1711 | pe = getprotobynumber(arg1); | |||
1712 | (void)printf("%u<%s>,%d", arg1, | |||
1713 | pe != NULL((void*)0) ? pe->p_name : "unknown", optname); | |||
1714 | } | |||
1715 | } | |||
1716 | ||||
1717 | static void | |||
1718 | ktraceopname(int ops) | |||
1719 | { | |||
1720 | int invalid = 0; | |||
1721 | ||||
1722 | printf("%#x<", ops); | |||
1723 | switch (KTROP(ops)((ops)&3)) { | |||
1724 | case KTROP_SET0: | |||
1725 | printf("KTROP_SET"); | |||
1726 | break; | |||
1727 | case KTROP_CLEAR1: | |||
1728 | printf("KTROP_CLEAR"); | |||
1729 | break; | |||
1730 | case KTROP_CLEARFILE2: | |||
1731 | printf("KTROP_CLEARFILE"); | |||
1732 | break; | |||
1733 | default: | |||
1734 | printf("KTROP(%d)", KTROP(ops)((ops)&3)); | |||
1735 | invalid = 1; | |||
1736 | break; | |||
1737 | } | |||
1738 | if (ops & KTRFLAG_DESCEND4) printf("|KTRFLAG_DESCEND"); | |||
1739 | printf(">"); | |||
1740 | if (invalid || (ops & ~(KTROP((unsigned)-1)(((unsigned)-1)&3) | KTRFLAG_DESCEND4))) | |||
1741 | (void)printf("<invalid>%d", ops); | |||
1742 | } |