Annotation of src/usr.bin/kdump/ktrstruct.c, Revision 1.26
1.26 ! anton 1: /* $OpenBSD: ktrstruct.c,v 1.25 2018/07/13 09:25:23 beck Exp $ */
1.1 guenther 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/types.h>
33: #include <sys/resource.h>
34: #include <sys/socket.h>
1.22 guenther 35: #include <sys/select.h>
1.1 guenther 36: #include <sys/stat.h>
37: #include <sys/time.h>
1.14 tedu 38: #include <sys/event.h>
1.1 guenther 39: #include <sys/un.h>
1.26 ! anton 40: #include <sys/fcntl.h>
1.6 guenther 41: #include <ufs/ufs/quota.h>
1.1 guenther 42: #include <netinet/in.h>
43: #include <arpa/inet.h>
44:
45: #include <ctype.h>
46: #include <err.h>
47: #include <limits.h>
1.10 guenther 48: #include <netdb.h>
1.1 guenther 49: #include <poll.h>
50: #include <signal.h>
1.13 guenther 51: #include <stddef.h>
1.1 guenther 52: #include <stdio.h>
53: #include <stdlib.h>
54: #include <stdint.h>
55: #include <string.h>
56: #include <grp.h>
57: #include <pwd.h>
58: #include <unistd.h>
1.18 guenther 59: #include <vis.h>
1.1 guenther 60:
61: #include "kdump.h"
62: #include "kdump_subr.h"
63:
64: #define TIME_FORMAT "%b %e %T %Y"
65:
66: static void
67: ktrsockaddr(struct sockaddr *sa)
68: {
1.18 guenther 69: /*
70: * TODO: Support additional address families
71: * #include <netmpls/mpls.h>
72: * struct sockaddr_mpls *mpls;
73: */
1.1 guenther 74:
75: /*
76: * note: ktrstruct() has already verified that sa points to a
77: * buffer at least sizeof(struct sockaddr) bytes long and exactly
78: * sa->sa_len bytes long.
79: */
80: printf("struct sockaddr { ");
81: sockfamilyname(sa->sa_family);
82: printf(", ");
83:
84: #define check_sockaddr_len(n) \
85: if (sa_##n->s##n##_len < sizeof(struct sockaddr_##n)) { \
86: printf("invalid"); \
87: break; \
88: }
89:
90: switch(sa->sa_family) {
91: case AF_INET: {
92: struct sockaddr_in *sa_in;
1.18 guenther 93: char addr[64];
1.1 guenther 94:
95: sa_in = (struct sockaddr_in *)sa;
96: check_sockaddr_len(in);
97: inet_ntop(AF_INET, &sa_in->sin_addr, addr, sizeof addr);
98: printf("%s:%u", addr, ntohs(sa_in->sin_port));
99: break;
100: }
101: case AF_INET6: {
102: struct sockaddr_in6 *sa_in6;
1.18 guenther 103: char addr[64];
1.1 guenther 104:
105: sa_in6 = (struct sockaddr_in6 *)sa;
106: check_sockaddr_len(in6);
107: inet_ntop(AF_INET6, &sa_in6->sin6_addr, addr, sizeof addr);
108: printf("[%s]:%u", addr, htons(sa_in6->sin6_port));
109: break;
110: }
111: case AF_UNIX: {
112: struct sockaddr_un *sa_un;
1.18 guenther 113: char path[4 * sizeof(sa_un->sun_path) + 1];
114: size_t len;
1.1 guenther 115:
116: sa_un = (struct sockaddr_un *)sa;
1.18 guenther 117: len = sa_un->sun_len;
118: if (len <= offsetof(struct sockaddr_un, sun_path)) {
1.1 guenther 119: printf("invalid");
120: break;
121: }
1.18 guenther 122: len -= offsetof(struct sockaddr_un, sun_path);
123: if (len > sizeof(sa_un->sun_path)) {
124: printf("too long");
125: break;
126: }
127: /* format, stopping at first NUL */
128: len = strnlen(sa_un->sun_path, len);
129: strvisx(path, sa_un->sun_path, len,
130: VIS_CSTYLE | VIS_DQ | VIS_TAB | VIS_NL);
131: printf("\"%s\"", path);
1.1 guenther 132: break;
133: }
134: default:
135: printf("unknown address family");
136: }
137: printf(" }\n");
138: }
139:
140: static void
1.8 guenther 141: print_time(time_t t, int relative, int have_subsec)
1.1 guenther 142: {
143: char timestr[PATH_MAX + 4];
144: struct tm *tm;
145:
1.8 guenther 146: if (t < 0 && have_subsec) {
147: /* negative times with non-zero subsecs require care */
148: printf("-%jd", -(intmax_t)(t + 1));
149: } else
1.1 guenther 150: printf("%jd", (intmax_t)t);
1.8 guenther 151:
1.20 tedu 152: /* 1970s times are probably relative */
153: if (!relative && t > (10 * 365 * 24 * 3600)) {
1.1 guenther 154: tm = localtime(&t);
1.9 jsg 155: if (tm != NULL) {
156: (void)strftime(timestr, sizeof(timestr), TIME_FORMAT,
157: tm);
158: printf("<\"%s\">", timestr);
159: }
1.1 guenther 160: }
161: }
162:
163: static void
164: print_timespec(const struct timespec *tsp, int relative)
165: {
1.2 guenther 166: if (tsp->tv_nsec == UTIME_NOW)
167: printf("UTIME_NOW");
168: else if (tsp->tv_nsec == UTIME_OMIT)
169: printf("UTIME_OMIT");
1.8 guenther 170: else {
171: print_time(tsp->tv_sec, relative, tsp->tv_nsec);
1.2 guenther 172: if (tsp->tv_nsec != 0)
1.8 guenther 173: printf(".%09ld", tsp->tv_sec >= 0 ? tsp->tv_nsec :
174: 1000000000 - tsp->tv_nsec);
175: }
176: }
177:
178: void
179: uidname(int uid)
180: {
181: const char *name;
182:
183: if (uid == -1)
184: printf("-1");
185: else {
186: printf("%u<", (unsigned)uid);
187: if (uid > UID_MAX || (name = user_from_uid(uid, 1)) == NULL)
188: printf("unknown>");
189: else
190: printf("\"%s\">", name);
191: }
192: }
193:
194: void
195: gidname(int gid)
196: {
197: const char *name;
198:
199: if (gid == -1)
200: printf("-1");
201: else {
202: printf("%u<", (unsigned)gid);
203: if (gid > GID_MAX || (name = group_from_gid(gid, 1)) == NULL)
204: printf("unknown>");
205: else
206: printf("\"%s\">", name);
1.2 guenther 207: }
1.1 guenther 208: }
209:
210: static void
211: ktrstat(const struct stat *statp)
212: {
213: char mode[12];
214:
215: /*
216: * note: ktrstruct() has already verified that statp points to a
217: * buffer exactly sizeof(struct stat) bytes long.
218: */
219: printf("struct stat { ");
220: strmode(statp->st_mode, mode);
1.8 guenther 221: printf("dev=%d, ino=%llu, mode=%s, nlink=%u, uid=",
1.1 guenther 222: statp->st_dev, (unsigned long long)statp->st_ino,
223: mode, statp->st_nlink);
1.8 guenther 224: uidname(statp->st_uid);
225: printf(", gid=");
226: gidname(statp->st_gid);
227: printf(", rdev=%d, ", statp->st_rdev);
1.1 guenther 228: printf("atime=");
229: print_timespec(&statp->st_atim, 0);
230: printf(", mtime=");
231: print_timespec(&statp->st_mtim, 0);
232: printf(", ctime=");
233: print_timespec(&statp->st_ctim, 0);
1.7 krw 234: printf(", size=%lld, blocks=%lld, blksize=%d, flags=0x%x, gen=0x%x",
1.1 guenther 235: statp->st_size, statp->st_blocks, statp->st_blksize,
236: statp->st_flags, statp->st_gen);
237: printf(" }\n");
238: }
239:
240: static void
241: ktrtimespec(const struct timespec *tsp, int relative)
242: {
243: printf("struct timespec { ");
244: print_timespec(tsp, relative);
245: printf(" }\n");
246: }
247:
248: static void
1.3 guenther 249: print_timeval(const struct timeval *tvp, int relative)
1.1 guenther 250: {
1.8 guenther 251: print_time(tvp->tv_sec, relative, tvp->tv_usec);
252: if (tvp->tv_usec != 0)
253: printf(".%06ld", tvp->tv_sec >= 0 ? tvp->tv_usec :
1.4 guenther 254: 1000000 - tvp->tv_usec);
1.3 guenther 255: }
256:
257: static void
258: ktrtimeval(const struct timeval *tvp, int relative)
259: {
260: printf("struct timeval { ");
261: print_timeval(tvp, relative);
1.1 guenther 262: printf(" }\n");
263: }
264:
265: static void
266: ktrsigaction(const struct sigaction *sa)
267: {
268: /*
269: * note: ktrstruct() has already verified that sa points to a
270: * buffer exactly sizeof(struct sigaction) bytes long.
271: */
1.19 guenther 272: /*
273: * Fuck! Comparison of function pointers on hppa assumes you can
274: * dereference them if they're plabels! Cast everything to void *
275: * to suppress that extra logic; sorry folks, the address we report
276: * here might not match what you see in your executable...
277: */
1.1 guenther 278: printf("struct sigaction { ");
1.19 guenther 279: if ((void *)sa->sa_handler == (void *)SIG_DFL)
1.1 guenther 280: printf("handler=SIG_DFL");
1.19 guenther 281: else if ((void *)sa->sa_handler == (void *)SIG_IGN)
1.1 guenther 282: printf("handler=SIG_IGN");
283: else if (sa->sa_flags & SA_SIGINFO)
284: printf("sigaction=%p", (void *)sa->sa_sigaction);
285: else
286: printf("handler=%p", (void *)sa->sa_handler);
287: printf(", mask=");
288: sigset(sa->sa_mask);
289: printf(", flags=");
290: sigactionflagname(sa->sa_flags);
291: printf(" }\n");
292: }
293:
294: static void
295: print_rlim(rlim_t lim)
296: {
297: if (lim == RLIM_INFINITY)
298: printf("infinite");
299: else
300: printf("%llu", (unsigned long long)lim);
301: }
302:
303: static void
304: ktrrlimit(const struct rlimit *limp)
305: {
306: printf("struct rlimit { ");
307: printf("cur=");
308: print_rlim(limp->rlim_cur);
309: printf(", max=");
310: print_rlim(limp->rlim_max);
311: printf(" }\n");
312: }
313:
314: static void
315: ktrtfork(const struct __tfork *tf)
316: {
317: printf("struct __tfork { tcb=%p, tid=%p, stack=%p }\n",
318: tf->tf_tcb, (void *)tf->tf_tid, tf->tf_stack);
319: }
320:
321: static void
1.23 guenther 322: ktrfds(const char *data, size_t count)
323: {
324: size_t i;
325: int fd;
326:
327: for (i = 0; i < count - 1; i++) {
328: memcpy(&fd, &data[i * sizeof(fd)], sizeof(fd));
329: printf("fd[%zu] = %d, ", i, fd);
330: }
331: memcpy(&fd, &data[i * sizeof(fd)], sizeof(fd));
332: printf("fd[%zu] = %d\n", i, fd);
333: }
334:
335: static void
1.17 guenther 336: ktrfdset(struct fd_set *fds, int len)
1.1 guenther 337: {
338: int nfds, i, start = -1;
339: char sep = ' ';
340:
341: nfds = len * NBBY;
342: printf("struct fd_set {");
343: for (i = 0; i <= nfds; i++)
344: if (i != nfds && FD_ISSET(i, fds)) {
345: if (start == -1)
346: start = i;
347: } else if (start != -1) {
348: putchar(sep);
349: if (start == i - 1)
350: printf("%d", start);
351: else if (start == i - 2)
352: printf("%d,%d", start, i - 1);
353: else
354: printf("%d-%d", start, i - 1);
355: sep = ',';
356: start = -1;
357: }
358:
359: printf(" }\n");
360: }
361:
1.3 guenther 362: static void
363: ktrrusage(const struct rusage *rup)
364: {
365: printf("struct rusage { utime=");
366: print_timeval(&rup->ru_utime, 1);
367: printf(", stime=");
368: print_timeval(&rup->ru_stime, 1);
369: printf(", maxrss=%ld, ixrss=%ld, idrss=%ld, isrss=%ld,"
370: " minflt=%ld, majflt=%ld, nswap=%ld, inblock=%ld,"
371: " oublock=%ld, msgsnd=%ld, msgrcv=%ld, nsignals=%ld,"
372: " nvcsw=%ld, nivcsw=%ld }\n",
373: rup->ru_maxrss, rup->ru_ixrss, rup->ru_idrss, rup->ru_isrss,
374: rup->ru_minflt, rup->ru_majflt, rup->ru_nswap, rup->ru_inblock,
375: rup->ru_oublock, rup->ru_msgsnd, rup->ru_msgrcv, rup->ru_nsignals,
376: rup->ru_nvcsw, rup->ru_nivcsw);
377: }
378:
1.6 guenther 379: static void
380: ktrquota(const struct dqblk *quota)
381: {
382: printf("struct dqblk { bhardlimit=%u, bsoftlimit=%u, curblocks=%u,"
383: " ihardlimit=%u, isoftlimit=%u, curinodes=%u, btime=",
384: quota->dqb_bhardlimit, quota->dqb_bsoftlimit,
385: quota->dqb_curblocks, quota->dqb_ihardlimit,
386: quota->dqb_isoftlimit, quota->dqb_curinodes);
1.8 guenther 387: print_time(quota->dqb_btime, 0, 0);
1.6 guenther 388: printf(", itime=");
1.8 guenther 389: print_time(quota->dqb_itime, 0, 0);
1.6 guenther 390: printf(" }\n");
391: }
392:
1.10 guenther 393: static void
394: ktrmsghdr(const struct msghdr *msg)
395: {
396: printf("struct msghdr { name=%p, namelen=%u, iov=%p, iovlen=%u,"
1.16 guenther 397: " control=%p, controllen=%u, flags=",
1.10 guenther 398: msg->msg_name, msg->msg_namelen, msg->msg_iov, msg->msg_iovlen,
1.16 guenther 399: msg->msg_control, msg->msg_controllen);
400: sendrecvflagsname(msg->msg_flags);
401: printf(" }\n");
1.10 guenther 402: }
403:
404: static void
405: ktriovec(const char *data, int count)
406: {
407: struct iovec iov;
408: int i;
409:
410: printf("struct iovec");
411: if (count > 1)
412: printf(" [%d]", count);
413: for (i = 0; i < count; i++) {
414: memcpy(&iov, data, sizeof(iov));
415: data += sizeof(iov);
416: printf(" { base=%p, len=%lu }", iov.iov_base, iov.iov_len);
417: }
418: printf("\n");
419: }
420:
421: static void
1.14 tedu 422: ktrevent(const char *data, int count)
423: {
424: struct kevent kev;
425: int i;
426:
427: printf("struct kevent");
428: if (count > 1)
429: printf(" [%d]", count);
430: for (i = 0; i < count; i++) {
431: memcpy(&kev, data, sizeof(kev));
432: data += sizeof(kev);
1.16 guenther 433: printf(" { ident=%lu, filter=", kev.ident);
434: evfiltername(kev.filter);
435: printf(", flags=");
436: evflagsname(kev.flags);
437: printf(", fflags=");
438: evfflagsname(kev.filter, kev.fflags);
439: printf(", data=%llu", kev.data);
440: if ((kev.flags & EV_ERROR) && fancy) {
441: printf("<\"%s\">", strerror(kev.data));
1.15 tedu 442: }
1.16 guenther 443: printf(", udata=%p }", kev.udata);
1.14 tedu 444: }
445: printf("\n");
446: }
447:
448: static void
1.21 deraadt 449: ktrpollfd(const char *data, int count)
450: {
451: struct pollfd pfd;
452: int i;
453:
454: printf("struct pollfd");
455: if (count > 1)
456: printf(" [%d]", count);
457: for (i = 0; i < count; i++) {
458: memcpy(&pfd, data, sizeof(pfd));
459: data += sizeof(pfd);
460: printf(" { fd=%d, events=", pfd.fd);
461: pollfdeventname(pfd.events);
462: printf(", revents=");
463: pollfdeventname(pfd.revents);
464: printf(" }");
465: }
466: printf("\n");
467: }
468:
469: static void
1.10 guenther 470: ktrcmsghdr(char *data, socklen_t len)
471: {
472: struct msghdr msg;
473: struct cmsghdr *cmsg;
474: int i, count, *fds;
475:
476: msg.msg_control = data;
477: msg.msg_controllen = len;
478:
479: /* count the control messages */
480: count = 0;
481: for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL;
482: cmsg = CMSG_NXTHDR(&msg, cmsg)) {
483: count++;
484: }
485:
486: printf("struct cmsghdr");
487: if (count > 1)
488: printf(" [%d]", count);
489:
490: for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL;
491: cmsg = CMSG_NXTHDR(&msg, cmsg)) {
492: printf(" { len=%u, level=", cmsg->cmsg_len);
493: if (cmsg->cmsg_level == SOL_SOCKET) {
494: printf("SOL_SOCKET, type=");
495: switch (cmsg->cmsg_type) {
496: case SCM_RIGHTS:
497: printf("SCM_RIGHTS, data=");
498: fds = (int *)CMSG_DATA(cmsg);
499: for (i = 0;
500: cmsg->cmsg_len > CMSG_LEN(sizeof(int) * i);
501: i++) {
502: printf("%s%d", i ? "," : "", fds[i]);
503: }
504: break;
505: case SCM_TIMESTAMP:
506: default:
507: printf("%d", cmsg->cmsg_type);
508: break;
509: }
510: } else {
511: struct protoent *p = getprotobynumber(cmsg->cmsg_level);
512:
513: printf("%u<%s>, type=%d", cmsg->cmsg_level,
514: p != NULL ? p->p_name : "unknown", cmsg->cmsg_type);
515: }
516: printf(" }");
517: }
518: printf("\n");
519: }
520:
1.26 ! anton 521: static void
! 522: ktrflock(const struct flock *fl)
! 523: {
! 524: printf("struct flock { start=%lld, len=%lld, pid=%d, type=",
! 525: fl->l_start, fl->l_len, fl->l_pid);
! 526: flocktypename(fl->l_type);
! 527: printf(", whence=");
! 528: whencename(fl->l_whence);
! 529: printf(" }\n");
! 530: }
! 531:
1.1 guenther 532: void
533: ktrstruct(char *buf, size_t buflen)
534: {
535: char *name, *data;
536: size_t namelen, datalen;
537: int i;
538:
539: for (name = buf, namelen = 0; namelen < buflen && name[namelen] != '\0';
540: ++namelen)
541: /* nothing */;
542: if (namelen == buflen)
543: goto invalid;
544: if (name[namelen] != '\0')
545: goto invalid;
546: data = buf + namelen + 1;
547: datalen = buflen - namelen - 1;
548: if (datalen == 0)
549: goto invalid;
550: /* sanity check */
551: for (i = 0; i < namelen; ++i)
552: if (!isalpha((unsigned char)name[i]))
553: goto invalid;
554: if (strcmp(name, "stat") == 0) {
555: struct stat sb;
556:
557: if (datalen != sizeof(struct stat))
558: goto invalid;
559: memcpy(&sb, data, datalen);
560: ktrstat(&sb);
561: } else if (strcmp(name, "sockaddr") == 0) {
562: struct sockaddr_storage ss;
563:
564: if (datalen > sizeof(ss))
565: goto invalid;
566: memcpy(&ss, data, datalen);
567: if ((ss.ss_family != AF_UNIX &&
568: datalen < sizeof(struct sockaddr)) || datalen != ss.ss_len)
569: goto invalid;
570: ktrsockaddr((struct sockaddr *)&ss);
571: } else if (strcmp(name, "abstimespec") == 0 ||
572: strcmp(name, "reltimespec") == 0) {
573: struct timespec ts;
574:
575: if (datalen != sizeof(ts))
576: goto invalid;
577: memcpy(&ts, data, datalen);
578: ktrtimespec(&ts, name[0] == 'r');
579: } else if (strcmp(name, "abstimeval") == 0 ||
580: strcmp(name, "reltimeval") == 0) {
581: struct timeval tv;
582:
583: if (datalen != sizeof(tv))
584: goto invalid;
585: memcpy(&tv, data, datalen);
586: ktrtimeval(&tv, name[0] == 'r');
587: } else if (strcmp(name, "sigaction") == 0) {
588: struct sigaction sa;
589:
590: if (datalen != sizeof(sa))
591: goto invalid;
592: memcpy(&sa, data, datalen);
593: ktrsigaction(&sa);
594: } else if (strcmp(name, "rlimit") == 0) {
595: struct rlimit lim;
596:
597: if (datalen != sizeof(lim))
598: goto invalid;
599: memcpy(&lim, data, datalen);
600: ktrrlimit(&lim);
1.3 guenther 601: } else if (strcmp(name, "rusage") == 0) {
602: struct rusage ru;
603:
604: if (datalen != sizeof(ru))
605: goto invalid;
606: memcpy(&ru, data, datalen);
607: ktrrusage(&ru);
1.1 guenther 608: } else if (strcmp(name, "tfork") == 0) {
609: struct __tfork tf;
610:
611: if (datalen != sizeof(tf))
612: goto invalid;
613: memcpy(&tf, data, datalen);
614: ktrtfork(&tf);
1.23 guenther 615: } else if (strcmp(name, "fds") == 0) {
616: if (datalen % sizeof(int))
617: goto invalid;
618: ktrfds(data, datalen / sizeof(int));
1.1 guenther 619: } else if (strcmp(name, "fdset") == 0) {
620: struct fd_set *fds;
1.10 guenther 621:
1.1 guenther 622: if ((fds = malloc(datalen)) == NULL)
623: err(1, "malloc");
624: memcpy(fds, data, datalen);
625: ktrfdset(fds, datalen);
626: free(fds);
1.6 guenther 627: } else if (strcmp(name, "quota") == 0) {
628: struct dqblk quota;
629:
630: if (datalen != sizeof(quota))
631: goto invalid;
632: memcpy("a, data, datalen);
633: ktrquota("a);
1.10 guenther 634: } else if (strcmp(name, "msghdr") == 0) {
635: struct msghdr msg;
636:
637: if (datalen != sizeof(msg))
638: goto invalid;
639: memcpy(&msg, data, datalen);
640: ktrmsghdr(&msg);
641: } else if (strcmp(name, "iovec") == 0) {
642: if (datalen % sizeof(struct iovec))
643: goto invalid;
644: ktriovec(data, datalen / sizeof(struct iovec));
1.14 tedu 645: } else if (strcmp(name, "kevent") == 0) {
646: if (datalen % sizeof(struct kevent))
647: goto invalid;
648: ktrevent(data, datalen / sizeof(struct kevent));
1.21 deraadt 649: } else if (strcmp(name, "pollfd") == 0) {
650: if (datalen % sizeof(struct pollfd))
651: goto invalid;
652: ktrpollfd(data, datalen / sizeof(struct pollfd));
1.10 guenther 653: } else if (strcmp(name, "cmsghdr") == 0) {
654: char *cmsg;
655:
656: if ((cmsg = malloc(datalen)) == NULL)
657: err(1, "malloc");
658: memcpy(cmsg, data, datalen);
659: ktrcmsghdr(cmsg, datalen);
660: free(cmsg);
1.12 deraadt 661: } else if (strcmp(name, "pledgereq") == 0) {
1.24 deraadt 662: printf("promise=");
663: showbufc(basecol + sizeof("promise=") - 1,
1.18 guenther 664: (unsigned char *)data, datalen, VIS_DQ | VIS_TAB | VIS_NL);
1.24 deraadt 665: } else if (strcmp(name, "pledgeexecreq") == 0) {
666: printf("execpromise=");
667: showbufc(basecol + sizeof("execpromise=") - 1,
1.25 beck 668: (unsigned char *)data, datalen, VIS_DQ | VIS_TAB | VIS_NL);
669: } else if (strcmp(name, "unveil") == 0) {
670: printf("flags=");
671: showbufc(basecol + sizeof("flags=") - 1,
1.18 guenther 672: (unsigned char *)data, datalen, VIS_DQ | VIS_TAB | VIS_NL);
1.26 ! anton 673: } else if (strcmp(name, "flock") == 0) {
! 674: struct flock fl;
! 675:
! 676: if (datalen != sizeof(fl))
! 677: goto invalid;
! 678: memcpy(&fl, data, datalen);
! 679: ktrflock(&fl);
1.1 guenther 680: } else {
681: printf("unknown structure %s\n", name);
682: }
683: return;
684: invalid:
685: printf("invalid record\n");
686: }