GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usr.bin/kdump/kdump_subr.c Lines: 119 979 12.2 %
Date: 2016-12-06 Branches: 132 1739 7.6 %

Line Branch Exec Source
1
#include <stdio.h>
2
#include <sys/param.h>
3
#include <sys/event.h>
4
#include <sys/fcntl.h>
5
#include <sys/stat.h>
6
#include <sys/unistd.h>
7
#define _KERNEL
8
#include <sys/mman.h>
9
#undef _KERNEL
10
#include <sys/wait.h>
11
#include <sys/proc.h>
12
#include <sys/socket.h>
13
#include <netinet/in.h>
14
#include <sys/param.h>
15
#include <sys/mount.h>
16
#include <sys/poll.h>
17
#include <sys/ptrace.h>
18
#include <sys/resource.h>
19
#include <sys/reboot.h>
20
#include <sys/uio.h>
21
#include <sys/ktrace.h>
22
#include <sched.h>
23
#if 0
24
#include <sys/linker.h>
25
#define _KERNEL
26
#include <sys/thr.h>
27
#undef _KERNEL
28
#include <sys/extattr.h>
29
#include <sys/acl.h>
30
#include <aio.h>
31
#endif
32
#include <sys/sem.h>
33
#include <sys/ipc.h>
34
#if 0
35
#include <sys/rtprio.h>
36
#endif
37
#include <sys/shm.h>
38
#if 0
39
#include <nfsserver/nfs.h>
40
#endif
41
#include <ufs/ufs/quota.h>
42
#include <sys/syslog.h>
43
44
#include "kdump_subr.h"
45
46
/* AUTO */
47
void
48
modename (int arg)
49
66
{
50
66
	int	or = 0;
51
66
	if (arg == 0) {
52
		printf("0<>");
53
		return;
54
	}
55
66
	printf("%#o<", arg);
56
66
	if(!((arg>0)^((S_ISUID)>0)))
57

66
		if_print_or(arg, S_ISUID, or);
58
66
	if(!((arg>0)^((S_ISGID)>0)))
59

66
		if_print_or(arg, S_ISGID, or);
60
66
	if(!((arg>0)^((S_ISTXT)>0)))
61

66
		if_print_or(arg, S_ISTXT, or);
62
66
	if(!((arg>0)^((S_IRUSR)>0)))
63

66
		if_print_or(arg, S_IRUSR, or);
64
66
	if(!((arg>0)^((S_IWUSR)>0)))
65

66
		if_print_or(arg, S_IWUSR, or);
66
66
	if(!((arg>0)^((S_IXUSR)>0)))
67

66
		if_print_or(arg, S_IXUSR, or);
68
66
	if(!((arg>0)^((S_IRGRP)>0)))
69

66
		if_print_or(arg, S_IRGRP, or);
70
66
	if(!((arg>0)^((S_IWGRP)>0)))
71

66
		if_print_or(arg, S_IWGRP, or);
72
66
	if(!((arg>0)^((S_IXGRP)>0)))
73

66
		if_print_or(arg, S_IXGRP, or);
74
66
	if(!((arg>0)^((S_IROTH)>0)))
75

66
		if_print_or(arg, S_IROTH, or);
76
66
	if(!((arg>0)^((S_IWOTH)>0)))
77

66
		if_print_or(arg, S_IWOTH, or);
78
66
	if(!((arg>0)^((S_IXOTH)>0)))
79

66
		if_print_or(arg, S_IXOTH, or);
80
66
	if(!((arg>0)^((S_IFIFO)>0)))
81

66
		if_print_or(arg, S_IFIFO, or);
82
66
	if(!((arg>0)^((S_IFCHR)>0)))
83

66
		if_print_or(arg, S_IFCHR, or);
84
66
	if(!((arg>0)^((S_IFDIR)>0)))
85

66
		if_print_or(arg, S_IFDIR, or);
86
66
	if(!((arg>0)^((S_IFBLK)>0)))
87

66
		if_print_or(arg, S_IFBLK, or);
88
66
	if(!((arg>0)^((S_IFREG)>0)))
89

66
		if_print_or(arg, S_IFREG, or);
90
66
	if(!((arg>0)^((S_IFLNK)>0)))
91

66
		if_print_or(arg, S_IFLNK, or);
92
66
	if(!((arg>0)^((S_IFSOCK)>0)))
93

66
		if_print_or(arg, S_IFSOCK, or);
94
66
	if(!((arg>0)^((S_ISVTX)>0)))
95

66
		if_print_or(arg, S_ISVTX, or);
96
66
	printf(">");
97
66
	if (or == 0)
98
		(void)printf("<invalid>%d", arg);
99
}
100
101
/* AUTO */
102
void
103
doflagsname (int arg, int show_accmode)
104
70
{
105
70
	int	or = 0;
106
107
70
	printf("%#x<", arg);
108

70
	if (show_accmode || (arg & O_ACCMODE)) {
109
70
		or = 1;
110

70
		switch (arg & O_ACCMODE) {
111
		case O_RDONLY:
112
2
			printf("O_RDONLY");
113
2
			break;
114
		case O_WRONLY:
115
			printf("O_WRONLY");
116
			break;
117
		case O_RDWR:
118
68
			printf("O_RDWR");
119
68
			break;
120
		default:
121
			printf("<invalid>O_ACCMODE");
122
			break;
123
		}
124
	}
125

70
	if_print_or(arg, O_NONBLOCK, or);
126

70
	if_print_or(arg, O_APPEND, or);
127

70
	if_print_or(arg, O_SHLOCK, or);
128

70
	if_print_or(arg, O_EXLOCK, or);
129

70
	if_print_or(arg, O_ASYNC, or);
130

70
	if_print_or(arg, O_FSYNC, or);
131

70
	if_print_or(arg, O_NOFOLLOW, or);
132

70
	if_print_or(arg, O_SYNC, or);
133

70
	if_print_or(arg, O_CREAT, or);
134

70
	if_print_or(arg, O_TRUNC, or);
135

70
	if_print_or(arg, O_EXCL, or);
136

70
	if_print_or(arg, O_NOCTTY, or);
137

70
	if_print_or(arg, O_CLOEXEC, or);
138

70
	if_print_or(arg, O_DIRECTORY, or);
139
70
	printf(">");
140
70
}
141
142
/*
143
 * Wrappers of the above to use with pn()
144
 */
145
void
146
flagsname(int flags)
147
{
148
	doflagsname(flags, 0);
149
}
150
151
void
152
openflagsname(int flags)
153
70
{
154
70
	doflagsname(flags, 1);
155
70
}
156
157
158
/* AUTO */
159
void
160
atflagsname (int arg)
161
{
162
	int	or = 0;
163
	if (arg == 0) {
164
		printf("0<>");
165
		return;
166
	}
167
	printf("%#x<", arg);
168
	if(!((arg>0)^((AT_EACCESS)>0)))
169
		if_print_or(arg, AT_EACCESS, or);
170
	if(!((arg>0)^((AT_SYMLINK_NOFOLLOW)>0)))
171
		if_print_or(arg, AT_SYMLINK_NOFOLLOW, or);
172
	if(!((arg>0)^((AT_SYMLINK_FOLLOW)>0)))
173
		if_print_or(arg, AT_SYMLINK_FOLLOW, or);
174
	if(!((arg>0)^((AT_REMOVEDIR)>0)))
175
		if_print_or(arg, AT_REMOVEDIR, or);
176
	printf(">");
177
	if (or == 0)
178
		(void)printf("<invalid>%d", arg);
179
}
180
181
/* AUTO */
182
void
183
accessmodename (int arg)
184
{
185
	int	or = 0;
186
	printf("%#x<", arg);
187
	if(!((arg>0)^((F_OK)>0)))
188
		if_print_or(arg, F_OK, or);
189
	if(!((arg>0)^((X_OK)>0)))
190
		if_print_or(arg, X_OK, or);
191
	if(!((arg>0)^((W_OK)>0)))
192
		if_print_or(arg, W_OK, or);
193
	if(!((arg>0)^((R_OK)>0)))
194
		if_print_or(arg, R_OK, or);
195
	printf(">");
196
	if (or == 0)
197
		(void)printf("<invalid>%d", arg);
198
}
199
200
/* AUTO */
201
void
202
mmapprotname (int arg)
203
49
{
204
49
	int	or = 0;
205
49
	printf("%#x<", arg);
206
49
	if(!((arg>0)^((PROT_NONE)>0)))
207

5
		if_print_or(arg, PROT_NONE, or);
208
49
	if(!((arg>0)^((PROT_READ)>0)))
209

44
		if_print_or(arg, PROT_READ, or);
210
49
	if(!((arg>0)^((PROT_WRITE)>0)))
211

44
		if_print_or(arg, PROT_WRITE, or);
212
49
	if(!((arg>0)^((PROT_EXEC)>0)))
213

44
		if_print_or(arg, PROT_EXEC, or);
214
49
	printf(">");
215
49
	if (or == 0)
216
		(void)printf("<invalid>%d", arg);
217
49
}
218
219
/* AUTO */
220
void
221
mmapflagsname (int arg)
222
32
{
223
32
	int	or = 0;
224
32
	printf("%#x<", arg);
225
32
	if(!((arg>0)^((MAP_SHARED)>0)))
226

32
		if_print_or(arg, MAP_SHARED, or);
227
32
	if(!((arg>0)^((MAP_PRIVATE)>0)))
228

32
		if_print_or(arg, MAP_PRIVATE, or);
229
32
	if(!((arg>0)^((MAP_FIXED)>0)))
230

32
		if_print_or(arg, MAP_FIXED, or);
231
32
	if(!((arg>0)^((__MAP_NOREPLACE)>0)))
232

32
		if_print_or(arg, __MAP_NOREPLACE, or);
233
32
	if(!((arg>0)^((MAP_ANON)>0)))
234

32
		if_print_or(arg, MAP_ANON, or);
235
32
	if(!((arg>0)^((__MAP_NOFAULT)>0)))
236

32
		if_print_or(arg, __MAP_NOFAULT, or);
237
32
	if(!((arg>0)^((MAP_FLAGMASK)>0)))
238

32
		if_print_or(arg, MAP_FLAGMASK, or);
239
32
	printf(">");
240
32
	if (or == 0)
241
		(void)printf("<invalid>%d", arg);
242
32
}
243
244
/* AUTO */
245
void
246
wait4optname (int arg)
247
{
248
	int	or = 0;
249
	if (arg == 0) {
250
		printf("0<>");
251
		return;
252
	}
253
	printf("%#x<", arg);
254
	if(!((arg>0)^((WCOREFLAG)>0)))
255
		if_print_or(arg, WCOREFLAG, or);
256
	if(!((arg>0)^((WNOHANG)>0)))
257
		if_print_or(arg, WNOHANG, or);
258
	if(!((arg>0)^((WUNTRACED)>0)))
259
		if_print_or(arg, WUNTRACED, or);
260
	if(!((arg>0)^((WCONTINUED)>0)))
261
		if_print_or(arg, WCONTINUED, or);
262
	printf(">");
263
	if (or == 0)
264
		(void)printf("<invalid>%d", arg);
265
}
266
267
/* AUTO */
268
void
269
mountflagsname (int arg)
270
{
271
	int	or = 0;
272
	printf("%#x<", arg);
273
	if(!((arg>0)^((MNT_RDONLY)>0)))
274
		if_print_or(arg, MNT_RDONLY, or);
275
	if(!((arg>0)^((MNT_SYNCHRONOUS)>0)))
276
		if_print_or(arg, MNT_SYNCHRONOUS, or);
277
	if(!((arg>0)^((MNT_NOEXEC)>0)))
278
		if_print_or(arg, MNT_NOEXEC, or);
279
	if(!((arg>0)^((MNT_NOSUID)>0)))
280
		if_print_or(arg, MNT_NOSUID, or);
281
	if(!((arg>0)^((MNT_NODEV)>0)))
282
		if_print_or(arg, MNT_NODEV, or);
283
	if(!((arg>0)^((MNT_ASYNC)>0)))
284
		if_print_or(arg, MNT_ASYNC, or);
285
	if(!((arg>0)^((MNT_WXALLOWED)>0)))
286
		if_print_or(arg, MNT_WXALLOWED, or);
287
	if(!((arg>0)^((MNT_EXRDONLY)>0)))
288
		if_print_or(arg, MNT_EXRDONLY, or);
289
	if(!((arg>0)^((MNT_EXPORTED)>0)))
290
		if_print_or(arg, MNT_EXPORTED, or);
291
	if(!((arg>0)^((MNT_DEFEXPORTED)>0)))
292
		if_print_or(arg, MNT_DEFEXPORTED, or);
293
	if(!((arg>0)^((MNT_EXPORTANON)>0)))
294
		if_print_or(arg, MNT_EXPORTANON, or);
295
	if(!((arg>0)^((MNT_LOCAL)>0)))
296
		if_print_or(arg, MNT_LOCAL, or);
297
	if(!((arg>0)^((MNT_QUOTA)>0)))
298
		if_print_or(arg, MNT_QUOTA, or);
299
	if(!((arg>0)^((MNT_ROOTFS)>0)))
300
		if_print_or(arg, MNT_ROOTFS, or);
301
	if(!((arg>0)^((MNT_NOATIME)>0)))
302
		if_print_or(arg, MNT_NOATIME, or);
303
	if(!((arg>0)^((MNT_VISFLAGMASK)>0)))
304
		if_print_or(arg, MNT_VISFLAGMASK, or);
305
	if(!((arg>0)^((MNT_UPDATE)>0)))
306
		if_print_or(arg, MNT_UPDATE, or);
307
	if(!((arg>0)^((MNT_DELEXPORT)>0)))
308
		if_print_or(arg, MNT_DELEXPORT, or);
309
	if(!((arg>0)^((MNT_RELOAD)>0)))
310
		if_print_or(arg, MNT_RELOAD, or);
311
	if(!((arg>0)^((MNT_FORCE)>0)))
312
		if_print_or(arg, MNT_FORCE, or);
313
	if(!((arg>0)^((MNT_WANTRDWR)>0)))
314
		if_print_or(arg, MNT_WANTRDWR, or);
315
	if(!((arg>0)^((MNT_SOFTDEP)>0)))
316
		if_print_or(arg, MNT_SOFTDEP, or);
317
	if(!((arg>0)^((MNT_DOOMED)>0)))
318
		if_print_or(arg, MNT_DOOMED, or);
319
	printf(">");
320
	if (or == 0)
321
		(void)printf("<invalid>%d", arg);
322
}
323
324
/* AUTO */
325
void
326
rebootoptname (int arg)
327
{
328
	int	or = 0;
329
	printf("%#x<", arg);
330
	if(!((arg>0)^((RB_ASKNAME)>0)))
331
		if_print_or(arg, RB_ASKNAME, or);
332
	if(!((arg>0)^((RB_SINGLE)>0)))
333
		if_print_or(arg, RB_SINGLE, or);
334
	if(!((arg>0)^((RB_NOSYNC)>0)))
335
		if_print_or(arg, RB_NOSYNC, or);
336
	if(!((arg>0)^((RB_HALT)>0)))
337
		if_print_or(arg, RB_HALT, or);
338
	if(!((arg>0)^((RB_INITNAME)>0)))
339
		if_print_or(arg, RB_INITNAME, or);
340
	if(!((arg>0)^((RB_DFLTROOT)>0)))
341
		if_print_or(arg, RB_DFLTROOT, or);
342
	if(!((arg>0)^((RB_KDB)>0)))
343
		if_print_or(arg, RB_KDB, or);
344
	if(!((arg>0)^((RB_RDONLY)>0)))
345
		if_print_or(arg, RB_RDONLY, or);
346
	if(!((arg>0)^((RB_DUMP)>0)))
347
		if_print_or(arg, RB_DUMP, or);
348
	if(!((arg>0)^((RB_MINIROOT)>0)))
349
		if_print_or(arg, RB_MINIROOT, or);
350
	if(!((arg>0)^((RB_CONFIG)>0)))
351
		if_print_or(arg, RB_CONFIG, or);
352
	if(!((arg>0)^((RB_TIMEBAD)>0)))
353
		if_print_or(arg, RB_TIMEBAD, or);
354
	if(!((arg>0)^((RB_POWERDOWN)>0)))
355
		if_print_or(arg, RB_POWERDOWN, or);
356
	if(!((arg>0)^((RB_SERCONS)>0)))
357
		if_print_or(arg, RB_SERCONS, or);
358
	if(!((arg>0)^((RB_USERREQ)>0)))
359
		if_print_or(arg, RB_USERREQ, or);
360
	printf(">");
361
	if (or == 0)
362
		(void)printf("<invalid>%d", arg);
363
}
364
365
/* AUTO */
366
void
367
flockname (int arg)
368
{
369
	int	or = 0;
370
	printf("%#x<", arg);
371
	if(!((arg>0)^((LOCK_SH)>0)))
372
		if_print_or(arg, LOCK_SH, or);
373
	if(!((arg>0)^((LOCK_EX)>0)))
374
		if_print_or(arg, LOCK_EX, or);
375
	if(!((arg>0)^((LOCK_NB)>0)))
376
		if_print_or(arg, LOCK_NB, or);
377
	if(!((arg>0)^((LOCK_UN)>0)))
378
		if_print_or(arg, LOCK_UN, or);
379
	printf(">");
380
	if (or == 0)
381
		(void)printf("<invalid>%d", arg);
382
}
383
384
/* AUTO */
385
void
386
mlockallname (int arg)
387
{
388
	int	or = 0;
389
	printf("%#x<", arg);
390
	if(!((arg>0)^((MCL_CURRENT)>0)))
391
		if_print_or(arg, MCL_CURRENT, or);
392
	if(!((arg>0)^((MCL_FUTURE)>0)))
393
		if_print_or(arg, MCL_FUTURE, or);
394
	printf(">");
395
	if (or == 0)
396
		(void)printf("<invalid>%d", arg);
397
}
398
399
/* AUTO */
400
void
401
shmatname (int arg)
402
{
403
	int	or = 0;
404
	if (arg == 0) {
405
		printf("0<>");
406
		return;
407
	}
408
	printf("%#x<", arg);
409
	if(!((arg>0)^((SHM_RDONLY)>0)))
410
		if_print_or(arg, SHM_RDONLY, or);
411
	if(!((arg>0)^((SHM_RND)>0)))
412
		if_print_or(arg, SHM_RND, or);
413
	printf(">");
414
	if (or == 0)
415
		(void)printf("<invalid>%d", arg);
416
}
417
418
/* AUTO */
419
void
420
whencename (int arg)
421
2
{
422

2
	switch (arg) {
423
	case SEEK_SET:
424
2
		(void)printf("SEEK_SET");
425
2
		break;
426
	case SEEK_CUR:
427
		(void)printf("SEEK_CUR");
428
		break;
429
	case SEEK_END:
430
		(void)printf("SEEK_END");
431
		break;
432
	default: /* Should not reach */
433
		(void)printf("<invalid=%d>", arg);
434
	}
435
2
}
436
437
/* AUTO */
438
void
439
pathconfname (int arg)
440
{
441
	switch (arg) {
442
	case _PC_LINK_MAX:
443
		(void)printf("_PC_LINK_MAX");
444
		break;
445
	case _PC_MAX_CANON:
446
		(void)printf("_PC_MAX_CANON");
447
		break;
448
	case _PC_MAX_INPUT:
449
		(void)printf("_PC_MAX_INPUT");
450
		break;
451
	case _PC_NAME_MAX:
452
		(void)printf("_PC_NAME_MAX");
453
		break;
454
	case _PC_PATH_MAX:
455
		(void)printf("_PC_PATH_MAX");
456
		break;
457
	case _PC_PIPE_BUF:
458
		(void)printf("_PC_PIPE_BUF");
459
		break;
460
	case _PC_CHOWN_RESTRICTED:
461
		(void)printf("_PC_CHOWN_RESTRICTED");
462
		break;
463
	case _PC_NO_TRUNC:
464
		(void)printf("_PC_NO_TRUNC");
465
		break;
466
	case _PC_VDISABLE:
467
		(void)printf("_PC_VDISABLE");
468
		break;
469
	case _PC_ALLOC_SIZE_MIN:
470
		(void)printf("_PC_ALLOC_SIZE_MIN");
471
		break;
472
	case _PC_ASYNC_IO:
473
		(void)printf("_PC_ASYNC_IO");
474
		break;
475
	case _PC_FILESIZEBITS:
476
		(void)printf("_PC_FILESIZEBITS");
477
		break;
478
	case _PC_PRIO_IO:
479
		(void)printf("_PC_PRIO_IO");
480
		break;
481
	case _PC_REC_INCR_XFER_SIZE:
482
		(void)printf("_PC_REC_INCR_XFER_SIZE");
483
		break;
484
	case _PC_REC_MAX_XFER_SIZE:
485
		(void)printf("_PC_REC_MAX_XFER_SIZE");
486
		break;
487
	case _PC_REC_MIN_XFER_SIZE:
488
		(void)printf("_PC_REC_MIN_XFER_SIZE");
489
		break;
490
	case _PC_REC_XFER_ALIGN:
491
		(void)printf("_PC_REC_XFER_ALIGN");
492
		break;
493
	case _PC_SYMLINK_MAX:
494
		(void)printf("_PC_SYMLINK_MAX");
495
		break;
496
	case _PC_SYNC_IO:
497
		(void)printf("_PC_SYNC_IO");
498
		break;
499
	case _PC_TIMESTAMP_RESOLUTION:
500
		(void)printf("_PC_TIMESTAMP_RESOLUTION");
501
		break;
502
	default: /* Should not reach */
503
		(void)printf("<invalid=%d>", arg);
504
	}
505
}
506
507
/* AUTO */
508
void
509
rlimitname (int arg)
510
{
511
	switch (arg) {
512
	case RLIMIT_CPU:
513
		(void)printf("RLIMIT_CPU");
514
		break;
515
	case RLIMIT_FSIZE:
516
		(void)printf("RLIMIT_FSIZE");
517
		break;
518
	case RLIMIT_DATA:
519
		(void)printf("RLIMIT_DATA");
520
		break;
521
	case RLIMIT_STACK:
522
		(void)printf("RLIMIT_STACK");
523
		break;
524
	case RLIMIT_CORE:
525
		(void)printf("RLIMIT_CORE");
526
		break;
527
	case RLIMIT_RSS:
528
		(void)printf("RLIMIT_RSS");
529
		break;
530
	case RLIMIT_MEMLOCK:
531
		(void)printf("RLIMIT_MEMLOCK");
532
		break;
533
	case RLIMIT_NPROC:
534
		(void)printf("RLIMIT_NPROC");
535
		break;
536
	case RLIMIT_NOFILE:
537
		(void)printf("RLIMIT_NOFILE");
538
		break;
539
	default: /* Should not reach */
540
		(void)printf("<invalid=%d>", arg);
541
	}
542
}
543
544
/* AUTO */
545
void
546
shutdownhowname (int arg)
547
{
548
	switch (arg) {
549
	case SHUT_RD:
550
		(void)printf("SHUT_RD");
551
		break;
552
	case SHUT_WR:
553
		(void)printf("SHUT_WR");
554
		break;
555
	case SHUT_RDWR:
556
		(void)printf("SHUT_RDWR");
557
		break;
558
	default: /* Should not reach */
559
		(void)printf("<invalid=%d>", arg);
560
	}
561
}
562
563
/* AUTO */
564
void
565
prioname (int arg)
566
{
567
	switch (arg) {
568
	case PRIO_MAX:
569
		(void)printf("PRIO_MAX");
570
		break;
571
	case PRIO_PROCESS:
572
		(void)printf("PRIO_PROCESS");
573
		break;
574
	case PRIO_PGRP:
575
		(void)printf("PRIO_PGRP");
576
		break;
577
	case PRIO_USER:
578
		(void)printf("PRIO_USER");
579
		break;
580
	default: /* Should not reach */
581
		(void)printf("<invalid=%d>", arg);
582
	}
583
}
584
585
/* AUTO */
586
void
587
madvisebehavname (int arg)
588
{
589
	switch (arg) {
590
	case MADV_SPACEAVAIL:
591
		(void)printf("MADV_SPACEAVAIL");
592
		break;
593
	case MADV_FREE:
594
		(void)printf("MADV_FREE");
595
		break;
596
	default: /* Should not reach */
597
		(void)printf("<invalid=%d>", arg);
598
	}
599
}
600
601
/* AUTO */
602
void
603
msyncflagsname (int arg)
604
{
605
	switch (arg) {
606
	case MS_ASYNC:
607
		(void)printf("MS_ASYNC");
608
		break;
609
	case MS_SYNC:
610
		(void)printf("MS_SYNC");
611
		break;
612
	case MS_INVALIDATE:
613
		(void)printf("MS_INVALIDATE");
614
		break;
615
	default: /* Should not reach */
616
		(void)printf("<invalid=%d>", arg);
617
	}
618
}
619
620
/* AUTO */
621
void
622
clocktypename (int arg)
623
{
624
	switch (arg) {
625
	case CLOCK_REALTIME:
626
		(void)printf("CLOCK_REALTIME");
627
		break;
628
	case CLOCK_PROCESS_CPUTIME_ID:
629
		(void)printf("CLOCK_PROCESS_CPUTIME_ID");
630
		break;
631
	case CLOCK_MONOTONIC:
632
		(void)printf("CLOCK_MONOTONIC");
633
		break;
634
	case CLOCK_THREAD_CPUTIME_ID:
635
		(void)printf("CLOCK_THREAD_CPUTIME_ID");
636
		break;
637
	case CLOCK_UPTIME:
638
		(void)printf("CLOCK_UPTIME");
639
		break;
640
	default: /* Should not reach */
641
		(void)printf("<invalid=%d>", arg);
642
	}
643
}
644
645
/* AUTO */
646
void
647
rusagewho (int arg)
648
{
649
	switch (arg) {
650
	case RUSAGE_SELF:
651
		(void)printf("RUSAGE_SELF");
652
		break;
653
	case RUSAGE_CHILDREN:
654
		(void)printf("RUSAGE_CHILDREN");
655
		break;
656
	case RUSAGE_THREAD:
657
		(void)printf("RUSAGE_THREAD");
658
		break;
659
	default: /* Should not reach */
660
		(void)printf("<invalid=%d>", arg);
661
	}
662
}
663
664
/* AUTO */
665
void
666
sigactionflagname (int arg)
667
{
668
	int	or = 0;
669
	if (arg == 0) {
670
		printf("0<>");
671
		return;
672
	}
673
	printf("%#x<", arg);
674
	if(!((arg>0)^((SA_ONSTACK)>0)))
675
		if_print_or(arg, SA_ONSTACK, or);
676
	if(!((arg>0)^((SA_RESTART)>0)))
677
		if_print_or(arg, SA_RESTART, or);
678
	if(!((arg>0)^((SA_RESETHAND)>0)))
679
		if_print_or(arg, SA_RESETHAND, or);
680
	if(!((arg>0)^((SA_NODEFER)>0)))
681
		if_print_or(arg, SA_NODEFER, or);
682
	if(!((arg>0)^((SA_NOCLDWAIT)>0)))
683
		if_print_or(arg, SA_NOCLDWAIT, or);
684
	if(!((arg>0)^((SA_NOCLDSTOP)>0)))
685
		if_print_or(arg, SA_NOCLDSTOP, or);
686
	if(!((arg>0)^((SA_SIGINFO)>0)))
687
		if_print_or(arg, SA_SIGINFO, or);
688
	printf(">");
689
	if (or == 0)
690
		(void)printf("<invalid>%d", arg);
691
}
692
693
/* AUTO */
694
void
695
sigprocmaskhowname (int arg)
696
{
697
	switch (arg) {
698
	case SIG_BLOCK:
699
		(void)printf("SIG_BLOCK");
700
		break;
701
	case SIG_UNBLOCK:
702
		(void)printf("SIG_UNBLOCK");
703
		break;
704
	case SIG_SETMASK:
705
		(void)printf("SIG_SETMASK");
706
		break;
707
	default: /* Should not reach */
708
		(void)printf("<invalid=%d>", arg);
709
	}
710
}
711
712
/* AUTO */
713
void
714
sigill_name (int arg)
715
{
716
	switch (arg) {
717
	case ILL_ILLOPC:
718
		(void)printf("ILL_ILLOPC");
719
		break;
720
	case ILL_ILLOPN:
721
		(void)printf("ILL_ILLOPN");
722
		break;
723
	case ILL_ILLADR:
724
		(void)printf("ILL_ILLADR");
725
		break;
726
	case ILL_ILLTRP:
727
		(void)printf("ILL_ILLTRP");
728
		break;
729
	case ILL_PRVOPC:
730
		(void)printf("ILL_PRVOPC");
731
		break;
732
	case ILL_PRVREG:
733
		(void)printf("ILL_PRVREG");
734
		break;
735
	case ILL_COPROC:
736
		(void)printf("ILL_COPROC");
737
		break;
738
	case ILL_BADSTK:
739
		(void)printf("ILL_BADSTK");
740
		break;
741
	default: /* Should not reach */
742
		(void)printf("<invalid=%d>", arg);
743
	}
744
}
745
746
/* AUTO */
747
void
748
sigtrap_name (int arg)
749
{
750
	switch (arg) {
751
	case TRAP_BRKPT:
752
		(void)printf("TRAP_BRKPT");
753
		break;
754
	case TRAP_TRACE:
755
		(void)printf("TRAP_TRACE");
756
		break;
757
	default: /* Should not reach */
758
		(void)printf("<invalid=%d>", arg);
759
	}
760
}
761
762
/* AUTO */
763
void
764
sigemt_name (int arg)
765
{
766
	switch (arg) {
767
	case EMT_TAGOVF:
768
		(void)printf("EMT_TAGOVF");
769
		break;
770
	default: /* Should not reach */
771
		(void)printf("<invalid=%d>", arg);
772
	}
773
}
774
775
/* AUTO */
776
void
777
sigfpe_name (int arg)
778
{
779
	switch (arg) {
780
	case FPE_INTDIV:
781
		(void)printf("FPE_INTDIV");
782
		break;
783
	case FPE_INTOVF:
784
		(void)printf("FPE_INTOVF");
785
		break;
786
	case FPE_FLTDIV:
787
		(void)printf("FPE_FLTDIV");
788
		break;
789
	case FPE_FLTOVF:
790
		(void)printf("FPE_FLTOVF");
791
		break;
792
	case FPE_FLTUND:
793
		(void)printf("FPE_FLTUND");
794
		break;
795
	case FPE_FLTRES:
796
		(void)printf("FPE_FLTRES");
797
		break;
798
	case FPE_FLTINV:
799
		(void)printf("FPE_FLTINV");
800
		break;
801
	case FPE_FLTSUB:
802
		(void)printf("FPE_FLTSUB");
803
		break;
804
	default: /* Should not reach */
805
		(void)printf("<invalid=%d>", arg);
806
	}
807
}
808
809
/* AUTO */
810
void
811
sigbus_name (int arg)
812
{
813
	switch (arg) {
814
	case BUS_ADRALN:
815
		(void)printf("BUS_ADRALN");
816
		break;
817
	case BUS_ADRERR:
818
		(void)printf("BUS_ADRERR");
819
		break;
820
	case BUS_OBJERR:
821
		(void)printf("BUS_OBJERR");
822
		break;
823
	default: /* Should not reach */
824
		(void)printf("<invalid=%d>", arg);
825
	}
826
}
827
828
/* AUTO */
829
void
830
sigsegv_name (int arg)
831
{
832
	switch (arg) {
833
	case SEGV_MAPERR:
834
		(void)printf("SEGV_MAPERR");
835
		break;
836
	case SEGV_ACCERR:
837
		(void)printf("SEGV_ACCERR");
838
		break;
839
	default: /* Should not reach */
840
		(void)printf("<invalid=%d>", arg);
841
	}
842
}
843
844
/* AUTO */
845
void
846
sigchld_name (int arg)
847
{
848
	switch (arg) {
849
	case CLD_EXITED:
850
		(void)printf("CLD_EXITED");
851
		break;
852
	case CLD_KILLED:
853
		(void)printf("CLD_KILLED");
854
		break;
855
	case CLD_DUMPED:
856
		(void)printf("CLD_DUMPED");
857
		break;
858
	case CLD_TRAPPED:
859
		(void)printf("CLD_TRAPPED");
860
		break;
861
	case CLD_STOPPED:
862
		(void)printf("CLD_STOPPED");
863
		break;
864
	case CLD_CONTINUED:
865
		(void)printf("CLD_CONTINUED");
866
		break;
867
	default: /* Should not reach */
868
		(void)printf("<invalid=%d>", arg);
869
	}
870
}
871
872
/* AUTO */
873
void
874
minheritname (int arg)
875
1
{
876

1
	switch (arg) {
877
	case MAP_INHERIT_SHARE:
878
		(void)printf("MAP_INHERIT_SHARE");
879
		break;
880
	case MAP_INHERIT_COPY:
881
		(void)printf("MAP_INHERIT_COPY");
882
		break;
883
	case MAP_INHERIT_NONE:
884
		(void)printf("MAP_INHERIT_NONE");
885
		break;
886
	case MAP_INHERIT_ZERO:
887
1
		(void)printf("MAP_INHERIT_ZERO");
888
1
		break;
889
	default: /* Should not reach */
890
		(void)printf("<invalid=%d>", arg);
891
	}
892
1
}
893
894
/* AUTO */
895
void
896
quotactlname (int arg)
897
{
898
	switch (arg) {
899
	case Q_QUOTAON:
900
		(void)printf("Q_QUOTAON");
901
		break;
902
	case Q_QUOTAOFF:
903
		(void)printf("Q_QUOTAOFF");
904
		break;
905
	case Q_GETQUOTA:
906
		(void)printf("Q_GETQUOTA");
907
		break;
908
	case Q_SETQUOTA:
909
		(void)printf("Q_SETQUOTA");
910
		break;
911
	case Q_SETUSE:
912
		(void)printf("Q_SETUSE");
913
		break;
914
	case Q_SYNC:
915
		(void)printf("Q_SYNC");
916
		break;
917
	default: /* Should not reach */
918
		(void)printf("<invalid=%d>", arg);
919
	}
920
}
921
922
/* AUTO */
923
void
924
sockfamilyname (int arg)
925
{
926
	if (arg == AF_UNSPEC)
927
		printf("AF_UNSPEC");
928
	else if (arg == AF_LOCAL)
929
		printf("AF_LOCAL");
930
	else if (arg == AF_UNIX)
931
		printf("AF_UNIX");
932
	else if (arg == AF_INET)
933
		printf("AF_INET");
934
	else if (arg == AF_IMPLINK)
935
		printf("AF_IMPLINK");
936
	else if (arg == AF_PUP)
937
		printf("AF_PUP");
938
	else if (arg == AF_CHAOS)
939
		printf("AF_CHAOS");
940
	else if (arg == AF_NS)
941
		printf("AF_NS");
942
	else if (arg == AF_ISO)
943
		printf("AF_ISO");
944
	else if (arg == AF_OSI)
945
		printf("AF_OSI");
946
	else if (arg == AF_ECMA)
947
		printf("AF_ECMA");
948
	else if (arg == AF_DATAKIT)
949
		printf("AF_DATAKIT");
950
	else if (arg == AF_CCITT)
951
		printf("AF_CCITT");
952
	else if (arg == AF_SNA)
953
		printf("AF_SNA");
954
	else if (arg == AF_DECnet)
955
		printf("AF_DECnet");
956
	else if (arg == AF_DLI)
957
		printf("AF_DLI");
958
	else if (arg == AF_LAT)
959
		printf("AF_LAT");
960
	else if (arg == AF_HYLINK)
961
		printf("AF_HYLINK");
962
	else if (arg == AF_APPLETALK)
963
		printf("AF_APPLETALK");
964
	else if (arg == AF_ROUTE)
965
		printf("AF_ROUTE");
966
	else if (arg == AF_LINK)
967
		printf("AF_LINK");
968
	else if (arg == AF_COIP)
969
		printf("AF_COIP");
970
	else if (arg == AF_CNT)
971
		printf("AF_CNT");
972
	else if (arg == AF_IPX)
973
		printf("AF_IPX");
974
	else if (arg == AF_INET6)
975
		printf("AF_INET6");
976
	else if (arg == AF_ISDN)
977
		printf("AF_ISDN");
978
	else if (arg == AF_E164)
979
		printf("AF_E164");
980
	else if (arg == AF_NATM)
981
		printf("AF_NATM");
982
	else if (arg == AF_ENCAP)
983
		printf("AF_ENCAP");
984
	else if (arg == AF_SIP)
985
		printf("AF_SIP");
986
	else if (arg == AF_KEY)
987
		printf("AF_KEY");
988
	else if (arg == AF_BLUETOOTH)
989
		printf("AF_BLUETOOTH");
990
	else if (arg == AF_MPLS)
991
		printf("AF_MPLS");
992
	else if (arg == AF_MAX)
993
		printf("AF_MAX");
994
	else /* Should not reach */
995
		(void)printf("<invalid=%d>", arg);
996
}
997
998
/* AUTO */
999
void
1000
sockipprotoname (int arg)
1001
{
1002
	if (arg == IPPROTO_IP)
1003
		printf("IPPROTO_IP");
1004
	else if (arg == IPPROTO_HOPOPTS)
1005
		printf("IPPROTO_HOPOPTS");
1006
	else if (arg == IPPROTO_ICMP)
1007
		printf("IPPROTO_ICMP");
1008
	else if (arg == IPPROTO_IGMP)
1009
		printf("IPPROTO_IGMP");
1010
	else if (arg == IPPROTO_GGP)
1011
		printf("IPPROTO_GGP");
1012
	else if (arg == IPPROTO_IPIP)
1013
		printf("IPPROTO_IPIP");
1014
	else if (arg == IPPROTO_IPV4)
1015
		printf("IPPROTO_IPV4");
1016
	else if (arg == IPPROTO_TCP)
1017
		printf("IPPROTO_TCP");
1018
	else if (arg == IPPROTO_EGP)
1019
		printf("IPPROTO_EGP");
1020
	else if (arg == IPPROTO_PUP)
1021
		printf("IPPROTO_PUP");
1022
	else if (arg == IPPROTO_UDP)
1023
		printf("IPPROTO_UDP");
1024
	else if (arg == IPPROTO_IDP)
1025
		printf("IPPROTO_IDP");
1026
	else if (arg == IPPROTO_TP)
1027
		printf("IPPROTO_TP");
1028
	else if (arg == IPPROTO_IPV6)
1029
		printf("IPPROTO_IPV6");
1030
	else if (arg == IPPROTO_ROUTING)
1031
		printf("IPPROTO_ROUTING");
1032
	else if (arg == IPPROTO_FRAGMENT)
1033
		printf("IPPROTO_FRAGMENT");
1034
	else if (arg == IPPROTO_RSVP)
1035
		printf("IPPROTO_RSVP");
1036
	else if (arg == IPPROTO_GRE)
1037
		printf("IPPROTO_GRE");
1038
	else if (arg == IPPROTO_ESP)
1039
		printf("IPPROTO_ESP");
1040
	else if (arg == IPPROTO_AH)
1041
		printf("IPPROTO_AH");
1042
	else if (arg == IPPROTO_MOBILE)
1043
		printf("IPPROTO_MOBILE");
1044
	else if (arg == IPPROTO_ICMPV6)
1045
		printf("IPPROTO_ICMPV6");
1046
	else if (arg == IPPROTO_NONE)
1047
		printf("IPPROTO_NONE");
1048
	else if (arg == IPPROTO_DSTOPTS)
1049
		printf("IPPROTO_DSTOPTS");
1050
	else if (arg == IPPROTO_EON)
1051
		printf("IPPROTO_EON");
1052
	else if (arg == IPPROTO_ETHERIP)
1053
		printf("IPPROTO_ETHERIP");
1054
	else if (arg == IPPROTO_ENCAP)
1055
		printf("IPPROTO_ENCAP");
1056
	else if (arg == IPPROTO_PIM)
1057
		printf("IPPROTO_PIM");
1058
	else if (arg == IPPROTO_IPCOMP)
1059
		printf("IPPROTO_IPCOMP");
1060
	else if (arg == IPPROTO_CARP)
1061
		printf("IPPROTO_CARP");
1062
	else if (arg == IPPROTO_MPLS)
1063
		printf("IPPROTO_MPLS");
1064
	else if (arg == IPPROTO_PFSYNC)
1065
		printf("IPPROTO_PFSYNC");
1066
	else if (arg == IPPROTO_RAW)
1067
		printf("IPPROTO_RAW");
1068
	else if (arg == IPPROTO_MAX)
1069
		printf("IPPROTO_MAX");
1070
	else if (arg == IPPROTO_DIVERT)
1071
		printf("IPPROTO_DIVERT");
1072
	else if (arg == IPPROTO_DONE)
1073
		printf("IPPROTO_DONE");
1074
	else if (arg == IPPROTO_MAXID)
1075
		printf("IPPROTO_MAXID");
1076
	else /* Should not reach */
1077
		(void)printf("<invalid=%d>", arg);
1078
}
1079
1080
/* AUTO */
1081
void
1082
sockoptname (int arg)
1083
{
1084
	switch (arg) {
1085
	case SO_DEBUG:
1086
		(void)printf("SO_DEBUG");
1087
		break;
1088
	case SO_ACCEPTCONN:
1089
		(void)printf("SO_ACCEPTCONN");
1090
		break;
1091
	case SO_REUSEADDR:
1092
		(void)printf("SO_REUSEADDR");
1093
		break;
1094
	case SO_KEEPALIVE:
1095
		(void)printf("SO_KEEPALIVE");
1096
		break;
1097
	case SO_DONTROUTE:
1098
		(void)printf("SO_DONTROUTE");
1099
		break;
1100
	case SO_BROADCAST:
1101
		(void)printf("SO_BROADCAST");
1102
		break;
1103
	case SO_USELOOPBACK:
1104
		(void)printf("SO_USELOOPBACK");
1105
		break;
1106
	case SO_LINGER:
1107
		(void)printf("SO_LINGER");
1108
		break;
1109
	case SO_OOBINLINE:
1110
		(void)printf("SO_OOBINLINE");
1111
		break;
1112
	case SO_REUSEPORT:
1113
		(void)printf("SO_REUSEPORT");
1114
		break;
1115
	case SO_TIMESTAMP:
1116
		(void)printf("SO_TIMESTAMP");
1117
		break;
1118
	case SO_BINDANY:
1119
		(void)printf("SO_BINDANY");
1120
		break;
1121
	case SO_SNDBUF:
1122
		(void)printf("SO_SNDBUF");
1123
		break;
1124
	case SO_RCVBUF:
1125
		(void)printf("SO_RCVBUF");
1126
		break;
1127
	case SO_SNDLOWAT:
1128
		(void)printf("SO_SNDLOWAT");
1129
		break;
1130
	case SO_RCVLOWAT:
1131
		(void)printf("SO_RCVLOWAT");
1132
		break;
1133
	case SO_SNDTIMEO:
1134
		(void)printf("SO_SNDTIMEO");
1135
		break;
1136
	case SO_RCVTIMEO:
1137
		(void)printf("SO_RCVTIMEO");
1138
		break;
1139
	case SO_ERROR:
1140
		(void)printf("SO_ERROR");
1141
		break;
1142
	case SO_TYPE:
1143
		(void)printf("SO_TYPE");
1144
		break;
1145
	case SO_NETPROC:
1146
		(void)printf("SO_NETPROC");
1147
		break;
1148
	case SO_RTABLE:
1149
		(void)printf("SO_RTABLE");
1150
		break;
1151
	case SO_PEERCRED:
1152
		(void)printf("SO_PEERCRED");
1153
		break;
1154
	case SO_SPLICE:
1155
		(void)printf("SO_SPLICE");
1156
		break;
1157
	default: /* Should not reach */
1158
		(void)printf("<invalid=%d>", arg);
1159
	}
1160
}
1161
1162
/* AUTO */
1163
void
1164
ktracefacname (int arg)
1165
{
1166
	int	or = 0;
1167
	if (arg == 0) {
1168
		printf("0<>");
1169
		return;
1170
	}
1171
	printf("%#x<", arg);
1172
	if(!((arg>0)^((KTRFAC_SYSCALL)>0)))
1173
		if_print_or(arg, KTRFAC_SYSCALL, or);
1174
	if(!((arg>0)^((KTRFAC_SYSRET)>0)))
1175
		if_print_or(arg, KTRFAC_SYSRET, or);
1176
	if(!((arg>0)^((KTRFAC_NAMEI)>0)))
1177
		if_print_or(arg, KTRFAC_NAMEI, or);
1178
	if(!((arg>0)^((KTRFAC_GENIO)>0)))
1179
		if_print_or(arg, KTRFAC_GENIO, or);
1180
	if(!((arg>0)^((KTRFAC_PSIG)>0)))
1181
		if_print_or(arg, KTRFAC_PSIG, or);
1182
	if(!((arg>0)^((KTRFAC_STRUCT)>0)))
1183
		if_print_or(arg, KTRFAC_STRUCT, or);
1184
	if(!((arg>0)^((KTRFAC_USER)>0)))
1185
		if_print_or(arg, KTRFAC_USER, or);
1186
	if(!((arg>0)^((KTRFAC_EXECARGS)>0)))
1187
		if_print_or(arg, KTRFAC_EXECARGS, or);
1188
	if(!((arg>0)^((KTRFAC_EXECENV)>0)))
1189
		if_print_or(arg, KTRFAC_EXECENV, or);
1190
	if(!((arg>0)^((KTRFAC_PLEDGE)>0)))
1191
		if_print_or(arg, KTRFAC_PLEDGE, or);
1192
	if(!((arg>0)^((KTRFAC_ROOT)>0)))
1193
		if_print_or(arg, KTRFAC_ROOT, or);
1194
	if(!((arg>0)^((KTRFAC_INHERIT)>0)))
1195
		if_print_or(arg, KTRFAC_INHERIT, or);
1196
	printf(">");
1197
	if (or == 0)
1198
		(void)printf("<invalid>%d", arg);
1199
}
1200
1201
/* AUTO */
1202
void
1203
itimername (int arg)
1204
{
1205
	switch (arg) {
1206
	case ITIMER_REAL:
1207
		(void)printf("ITIMER_REAL");
1208
		break;
1209
	case ITIMER_VIRTUAL:
1210
		(void)printf("ITIMER_VIRTUAL");
1211
		break;
1212
	case ITIMER_PROF:
1213
		(void)printf("ITIMER_PROF");
1214
		break;
1215
	default: /* Should not reach */
1216
		(void)printf("<invalid=%d>", arg);
1217
	}
1218
}
1219
1220
/* AUTO */
1221
void
1222
evfiltername (int arg)
1223
{
1224
	switch (arg) {
1225
	case EVFILT_READ:
1226
		(void)printf("EVFILT_READ");
1227
		break;
1228
	case EVFILT_WRITE:
1229
		(void)printf("EVFILT_WRITE");
1230
		break;
1231
	case EVFILT_AIO:
1232
		(void)printf("EVFILT_AIO");
1233
		break;
1234
	case EVFILT_VNODE:
1235
		(void)printf("EVFILT_VNODE");
1236
		break;
1237
	case EVFILT_PROC:
1238
		(void)printf("EVFILT_PROC");
1239
		break;
1240
	case EVFILT_SIGNAL:
1241
		(void)printf("EVFILT_SIGNAL");
1242
		break;
1243
	case EVFILT_TIMER:
1244
		(void)printf("EVFILT_TIMER");
1245
		break;
1246
	default: /* Should not reach */
1247
		(void)printf("<invalid=%d>", arg);
1248
	}
1249
}
1250
1251
/* AUTO */
1252
void
1253
pollfdeventname (int arg)
1254
{
1255
	int	or = 0;
1256
	if (arg == 0) {
1257
		printf("0<>");
1258
		return;
1259
	}
1260
	printf("%#x<", arg);
1261
	if(!((arg>0)^((POLLIN)>0)))
1262
		if_print_or(arg, POLLIN, or);
1263
	if(!((arg>0)^((POLLPRI)>0)))
1264
		if_print_or(arg, POLLPRI, or);
1265
	if(!((arg>0)^((POLLOUT)>0)))
1266
		if_print_or(arg, POLLOUT, or);
1267
	if(!((arg>0)^((POLLERR)>0)))
1268
		if_print_or(arg, POLLERR, or);
1269
	if(!((arg>0)^((POLLHUP)>0)))
1270
		if_print_or(arg, POLLHUP, or);
1271
	if(!((arg>0)^((POLLNVAL)>0)))
1272
		if_print_or(arg, POLLNVAL, or);
1273
	if(!((arg>0)^((POLLRDNORM)>0)))
1274
		if_print_or(arg, POLLRDNORM, or);
1275
	if(!((arg>0)^((POLLRDBAND)>0)))
1276
		if_print_or(arg, POLLRDBAND, or);
1277
	if(!((arg>0)^((POLLWRBAND)>0)))
1278
		if_print_or(arg, POLLWRBAND, or);
1279
	printf(">");
1280
	if (or == 0)
1281
		(void)printf("<invalid>%d", arg);
1282
}
1283
1284
/* AUTO */
1285
void
1286
evflagsname (int arg)
1287
{
1288
	int	or = 0;
1289
	if (arg == 0) {
1290
		printf("0<>");
1291
		return;
1292
	}
1293
	printf("%#x<", arg);
1294
	if(!((arg>0)^((EV_ADD)>0)))
1295
		if_print_or(arg, EV_ADD, or);
1296
	if(!((arg>0)^((EV_DELETE)>0)))
1297
		if_print_or(arg, EV_DELETE, or);
1298
	if(!((arg>0)^((EV_ENABLE)>0)))
1299
		if_print_or(arg, EV_ENABLE, or);
1300
	if(!((arg>0)^((EV_DISABLE)>0)))
1301
		if_print_or(arg, EV_DISABLE, or);
1302
	if(!((arg>0)^((EV_ONESHOT)>0)))
1303
		if_print_or(arg, EV_ONESHOT, or);
1304
	if(!((arg>0)^((EV_CLEAR)>0)))
1305
		if_print_or(arg, EV_CLEAR, or);
1306
	if(!((arg>0)^((EV_EOF)>0)))
1307
		if_print_or(arg, EV_EOF, or);
1308
	if(!((arg>0)^((EV_ERROR)>0)))
1309
		if_print_or(arg, EV_ERROR, or);
1310
	printf(">");
1311
	if (or == 0)
1312
		(void)printf("<invalid>%d", arg);
1313
}
1314
1315
/* AUTO */
1316
void
1317
syslogflagname (int arg)
1318
{
1319
	int	or = 0;
1320
	if (arg == 0) {
1321
		printf("0<>");
1322
		return;
1323
	}
1324
	printf("%#x<", arg);
1325
	if(!((arg>0)^((LOG_PID)>0)))
1326
		if_print_or(arg, LOG_PID, or);
1327
	if(!((arg>0)^((LOG_CONS)>0)))
1328
		if_print_or(arg, LOG_CONS, or);
1329
	if(!((arg>0)^((LOG_ODELAY)>0)))
1330
		if_print_or(arg, LOG_ODELAY, or);
1331
	if(!((arg>0)^((LOG_NDELAY)>0)))
1332
		if_print_or(arg, LOG_NDELAY, or);
1333
	if(!((arg>0)^((LOG_NOWAIT)>0)))
1334
		if_print_or(arg, LOG_NOWAIT, or);
1335
	if(!((arg>0)^((LOG_PERROR)>0)))
1336
		if_print_or(arg, LOG_PERROR, or);
1337
	printf(">");
1338
	if (or == 0)
1339
		(void)printf("<invalid>%d", arg);
1340
}
1341
1342
/*
1343
 * AUTO - Special
1344
 * F_ is used to specify fcntl commands as well as arguments. Both sets are
1345
 * grouped in fcntl.h, and this awk script grabs the first group.
1346
 */
1347
void
1348
fcntlcmdname (int arg)
1349
{
1350
	switch (arg1) {
1351
	case F_DUPFD:
1352
		(void)printf("F_DUPFD");
1353
		break;
1354
	case F_GETFD:
1355
		(void)printf("F_GETFD");
1356
		break;
1357
	case F_SETFD:
1358
		(void)printf("F_SETFD");
1359
		break;
1360
	case F_GETFL:
1361
		(void)printf("F_GETFL");
1362
		break;
1363
	case F_SETFL:
1364
		(void)printf("F_SETFL");
1365
		break;
1366
	case F_GETOWN:
1367
		(void)printf("F_GETOWN");
1368
		break;
1369
	case F_SETOWN:
1370
		(void)printf("F_SETOWN");
1371
		break;
1372
	case F_GETLK:
1373
		(void)printf("F_GETLK");
1374
		break;
1375
	case F_SETLK:
1376
		(void)printf("F_SETLK");
1377
		break;
1378
	case F_SETLKW:
1379
		(void)printf("F_SETLKW");
1380
		break;
1381
	case F_DUPFD_CLOEXEC:
1382
		(void)printf("F_DUPFD_CLOEXEC");
1383
		break;
1384
	case F_ISATTY:
1385
		(void)printf("F_ISATTY");
1386
		break;
1387
	default: /* Should not reach */
1388
		(void)printf("<invalid=%d>", arg1);
1389
	}
1390
	if (arg1 == F_SETFD) {
1391
		(void)putchar(',');
1392
		if (arg == FD_CLOEXEC)
1393
			(void)printf("FD_CLOEXEC");
1394
		else if (arg == 0)
1395
			(void)printf("0");
1396
		else
1397
			(void)printf("<invalid>%#x", arg);
1398
1399
	} else if (arg1 == F_SETFL) {
1400
		(void)putchar(',');
1401
		doflagsname(arg, 0);
1402
	} else if (!fancy || (arg1 != F_GETFD && arg1 != F_GETFL && arg1 != F_ISATTY))
1403
		(void)printf(",%#x", arg);
1404
}
1405
1406
/*
1407
 * AUTO - Special
1408
 *
1409
 * The send and recv functions have a flags argument which can be
1410
 * set to 0. There is no corresponding #define. The auto_ functions
1411
 * detect this as "invalid", which is incorrect here.
1412
 */
1413
void
1414
sendrecvflagsname (int flags)
1415
{
1416
	int	or = 0;
1417
1418
	if (flags == 0) {
1419
		(void)printf("0");
1420
		return;
1421
	}
1422
1423
	printf("%#x<", flags);
1424
	if(!((flags>0)^((MSG_OOB)>0)))
1425
		if_print_or(flags, MSG_OOB, or);
1426
	if(!((flags>0)^((MSG_PEEK)>0)))
1427
		if_print_or(flags, MSG_PEEK, or);
1428
	if(!((flags>0)^((MSG_DONTROUTE)>0)))
1429
		if_print_or(flags, MSG_DONTROUTE, or);
1430
	if(!((flags>0)^((MSG_EOR)>0)))
1431
		if_print_or(flags, MSG_EOR, or);
1432
	if(!((flags>0)^((MSG_TRUNC)>0)))
1433
		if_print_or(flags, MSG_TRUNC, or);
1434
	if(!((flags>0)^((MSG_CTRUNC)>0)))
1435
		if_print_or(flags, MSG_CTRUNC, or);
1436
	if(!((flags>0)^((MSG_WAITALL)>0)))
1437
		if_print_or(flags, MSG_WAITALL, or);
1438
	if(!((flags>0)^((MSG_DONTWAIT)>0)))
1439
		if_print_or(flags, MSG_DONTWAIT, or);
1440
	if(!((flags>0)^((MSG_BCAST)>0)))
1441
		if_print_or(flags, MSG_BCAST, or);
1442
	if(!((flags>0)^((MSG_MCAST)>0)))
1443
		if_print_or(flags, MSG_MCAST, or);
1444
	if(!((flags>0)^((MSG_NOSIGNAL)>0)))
1445
		if_print_or(flags, MSG_NOSIGNAL, or);
1446
	if(!((flags>0)^((MSG_CMSG_CLOEXEC)>0)))
1447
		if_print_or(flags, MSG_CMSG_CLOEXEC, or);
1448
	printf(">");
1449
}
1450
1451
/*
1452
 * AUTO - Special
1453
 *
1454
 * SOCK_NONBLOCK and SOCK_CLOEXEC are or'ed into the type
1455
 */
1456
static void
1457
dosocktypename (int arg, int show_type)
1458
{
1459
	int	type = arg & 0xff;		/* XXX */
1460
	int	or = 0;
1461
1462
	printf("%#x<", arg);
1463
	if (show_type || type) {
1464
		or = 1;
1465
		switch (type) {
1466
		case SOCK_STREAM:
1467
			(void)printf("SOCK_STREAM");
1468
			break;
1469
		case SOCK_DGRAM:
1470
			(void)printf("SOCK_DGRAM");
1471
			break;
1472
		case SOCK_RAW:
1473
			(void)printf("SOCK_RAW");
1474
			break;
1475
		case SOCK_RDM:
1476
			(void)printf("SOCK_RDM");
1477
			break;
1478
		case SOCK_SEQPACKET:
1479
			(void)printf("SOCK_SEQPACKET");
1480
			break;
1481
		default: /* Should not reach */
1482
			(void)printf("<invalid=%d>", arg);
1483
		}
1484
	}
1485
1486
	if_print_or(arg, SOCK_CLOEXEC, or);
1487
	if_print_or(arg, SOCK_NONBLOCK, or);
1488
	if_print_or(arg, SOCK_DNS, or);
1489
	printf(">");
1490
}
1491
1492
void
1493
socktypename (int arg)
1494
{
1495
	dosocktypename(arg, 1);
1496
}
1497
1498
void
1499
sockflagsname (int arg)
1500
{
1501
	dosocktypename(arg, 0);
1502
}
1503
1504
void
1505
quotactlcmdname(int cmd)
1506
{
1507
	printf("%#x<QCMD(", cmd);
1508
	quotactlname(cmd >> SUBCMDSHIFT);
1509
	switch (cmd & SUBCMDMASK) {
1510
	case USRQUOTA:
1511
		printf(",%s)>", "USRQUOTA");
1512
		break;
1513
	case GRPQUOTA:
1514
		printf(",%s)>", "GRPQUOTA");
1515
		break;
1516
	default:
1517
		printf(",<invalid>%#x)>", cmd & SUBCMDMASK);
1518
		break;
1519
	}
1520
}
1521
1522
/*
1523
 * AUTO - Special
1524
 *
1525
 * kevent() NOTE_* interpretation depends on the filter type
1526
 */
1527
void
1528
evfflagsname (int filter, int fflags)
1529
{
1530
	int	or = 0;
1531
1532
	if (fflags == 0) {
1533
		printf("0<>");
1534
		return;
1535
	}
1536
	printf("%#x<", fflags);
1537
	switch (filter) {
1538
	case EVFILT_READ:
1539
	case EVFILT_WRITE:
1540
		if_print_or(fflags, NOTE_LOWAT, or);
1541
		if_print_or(fflags, NOTE_EOF, or);
1542
		break;
1543
	case EVFILT_VNODE:
1544
		if_print_or(fflags, NOTE_DELETE, or);
1545
		if_print_or(fflags, NOTE_WRITE, or);
1546
		if_print_or(fflags, NOTE_EXTEND, or);
1547
		if_print_or(fflags, NOTE_ATTRIB, or);
1548
		if_print_or(fflags, NOTE_LINK, or);
1549
		if_print_or(fflags, NOTE_RENAME, or);
1550
		if_print_or(fflags, NOTE_REVOKE, or);
1551
		if_print_or(fflags, NOTE_TRUNCATE, or);
1552
		break;
1553
	case EVFILT_PROC:
1554
		if_print_or(fflags, NOTE_EXIT, or);
1555
		if_print_or(fflags, NOTE_FORK, or);
1556
		if_print_or(fflags, NOTE_EXEC, or);
1557
		if_print_or(fflags, NOTE_TRACK, or);
1558
		if_print_or(fflags, NOTE_TRACKERR, or);
1559
		if_print_or(fflags, NOTE_CHILD, or);
1560
		break;
1561
	}
1562
	printf(">");
1563
}
1564